Skip to content

Instantly share code, notes, and snippets.

@mzaradzki
Created July 3, 2017 09:28
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 mzaradzki/f7ce625c5adf1a16cc9df40770ae33a1 to your computer and use it in GitHub Desktop.
Save mzaradzki/f7ce625c5adf1a16cc9df40770ae33a1 to your computer and use it in GitHub Desktop.
from sklearn.linear_model import LogisticRegression
dfLR = dfOHE.sample(frac=1) # shuffle the dataset before spliting it in 2 parts
dfLR_trn = dfLR[0:45000] # training set
dfLR_tst = dfLR[45000:] # testing set
LR = LogisticRegression(multi_class='ovr') # ovr = one (class) versus rest (of classes)
LR.fit(dfLR_trn[predictors].values, dfLR_trn['status_group_enc'].values)
# model accuracy score between 0% and 100%
score = LR.score(dfLR_tst[predictors].values, dfLR_tst['status_group_enc'].values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment