“This is the 21st day of my participation in the Gwen Challenge in November. See details of the event: The Last Gwen Challenge 2021”.

The realization of classification method

The realization of classification methods based on WEKA, including KNN classification, decision tree classification, naive Bayes classification

steps

KNN classification

1. Open WeKA, enter the Explorer screen, load the weather data set Glass. arff, and switch to the classify TAB. Click Choose and choose WEKA -> ClassiFIERS -> Lazy ->IBk, which is a KNN classifier. The IBk parameter values are kept as default, and the performance of the classifier is tested by cross-validation.

2. Click Start to get the following result:

3. Below, add noise data of different sizes to the glass data set to observe the impact on the performance of the classifier.

Weka ->filters->unsupervised->attribute [AddNoise] converts a certain proportion of class tags in the glass dataset to other class tags. This is to AddNoise data, that is to change the correct class tag to the wrong one. However, we only want to Addnoise data to the training data, and not to Addnoise data to the test data. Therefore, we need to select the FilteredClassifier, whose function is to only Addnoise to the training data. Specific operations are as follows:

Choose to choose – weka – meta – FilteredClassifier,

Click the following location,

Set the classifier to KNN (IBk) and add the noise algorithm Addnoise.

Modify the classification noise percent parameter of the AddNoise filter from 0%, 10% to 50%. After setting, click the Start button to start training and evaluation and observe how the classification accuracy changes.

Decision tree classification

1. Go to weather.Nominal. Arff, switch to classify, and choose decision tree weka-> ClassiFIERS -> Trees ->J48. Select the 10-fold cross-validation method, click Start to run, and get the following results.

2. Select the training set as the test data, as follows

Click Start to get the following result

As you can see that the classification accuracy is 100%, explain the meaning of the data in the rectangular box above, and consider why the final accuracy of the test using the training data set is higher.

3. Right-click the description in the box below, and choose Visualize Tree to generate a decision tree.

4. Using J48 to predict unknown data, create test data set as follows

Edit with notepad, name for the weather. The nominal. Test. The arff.

choose, click set on the right to open the test data set, and then click More Option, setting as follows

Click OK, and then start to run the decision tree algorithm, obtaining the following results:

Naive Bayes algorithm

Go to weather.Nominal. Arff, switch to the classify page and choose Weka -> ClassiFIERS ->Bayes ->BayesNet.