Reputation: 11
The specific implementation of base_estimator is not mentioned in the sklearn documentation. I want to use LSTM as base_estimator of adaboostregressor, but the way in the picture doesn't work, how can I design LSTM as base_estimator? Thank you all.
# This is my model
model = Sequential()
model.add(LSTM(128, return_sequences=False))
model.add(Dropout(0.2))
model.add( Dense(64,activation = 'relu'))
model.add(Dropout(0.3))
model.add( Dense(32,activation = 'relu'))
model.add(Dropout(0.3))
model.add( Dense(8,activation = 'relu'))
model.add(Dropout(0.3))
model.add(Dense(1))
model.compile(optimizer=Adam(lr =0.0003),
loss='mean_squared_error')
from sklearn.ensemble import AdaBoostRegressor
regr = AdaBoostRegressor(base_estimator=model, n_estimators=5, random_state=1)
I tried to assign 'model' to 'base_estimator'. But it reported an error. Here are the errors.
TypeError: Cannot clone object '<tensorflow.python.keras.engine.sequential.Sequential object at 0x7f972c2982e0>'
(type <class 'tensorflow.python.keras.engine.sequential.Sequential'>):
it does not seem to be a scikit-learn estimator as it does not implement a 'get_params' method.
I don't know how to implement this LSTM as a base_estimator.
Upvotes: 1
Views: 106