Created
June 2, 2019 09:38
-
-
Save karamanbk/d4c5e5aa0ff6422e5d9f319e1a4fe132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#train & test split | |
tx_class = tx_class.drop('NextPurchaseDay',axis=1) | |
X, y = tx_class.drop('NextPurchaseDayRange',axis=1), tx_class.NextPurchaseDayRange | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=44) | |
#create an array of models | |
models = [] | |
models.append(("LR",LogisticRegression())) | |
models.append(("NB",GaussianNB())) | |
models.append(("RF",RandomForestClassifier())) | |
models.append(("SVC",SVC())) | |
models.append(("Dtree",DecisionTreeClassifier())) | |
models.append(("XGB",xgb.XGBClassifier())) | |
models.append(("KNN",KNeighborsClassifier())) | |
#measure the accuracy | |
for name,model in models: | |
kfold = KFold(n_splits=2, random_state=22) | |
cv_result = cross_val_score(model,X_train,y_train, cv = kfold,scoring = "accuracy") | |
print(name, cv_result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment