Skip to content

Instantly share code, notes, and snippets.

@prashant2018
Last active January 1, 2019 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashant2018/84eda8965ad12dc1fb88a3074e675cec to your computer and use it in GitHub Desktop.
Save prashant2018/84eda8965ad12dc1fb88a3074e675cec to your computer and use it in GitHub Desktop.
import keras
from keras.models import Sequential
from keras.layers import Dense
def build_classifier():
classifier = Sequential()
classifier.add(Dense(units=6, kernel_initializer='uniform', activation='relu', input_dim=11))
classifier.add(Dense(units=6, kernel_initializer='uniform', activation='relu'))
classifier.add(Dense(units=1, kernel_initializer='uniform', activation='sigmoid'))
classifier.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
return classifier
from keras.wrappers.scikit_learn import KerasClassifier
from sklearn.model_selection import cross_val_score
classifier = KerasClassifier(build_fn = build_classifier, batch_size=10, nb_epoch=100)
accuracies = cross_val_score(estimator = classifier, X=X_train,y=y_train, cv=10, n_jobs=-1)
mean = accuracies.mean()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment