Created
June 24, 2022 10:13
-
-
Save oguzhari/21c9cea0ac07d99b6e9011da0957e116 to your computer and use it in GitHub Desktop.
Model Eğitimleri
This file contains hidden or 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
| #Model Eğitimleri. | |
| #MultinomialNB Best random_state=3305 | |
| X_train, X_test, y_train, y_test = train_test_split(ogrenme_seti.iloc[:, 0:4], ogrenme_seti.iloc[:,-1:], test_size=0.25,random_state=3305) | |
| clf.fit(X_train,y_train.values.ravel()) | |
| y_pred_test = clf.predict(X_test) | |
| print("Naive Bayes::\n", confusion_matrix(y_test,y_pred_test), "\n") | |
| f1_1 = f1_score(y_test,y_pred_test,average='macro') | |
| print(classification_report(y_test,y_pred_test)) | |
| print("Accuracy: ",accuracy_score(y_test,y_pred_test)) | |
| print("F1 score: ",f1_1) | |
| #Lojistik Regresyon Best random_state=3921 | |
| X_train, X_test, y_train, y_test = train_test_split(ogrenme_seti.iloc[:, 0:4], ogrenme_seti.iloc[:,-1:], test_size=0.25,random_state=3921) | |
| lr.fit(X_train,y_train.values.ravel()) | |
| y_pred_test = lr.predict(X_test) | |
| print("\nLogisticRegression::\n", confusion_matrix(y_test,y_pred_test), "\n") | |
| f1_2 = f1_score(y_test,y_pred_test,average='macro') | |
| print(classification_report(y_test,y_pred_test)) | |
| print("Accuracy: ",accuracy_score(y_test,y_pred_test)) | |
| print("F1 score: ",f1_2) | |
| #Karar Ağacı Best random_state=8679 | |
| X_train, X_test, y_train, y_test = train_test_split(ogrenme_seti.iloc[:, 0:4], ogrenme_seti.iloc[:,-1:], test_size=0.25,random_state=8679) | |
| dtc.fit(X_train,y_train) | |
| y_pred_test = dtc.predict(X_test) | |
| print("\nDecisionTreeClassifier::\n", confusion_matrix(y_test,y_pred_test), "\n") | |
| f1_3 = f1_score(y_test,y_pred_test,average='macro') | |
| print(classification_report(y_test,y_pred_test)) | |
| print("Accuracy: ",accuracy_score(y_test,y_pred_test)) | |
| print("F1 score: ",f1_3) | |
| #Rassal Orman Best random_state=6040 | |
| X_train, X_test, y_train, y_test = train_test_split(ogrenme_seti.iloc[:, 0:4], ogrenme_seti.iloc[:,-1:], test_size=0.25, random_state=6040) | |
| rfc.fit(X_train,y_train.values.ravel()) | |
| y_pred_test = rfc.predict(X_test) | |
| print("\nRandomForestClassifier::\n", confusion_matrix(y_test,y_pred_test), "\n") | |
| f1_4 = f1_score(y_test,y_pred_test,average='macro') | |
| print(classification_report(y_test,y_pred_test)) | |
| print("Accuracy: ",accuracy_score(y_test,y_pred_test)) | |
| print("F1 score: ",f1_4) | |
| #Gradyan Arttırma Best random_state=5211 | |
| X_train, X_test, y_train, y_test = train_test_split(ogrenme_seti.iloc[:, 0:4], ogrenme_seti.iloc[:,-1:], test_size=0.25, random_state=5211) | |
| gradient.fit(X_train,y_train.values.ravel()) | |
| y_pred_test = gradient.predict(X_test) | |
| print("\nGradientBoostingClassifier::\n", confusion_matrix(y_test,y_pred_test), "\n") | |
| f1_5 = f1_score(y_test,y_pred_test,average='macro') | |
| print(classification_report(y_test,y_pred_test)) | |
| print("Accuracy: ",accuracy_score(y_test,y_pred_test)) | |
| print("F1 score: ",f1_5) | |
| #XGB Best random_state=6366 | |
| X_train, X_test, y_train, y_test = train_test_split(ogrenme_seti.iloc[:, 0:4], ogrenme_seti.iloc[:,-1:], test_size=0.25, random_state=6366) | |
| xgb.fit(X_train,y_train.values.ravel()) | |
| y_pred_test = xgb.predict(X_test) | |
| print("\nXGBClassifier::\n", confusion_matrix(y_test,y_pred_test), "\n") | |
| f1_6 = f1_score(y_test,y_pred_test,average='macro') | |
| print(classification_report(y_test,y_pred_test)) | |
| print("Accuracy: ",accuracy_score(y_test,y_pred_test)) | |
| print("F1 score: ",f1_6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment