Skip to content

Instantly share code, notes, and snippets.

@cereniyim
Created May 21, 2020 17:37
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 cereniyim/2aeea86c7c58a3d1260965aedd3738f1 to your computer and use it in GitHub Desktop.
Save cereniyim/2aeea86c7c58a3d1260965aedd3738f1 to your computer and use it in GitHub Desktop.
function to train and evaluate the model with mean square error
def fit_evaluate_model(model, X_train, y_train,
X_valid, y_valid):
# function to train a given model
# return mean squared error of the
# actuals and predictions
model.fit(X_train, y_train)
y_predicted = model.predict(X_valid)
return mean_squared_error(y_valid, y_predicted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment