在SuperLearner集成模型中将神经网络用作基础学习器

时间:2018-10-21 11:42:15

标签: python tensorflow keras ensemble-learning

我想使用Keras的神经网络作为mlens超级学习者的估计器,但出现以下错误:

<keras.engine.sequential.Sequential object at 0x7f395d6e2e48>' does not 
appear to be a valid estimator as it does not implement a 'get_params' 
method. Type: <class 'keras.engine.sequential.Sequential'>

有人知道如何解决这个问题吗?

下面是我的代码:

from mlens.ensemble import SuperLearner
sl = SuperLearner(
folds=10,
random_state=1,
verbose=2,
backend="multiprocessing"
 )
  # Neural Network: 
  model=Sequential()
  model.add(Dense(85,activation='relu',input_shape=(49,)))
  model.add(Dense(85, activation='relu')) 
  model.add(Dense(85, activation='relu')) 
  model.add(Dense(1,activation='sigmoid'))

  models={

 "nn":model
  }
 sl.fit(X_train, Y_train, batch_size=64, epochs=1000, verbose=0)'

 meta_learner = Ridge(
 solver='auto', fit_intercept=True, alpha=1.0,
 max_iter=100, normalize=False, tol=0.05, random_state=1,
 )

sl.add(nn)
sl.add_meta(meta_learner)
sl.fit(X_train, Y_train, batch_size=64, epochs=1000, verbose=0)

0 个答案:

没有答案