Skip to content

Instantly share code, notes, and snippets.

@sazio
Created August 17, 2020 22:25
Show Gist options
  • Save sazio/6f94de1e648719ef01edf3ea1611b53a to your computer and use it in GitHub Desktop.
Save sazio/6f94de1e648719ef01edf3ea1611b53a to your computer and use it in GitHub Desktop.
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
# split into train and test sets
X_train, X_test, y_train, y_test = train_test_split(X_clf, y_clf, test_size=0.33, random_state=1)
# fit the model
model = LogisticRegression(solver='liblinear')
model.fit(X_train, y_train)
# evaluate the model
yhat = model.predict(X_test)
# evaluate predictions
accuracy = accuracy_score(y_test, yhat)
print('Accuracy: %.2f' % (accuracy*100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment