Aug-30-2018, 02:49 PM
Hello,Sciadm.
Your code is really perfect,and solve my problem, thank you so much.
And I change a little to select sample data.
However I still have some question?
I'm not sure how to write it run 20 times and get mean and than fill in the accuracy?
I guess need to write next for loops insides, and I have little idea to write.
Please give me some advice~~thanks you very much.
Your code is really perfect,and solve my problem, thank you so much.
And I change a little to select sample data.
However I still have some question?
I'm not sure how to write it run 20 times and get mean and than fill in the accuracy?
I guess need to write next for loops insides, and I have little idea to write.
df = pd.read_csv('LoanStats_2017+2016-39VARIABLES.csv',encoding='big5') df = df.fillna(df.mean()) accuracies = [] acc = [] i=[] for counter in range(1000,220000,5000): j=20# I guess write run 20 times place i.append(counter) c=df.sample(counter) X=c.drop('loan_status',axis=1) #X=X.sample(counter, axis=1) Y=c['loan_status'] model = XGBClassifier() X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.3) model.fit(X_train, y_train) y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred.round())[j] #run j time acc.append(accuracy) accuracy = np.mean(acc) # I need to write accuracies.append(accuracy) print('Total number of splsplittings: ', len(accuracies), 'Mean accuracy score: ', np.mean(accuracies), 'std.dev.: ', np.std(accuracies))I'm not sure how to write code, I think it have some mistakes.
Please give me some advice~~thanks you very much.