model = XGBClassifier() np.random.seed(32) # this makes results reproducible; comment this line if needed accuracies = [] for counter in range(100): X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.3) # if random_state parameter is removed, train_test_split will use random seed value from the numpy package model.fit(X_train, y_train) y_pred = model.predict(X_test) accuracy = accuracy_score(y_test, y_pred.round()) accuracies.append(accuracy) print('Total number of splittings: ', len(accuracies), 'Mean accuracy score: ', np.mean(accuracies), 'std.dev.: ', np.std(accuracies))
How to write for loop?
Messages In This Thread |
How to write for loop? - by sandy49992 - Aug-29-2018, 04:25 PM
RE: How to write for loop? - by scidam - Aug-30-2018, 01:09 AM
RE: How to write for loop? - by sandy49992 - Aug-30-2018, 11:27 AM
RE: How to write for loop? - by sandy49992 - Aug-30-2018, 02:49 PM
RE: How to write for loop? - by sandy49992 - Aug-30-2018, 04:52 PM
RE: How to write for loop? - by scidam - Aug-31-2018, 12:31 AM
RE: How to write for loop? - by sandy49992 - Sep-04-2018, 03:54 PM
RE: How to write for loop? - by sandy49992 - Sep-21-2018, 01:47 AM
|
Users browsing this thread: 2 Guest(s)