Prediction response of single data points
2 次查看(过去 30 天)
显示 更早的评论
I trained four different machine learning models. The discriminant analysis, decision tree, svm and the kNN-model. When I predict my data packagewise its prediction response is correct but when I'm predicting them data point by data point it only responses noise class.
Is there a reason why I cannot predict the class of each datapoint pointwise?
0 个评论
回答(1 个)
Shrinidhi KR
2020-5-5
You can predict the the class of individual datapoints.
I would suggest to look into Classification Learner and how to export the trained model to MATLAB workspace which can be used to make predictions on new data. This following documentation highlights how it can be done: https://www.mathworks.com/help/stats/export-classification-model-for-use-with-new-data.html
The important point to remember here is to keep in mind the way you pass the new datapoint to the model for prediction. Again as mentioned in the documentation link, the new sent of poinst should have same feature names, datatypes and also need to be passed in the same format as it was passed during training the model.
For example, if the dataset is loaded for a CSV file and imported into a table for traning the model, then individual datapoints are also to be put into table and passed in the same format. Below is an example of iris data and how it can be done using table to show predictions for individual datapoint:
sepallength = [5.1];
sepalwidth = [3.5];
petallength = [1.4];
petalwidth = [0.2];
T = table(sepallength,sepalwidth,petallength,petalwidth);
prediction = trainedModel.predictFcn(T);
This documentation links gives deatils about how to create tables and use them: https://www.mathworks.com/help/matlab/matlab_prog/create-a-table.html
You can also loop through the dataset and pass individual datapoints for prediction as per the required format for the model.
I hope this works for you.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!