Not a valid predictor error when trying to predict
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I've trained a few models using the classification learner, they work perfectly fine when I export them to the workspace.
But when I'm running them using the function generated by the classification learner, they produce this error after trying to predict:
Error using classreg.learning.internal.table2PredictMatrix>makeXMatrix (line 97)
Table variable Market_Cap 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 trainClassifier4>@(x)predict(classificationEnsemble,x) (line 73)
ensemblePredictFcn = @(x) predict(classificationEnsemble, x);
Error in trainClassifier4>@(x)ensemblePredictFcn(featureSelectionFcn(predictorExtractionFcn(x))) (line 74)
trainedClassifier.predictFcn = @(x) ensemblePredictFcn(featureSelectionFcn(predictorExtractionFcn(x)));
Error in MakePredictions (line 39)
predictions = trainedModel4.predictFcn(T);
I've had a similar error before but was able to fix it by turning one of the variables to categorical, this isn't the case here, market_cap is the right datatype.
Let me say that I've trained models to be with different features, and I have a code like this at the beginning of the file that trains a model if it doesn't exist in the workspace:
%% Train the models
if ~exist('trainedModel')
trainingData = readtable('historical_data_tagged.csv');
trainedModel = trainClassifier(trainingData);
end
if ~exist('trainedModel2')
trainingData = readtable('historical_data_tagged.csv');
trainedModel2 = trainClassifier2(trainingData);
end
if ~exist('trainedModel3')
trainingData = readtable('historical_data_tagged.csv');
trainedModel3 = trainClassifier3(trainingData);
end
if ~exist('trainedModel4')
trainingData = readtable('historical_data_tagged.csv');
trainedModel4 = trainClassifier4(trainingData);
end
Help?
0 件のコメント
回答 (1 件)
Aditya Patil
2021 年 2 月 17 日
I have brought this issue to the notice of the concerned staff, and it might be fixed in any of the upcoming releases.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Classification Learner App についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!