- If you supply a table, ensure it contains the same predictor names as your training data. The predictFcn function ignores additional variables in tables. Variable formats and types must match the original training data.
- If you supply a matrix, it must contain the same predictor columns or rows as your training data, in the same order and format. Do not include a response variable, any variables that you did not import in the app, or other unused variables.
When using a trained classifier for object detection in images using a Bag-of-Features approach, an error occurs stating "Unable to use a value of type cell as an index"
3 次查看(过去 30 天)
显示 更早的评论
I have a script for object detection in images using a trained classifier and a Bag-of-Features method. When attempting to apply the trained classifier to a test image, I receive the error "Unable to use a value of type cell as an index". How can I resolve this error and successfully apply the classifier to the test image? I already exported from the classificationLearner, therefore there is a % in the script.
Thank you.
0 个评论
回答(1 个)
Drew
2024-4-12
You have not really provided all the details, but it looks like perhaps there is some mismatch between the format of the features that are being passed to trainedClassifier.predictFcn(imagefeatures), and the format of the features used to train the model in Classification Learner. Were the features in a table, or a matrix, in Classification Learner? On the doc page https://www.mathworks.com/help/stats/export-classification-model-for-use-with-new-data.html , regarding using trainedModel.predictFcn with a model from Classification Learner:
Supply the data T with the same format and data type as the training data used in the app (table or matrix).
If this answer helps you, please remember to accept the answer.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!