Last active
April 5, 2020 02:48
-
-
Save f-rumblefish/54c78a2fa7121eb073b4308ddf0c54d4 to your computer and use it in GitHub Desktop.
Audio Model Selection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# algorithm 1 ------------------------------------------------------------------ | |
print(" Naive Bayes ... ") | |
from sklearn import naive_bayes | |
classifier = naive_bayes.GaussianNB() | |
nb_model = classifier.fit(X, Y) | |
prediction = nb_model.predict(X_test) | |
print(" accuracy = ", accuracy_score(Y_test, prediction)) | |
print(" f1_score = ", f1_score(Y_test, prediction)) | |
print(confusion_matrix(Y_test, prediction)) | |
# algorithm 2 ------------------------------------------------------------------ | |
print(" Random Forest ... ") | |
from sklearn.ensemble import RandomForestClassifier | |
classifier = RandomForestClassifier() | |
rf_model = classifier.fit(X, Y) | |
prediction = rf_model.predict(X_test) | |
print(" accuracy = ", accuracy_score(Y_test, prediction)) | |
print(" f1_score = ", f1_score(Y_test, prediction)) | |
print(confusion_matrix(Y_test, prediction)) | |
# algorithm 3 ------------------------------------------------------------------ | |
print(" Gradient Boosting ... ") | |
from sklearn.ensemble import GradientBoostingClassifier as gbc | |
classifier = gbc() | |
gbc_model = classifier.fit(X, Y) | |
prediction = gbc_model.predict(X_test) | |
print(" accuracy = ", accuracy_score(Y_test, prediction)) | |
print(" f1_score = ", f1_score(Y_test, prediction)) | |
print(confusion_matrix(Y_test, prediction)) | |
# algorithm 4 ------------------------------------------------------------------ | |
print(" XGBOOST ... ") | |
from xgboost import XGBClassifier | |
xgb_model = XGBClassifier() | |
xgb_model.fit(X, Y) | |
prediction = xgb_model.predict(X_test) | |
print(" accuracy = ", accuracy_score(Y_test, prediction)) | |
print(" f1_score = ", f1_score(Y_test, prediction)) | |
print(confusion_matrix(Y_test, prediction)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment