Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dramkadry committed Apr 6, 2024
1 parent 0679237 commit 9807e95
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions decision_tree/dt_author_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import sys
from time import time
sys.path.append("../tools/")
sys.path.append("./tools/")
from email_preprocess import preprocess


Expand Down Expand Up @@ -41,4 +41,46 @@
acc = accuracy_score(pred, labels_test)

print("Accuracy:", round(accuracy,3))
print("Metrics Accuracy:", round(acc, 3))
print("Metrics Accuracy:", round(acc, 3))

#########################################################

from sklearn.ensemble import AdaBoostClassifier
from sklearn.metrics import accuracy_score

# Create a AdaBoost Classifier (AB) object
t0 = time()
clf = AdaBoostClassifier(n_estimators=100, random_state=0)
clf.fit(features_train, labels_train)
print("Training Time:", round(time()-t0, 3), "s")

acc = accuracy_score(clf.predict(features_test), labels_test)

print("Metrics Accuracy:", round(acc, 3))


#########################################################
from sklearn.neighbors import KNeighborsClassifier

# Create a KNeighbors Classifier (KNN) object
t0 = time()
clf = KNeighborsClassifier(n_neighbors=3)
clf.fit(features_train, labels_train)
print("Training Time:", round(time()-t0, 3), "s")

acc = accuracy_score(clf.predict(features_test), labels_test)
print("Metrics Accuracy:", round(acc, 3))


#########################################################

from sklearn.ensemble import RandomForestClassifier

# Create a RandomForest Classifier (RF) object
t0 = time()
clf = RandomForestClassifier(n_estimators=100, random_state=0)
clf.fit(features_train, labels_train)
print("Training Time:", round(time()-t0, 3), "s")

acc = accuracy_score(clf.predict(features_test), labels_test)
print("Metrics Accuracy:", round(acc, 3))

0 comments on commit 9807e95

Please sign in to comment.