# use the trained model to make predictions againts the validation # feature matrix X_validation predictions = lr.predict(X_validation) # determine the accuracy of the model by scoring against the validation # results vector Y_validation print('accuracy_score:', a_s(Y_validation, predictions)) print('\n') print('confusion_matrix') print('\n') # generate confusion matrix print(c_m(Y_validation, predictions)) print('\n') print('classification_report') print('\n') # generate classification report print(c_r(Y_validation, predictions)) # load test dataset testfile = './woe-test.csv' dataset = pandas.read_csv(testfile, header=0) # Dimensions: dataset.shape -> tells us how many rows and cols # i.e. how many instances (rows) & attributes (cols) print('\n dataset.shape:') print(dataset.shape) print('\ndataset.head(5)') print(dataset.head(5)) # drop 'fil' and 'status_log' cols
scoring=scoring) results.append(cv_results) names.append(name) # the data output is: name, mean & std model_res = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std()) print(model_res) # LDA performed best print('\n') print('running LDA model i.e. best performing model on validation data....') print('\n') lda = LDA() # first fit the lda instance against the entire training dataset lda.fit(X_train, Y_train) # use the trained model to make predictions againts the validation # feature matrix X_validation predictions = lda.predict(X_validation) # determine the accuracy of the model by scoring against the validation # results vector Y_validation print('accuracy_score:', a_s(Y_validation, predictions)) print('\n') print('confusion_matrix') print('\n') # generate confusion matrix print(c_m(Y_validation, predictions)) print('\n') print('classification_report') print('\n') # generate classification report print(c_r(Y_validation, predictions))
test_size=test_set_size, random_state=seed, shuffle=False) # instantiate XGBC class using defaults model = XGBC() # fit model to training datasets print('\n training d model...') model.fit(X_train, Y_train) # view trained model print('\n model...') print(model) # make predictions for test data print('\n making predictions...') y_pred = model.predict(X_test) predictions = [round(value) for value in y_pred] train_predictions = model.score(X_train, Y_train) # determine the accuracy of the model by scoring against the test # results vector Y_test print('\n xgb_test_standardized_accuracy_score:', a_s(Y_test, predictions)) print('\n xgb_train_standardized_accuracy_score:', train_predictions) # determine the classification report of the model print('\n xg_classification report:') print('\n') print(c_r(Y_test, predictions, digits=3))