def get_scores(model, model_name):
model.fit(X_train, y_train)
train_preds = model.predict(X_train)
test_preds = model.predict(X_test)
train_probs = model.predict_proba(X_train)
test_probs = model.predict_proba(X_test)
print('{} has training accuracy of: {}'.format(model_name, accuracy_score(y_train, train_preds)))
print('{} has test accuracy of: {}\n'.format(model_name, accuracy_score(y_test, test_preds)))
print('{} has training log loss of: {}'.format(model_name, log_loss(y_train, train_probs)))
print('{} has test log loss of: {}\n'.format(model_name, log_loss(y_test, test_probs)))
I want call multiple model later, I call one of them here:
lr_initial = LogisticRegression(n_jobs=-1)
initial_lr_train_preds, initial_lr_test_preds, initial_lr_train_probs, initial_lr_test_probs = get_scores(lr_initial, ' Preliminary Logistic Regression model')
So, I want to put all values of accuracy_score(y_train, train_preds)
of each model in a variable. How can this be done