Skip to content
Snippets Groups Projects
Commit 265f4743 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 1792bc17
No related branches found
No related tags found
No related merge requests found
...@@ -197,8 +197,8 @@ def k_nearest_neighbors_all(x, y, k_s=10): ...@@ -197,8 +197,8 @@ def k_nearest_neighbors_all(x, y, k_s=10):
plt.show() plt.show()
def decision_tree(x, y, criterion='entropy', max_depth=4): def decision_tree(x_train, y_train, x_test, y_test, criterion='entropy', max_depth=4):
x_train, x_test, y_train, y_test = train_test_split( x, y, test_size=0.2, random_state=4) # x_train, x_test, y_train, y_test = train_test_split( x, y, test_size=0.2, random_state=4)
print('Train set:', x_train.shape, y_train.shape) print('Train set:', x_train.shape, y_train.shape)
print('Test set:', x_test.shape, y_test.shape) print('Test set:', x_test.shape, y_test.shape)
...@@ -211,6 +211,7 @@ def decision_tree(x, y, criterion='entropy', max_depth=4): ...@@ -211,6 +211,7 @@ def decision_tree(x, y, criterion='entropy', max_depth=4):
yhat = DT.predict(x_test) yhat = DT.predict(x_test)
yhat_prob = DT.predict_proba(x_test) yhat_prob = DT.predict_proba(x_test)
print(confusion_matrix(y_test, yhat, labels=[1, 0]))
print('Accuracy: ', "{:.4f}".format(accuracy_score(y_test, yhat))) print('Accuracy: ', "{:.4f}".format(accuracy_score(y_test, yhat)))
print('Jaccard Idx: ', "{:.4f}".format(jaccard_score(y_test, yhat))) print('Jaccard Idx: ', "{:.4f}".format(jaccard_score(y_test, yhat)))
print('Precision: ', "{:.4f}".format(precision_score(y_test, yhat))) print('Precision: ', "{:.4f}".format(precision_score(y_test, yhat)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment