machine learning algorithms code example

Example 1: best algorithm for classification

Accuracy of XGBClassifier is 95.55Confusion Matrix of XGBClassifier is [[ 9  0  0]                                      [ 0 15  1]                                      [ 0  1 19]]Accuracy of SVC is 95.55Confusion Matrix of SVC is [[ 9  0  0]                            [ 0 16  0]                            [ 0  2 18]]Accuracy of DecisionTreeClassifier is  88.88Confusion Matrix of DecisionTreeClassifier is [[ 9  0  0]                                               [ 0 15  1]                                               [ 0  4 16]]Accuracy of RandomForestClassifier is  84.44Confusion Matrix of RandomForestClassifier is [[ 9  0  0]                                               [ 0 15  1]                                               [ 0  6 14]]

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)

Tags:

Misc Example