フィルターのクリア

Trying to deploy a model developed with the classification learner

24 ビュー (過去 30 日間)
Or Shem Tov
Or Shem Tov 2020 年 5 月 12 日
コメント済み: aikaterini vraka 2023 年 3 月 21 日
Hi
Trying to deploy a model here I developed using the classification learner..
I'm trying to use:
>> yfit = trainedClassifier.predictFcn(T2)
Unable to resolve the name trainedClassifier.predictFcn.
Doesn't work, any ideas?
Thx!
  1 件のコメント
Or Shem Tov
Or Shem Tov 2020 年 5 月 12 日
I also tried now to export the model and use this:
yfit = trainedModel.predictFcn(T2)
Error using classreg.learning.internal.table2PredictMatrix>makeXMatrix (line 97)
Table variable IssuerTier is not a valid predictor.
Error in classreg.learning.internal.table2PredictMatrix (line 47)
Xout = makeXMatrix(X,CategoricalPredictors,vrange,pnames);
Error in classreg.learning.classif.CompactClassificationEnsemble/score (line 79)
X = classreg.learning.internal.table2PredictMatrix(X,[],[],...
Error in classreg.learning.classif.CompactClassificationEnsemble/predict (line 159)
scores = score(this,X,varargin{:});
Error in mlearnapp.internal.model.adapterlayer.TrainedClassificationEnsemble>@(x)predict(ClassificationEnsemble,x) (line 50)
functionHandle = @(x) predict(ClassificationEnsemble, x);
Error in mlearnapp.internal.model.transformation.TrainedManualFeatureSelection>@(x)decoratedPredictFunction(featureSelectionFunction(x)) (line 66)
functionHandle = @(x) decoratedPredictFunction(featureSelectionFunction(x));
Error in mlearnapp.internal.model.DatasetSpecification>@(x)exportableModel.predictFcn(predictorExtractionFcn(x)) (line 187)
newExportableModel.predictFcn = @(x) exportableModel.predictFcn(predictorExtractionFcn(x));
Lemme just see that 'IssuerTier' is in the training dataset AND in the new data set, I wonder why it would say 'not a valid predictor'
help? :(

サインインしてコメントする。

回答 (2 件)

Harsha Priya Daggubati
Harsha Priya Daggubati 2020 年 5 月 15 日
Hi,
I assume your model is saved as trainedClassifier from Classification Learner Application. I suggest making sure whether the trainedClassifier object is successfully saved in your workspace and has the function predictFcn. Make sure the test data is similar in structure to the training data.
You can refer to the following link for step-wise explaination:
Hope this helps you figure out the issue!
  2 件のコメント
Or Shem Tov
Or Shem Tov 2020 年 5 月 15 日
Thx for the answer.
Turns out the thing was that 2 of my columns were classified as categorical on the model but imported from the csv file as text, had to change that and it was up and running.
I used this code to solve the problem:
T = readtable('mydata.csv');
T.Column1 = categorical(T.Column1);
T.Column2 = categorical(T.Column2);
predictions = trainedModel.predictFcn(T);
T.predictions = predictions;
Harsha Priya Daggubati
Harsha Priya Daggubati 2020 年 5 月 15 日
Great, I can see this is the issue with test data format being different from train data then.

サインインしてコメントする。


Ushtar Arshad
Ushtar Arshad 2022 年 3 月 7 日
Unable to resolve the name trainedModel.predictFcn?
  2 件のコメント
JIKUI ZHAO
JIKUI ZHAO 2022 年 10 月 22 日
I have the same issue when import testdata for prediction
aikaterini vraka
aikaterini vraka 2023 年 3 月 21 日
I had the same issue and it turns out I needed to run the function before
[trainedClassifier, validationAccuracy] = trainClassifier(trainingData);

サインインしてコメントする。

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by