13

Blog | Classification Learner App in MATLAB | MATLAB Helper ®

 3 years ago
source link: https://matlabhelper.com/blog/matlab/classification-learner-app-in-matlab/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Classification Learner App in MATLAB
Need Urgent Help?

Our experts assist in all MATLAB & Simulink fields with communication options from live sessions to offline work.

testimonials

Philippa E. / PhD Fellow

I STRONGLY recommend MATLAB Helper to EVERYONE interested in doing a successful project & research work! MATLAB Helper has completely surpassed my expectations. Just book their service and forget all your worries.

Yogesh Mangal / Graduate Trainee

MATLAB Helper provide training and internship in MATLAB. It covers many topics of MATLAB. I have received my training from MATLAB Helper with the best experience. It also provide many webinar which is helpful to learning in MATLAB.

Read another post

We used the J, M, and V letter datasets for a classification task in the previous blog. We performed the classification by directly coding. Now let us see how we can do it in the Classification Learner app. In coding, we used only the KNN method, and we did not try to improve accuracy. But in the app, we can use Classification Learner to train models of these classifiers: decision trees, discriminant analysis, support vector machines, logistic regression, nearest neighbors, naive Bayes, and ensemble classification. In addition to training models, we can explore the data, select features, specify validation schemes, and evaluate results. We can export a model to the workspace to use the model with new data or generate MATLAB code to learn about programmatic classification.

The following are the steps that we will be following to perform classification in the Classification Learner app:

1) Our first step before we open the app will be to import the data we will use in the workspace. I have used the same data features of “J”, “M” and “V” that I had used in the previous blog of classification learning. The features.xlsx file that contains the data has been extracted to the workspace.

2) Now, we have to click the classification learner available in the Apps tab in MATLAB. It will be automatically available if you have installed the Statistics and Machine Learning toolbox. We can also open the app by entering classificationLearner in the command prompt.

3) This is how the app looks like after opening. To start the session, we need to click on the New Session icon.

4) A new window named New Session will open. Since the data is already in the workspace, it will be shown in the option, and we have to select it.

As the features are selected in the dataset part, it will automatically identify the response and predictors. The response indicated here is the parameter into which we will classify the data. Here, since the Character is selected as the response and it shows it has three unique values that are “J”, “M” and “V”. Predictors are the features that we use to classify them into the respective classes. The other two columns that are Aspect Ratio and Duration, will automatically become the predictors.

Before going into the validation part, we shall see what validation is and its parts. In validation, the training data is divided into training and validation parts. The validation part is used to check the trained model before testing to see that the model doesn’t get overfitted. There are two different types of validation processes:

  1. Cross-Validation: In this, the number of folds is the number of parts the training data will randomly divide. One part of it will be used for validation and the remaining for training.

  2. Holdout Validation: We can select the percentage of data held out as a testing dataset and the remaining for training. This is usually recommended for large datasets.

Since the dataset that I am using is small, I am not using validation. If I use validation, then, the training data will not be sufficient to learn.

5) This is how the app will look after selecting the dataset and validation method. Initially, the scatter plot of the training data features will appear as the session is opened. The X and Y-axis of the scatter plot can be changed on the right side.

6) Since we don’t know which model suits the dataset, we will select all options here. After this, we have to click the train option to train the testing data for all available models.

7) We can see the training accuracy results for 24 models on the left side. And there is the scatter plot in the center for the model predictions for the selected model.

MH Quiz Contest - Dec'20

Online MCQ Quiz on Machine Learning & MATLAB

Special Prize applicable till 31st December 2020. Hurry up!

8) There is an icon called plots that has the following options.

9) We can now select the top accuracy model. Here we have Fine KNN and Weighted KNN having the highest accuracy of 99.2%. Click on the Export option, and I have exported each of it to the workspace as trainedModel and trainedModel1. Export has the following options:

10) We can test these two models on the testing data and check the accuracy to find the best model. 

After exporting, the command window will look like this:

The trainedModel.predictFcn(readtable(“features.xlsx”)) command will be used to get the prediction output of the exported model. The following code is used to find the accuracy of the model.

testdata=readtable("testdata.xlsx")

predictions = char(trainedModel.predictFcn(testdata))

% accuracy

iscorrect=predictions==cell2mat(string((testdata.Character)))

iscorrect=iscorrect(:,2)

accuracy = sum(iscorrect)*100/20

Similarly, we have to try for the remaining exported model also. Finally, we get the testing accuracy of 90% and 85% for Fine KNN and weighted KNN models. Hence, we can use Fine KNN as it is the best model for this dataset. Thus, in this way, we will find out the best model for the dataset in less time. When we directly coded using the KNN model, we got an accuracy of 80%. Using the app, we were able to identify the best model quickly and got a better accuracy of 90%.

Loved the Blog? Gives us your valuable feedback through comments!

Thank you for reading this blog. Do share this blog, if you found it helpful. If you have any query, post it in the comments or get in touch with us by emailing your questions to [email protected]. Follow us on LinkedInFacebook and Subscribe to our YouTube Channel. We have expanded the traditional classroom teaching to meet the needs of today's learners. Our experts assist in all MATLAB & Simulink fields with communication options from live sessions to offline work with Pricing suitable for everyone. You can get offline help via email or opt for online zoom meetings with one-click content sharing, real-time co-annotation, and digital whiteboard.

If you are looking for one-time expert help, you can go ahead with Pay As You Go Plan. If your task is research-oriented like thesis support or paper implementation and you have a proper timeline, our recommendation would be Research Assistance, a monthly plan with a steady reduction of 10% of the expert fee up to six months of subscription. We also offer Corporate Assistance for requirements with annual validity. The minimum expert booking time is 1 hour under the Pay As You Go plan. You can book 5/10/20 hours under the Research Assistance plan. You will get expert help for the time you book only after you have an active order.

If you are looking for an expert's help and ready for the paid service, share your requirement with necessary attachments & inform us about any Service preference along with the timeline. Once evaluated, we will revert back to you with more details and the next suggested step.

Education is our future. MATLAB is our feature. Happy MATLABing!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK