mirror of
https://github.com/Doctorado-ML/STree.git
synced 2025-08-15 23:46:02 +00:00
Implement predict_proba with test.
Fix tree overload with dataset in nodes only needed in tests
This commit is contained in:
11
main.py
11
main.py
@@ -33,14 +33,15 @@ def load_creditcard(n_examples=0):
|
||||
print("Fraud: {0:.3f}% {1}".format(len(y[y == 1])*100/X.shape[0], len(y[y == 1])))
|
||||
print("Valid: {0:.3f}% {1}".format(len(y[y == 0])*100/X.shape[0], len(y[y == 0])))
|
||||
return X, y
|
||||
#X, y = load_creditcard(-5000)
|
||||
#X, y = load_creditcard(0)
|
||||
X, y = load_creditcard(-5000)
|
||||
#X, y = load_creditcard()
|
||||
|
||||
clf = Stree(C=.01, max_iter=100, random_state=random_state)
|
||||
clf.fit(X, y)
|
||||
print(clf)
|
||||
clf.show_tree()
|
||||
clf.save_sub_datasets()
|
||||
print(f"Predicting {y[0]} we have {clf.predict(X[0, :].reshape(-1, X.shape[1]))}")
|
||||
#clf.show_tree()
|
||||
#clf.save_sub_datasets()
|
||||
yp = clf.predict_proba(X[0, :].reshape(-1, X.shape[1]))
|
||||
print(f"Predicting {y[0]} we have {yp[0, 0]} with {yp[0, 1]} of belief")
|
||||
print(f"Classifier's accuracy: {clf.score(X, y, print_out=False):.4f}")
|
||||
clf.show_tree(only_leaves=True)
|
||||
|
Reference in New Issue
Block a user