Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created December 9, 2020 13:51
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 amankharwal/d5d6dc5569eaafb6dfc81e625add3b8f to your computer and use it in GitHub Desktop.
Save amankharwal/d5d6dc5569eaafb6dfc81e625add3b8f to your computer and use it in GitHub Desktop.
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)
print('F1 Score of Random Forest Model On Test Set - {}'.format(f1(rf_prediction,test_y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment