algorithm that works based on the concept of classification code example
Example 1: best algorithm for classification
for clf in classifiers: clf.fit(X_train, y_train) y_pred= clf.predict(X_test) acc = accuracy_score(y_test, y_pred) print("Accuracy of %s is %s"%(clf, acc)) cm = confusion_matrix(y_test, y_pred) print("Confusion Matrix of %s is %s"%(clf, cm)
Example 2: best algorithm for classification
model1 = xgboost.XGBClassifier()classifiers.append(model1)model2 = svm.SVC()classifiers.append(model2)model3 = tree.DecisionTreeClassifier()classifiers.append(model3)model4 = RandomForestClassifier()classifiers.append(model4)