I am way over my head... I keep getting this error and I have no idea what it means. I am hoping someone can help me fix this error. I have searched for "must be a callable, a Keras Model instance or None" and have found nothing.
def build_model(self):
model = Sequential()
model.add(Dense(64, input_dim=7, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(32, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
return model
def train_model(self, X, y):
# Wrap the Keras model for use in scikit-learn
keras_model = KerasClassifier(model=self.build_model, epochs=10, batch_size=32, verbose=0)
# Perform hyperparameter tuning
param_grid = {
'model__epochs': [10],
'model__batch_size': [32]
}
grid_search = GridSearchCV(estimator=keras_model, param_grid=param_grid, cv=3, scoring='accuracy', error_score='raise')
grid_search.fit(X, y)
# Set the best model
self.model = grid_search.best_estimator_
thank you for you patience.