how to evaluate my result knn code using confusion matrix
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
0 votes
Share a link to this question
Accepted Answer
0 votes
- The type of the input must be vectors or character matrices. Your inputs are of the type double. You can use the "num2str" function to convert the double type to char array. For example
- The size of both the character array inputs should be the same. In your script, the length of train_Coords is 120 and the length of test_Coords is 30.
38 Comments
- Train your model using the data 'X_train' and 'y_train'. In your case, the (X_train, y_train) is 80% of the total data.
- Predict the results of 'X_test' using the model trained in step 1. Store the results in 'y_test_pred'.
- Pass 'y_test_pred' and 'y_test' in the confusionmat function. In this case, both 'y_test_pred' and 'y_test 'are of the same dimension.










More Answers (0)
Categories
Find more on Model Building and Assessment in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)