-
-
Save amankharwal/5b21539dfd765ed92a49964019993c83 to your computer and use it in GitHub Desktop.
This file contains 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
X_features = ['Total_Trans_Ct','PC-3','PC-1','PC-0','PC-2','Total_Ct_Chng_Q4_Q1','Total_Relationship_Count'] | |
X = usampled_df_with_pcs[X_features] | |
y = usampled_df_with_pcs['Churn'] | |
train_x,test_x,train_y,test_y = train_test_split(X,y,random_state=42) | |
rf_pipe = Pipeline(steps =[ ('scale',StandardScaler()), ("RF",RandomForestClassifier(random_state=42)) ]) | |
f1_cross_val_scores = cross_val_score(rf_pipe,train_x,train_y,cv=5,scoring='f1') | |
rf_pipe.fit(train_x,train_y) | |
rf_prediction = rf_pipe.predict(test_x) | |
ada_pipe.fit(train_x,train_y) | |
ada_prediction = ada_pipe.predict(test_x) | |
svm_pipe.fit(train_x,train_y) | |
svm_prediction = svm_pipe.predict(test_x) | |
print('F1 Score of Random Forest Model On Test Set - {}'.format(f1(rf_prediction,test_y))) | |
print('F1 Score of AdaBoost Model On Test Set - {}'.format(f1(ada_prediction,test_y))) | |
print('F1 Score of SVM Model On Test Set - {}'.format(f1(svm_prediction,test_y))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment