How can I fix Errors when predicting values in trained LSBoost model?
3 次查看(过去 30 天)
显示 更早的评论
Hello friends, I am totally new to Matlab. I built a LSBoost Model in regression Lerner and imported it to Matlab. I wanted to test the model by inputing the value to predict the outcome. The model has 80 variables, 2 of which are Categorical (HoursEnding and Month). Below are my two lines of codes and bunch of error messages I am getting as a result. Guys please help me out with understanding the missing pieces and hot solve them. Much appreciate it.
My codes after importing trainedMidel into Matlab. Forecast.xlsx are where my predicting values are stored to solve for Y.
T = readtable("Forecast.xlsx");
yfit = trainedModel.predictFcn(T)
There are the errors I am getting as results. It appears that 2 of my categorical variables (HoursEnding and Month) need to be properly declaired. I just don't know how to.
Error using classreg.learning.internal.table2PredictMatrix>makeXMatrix (line 96)
Table variable HoursEnding is not a valid predictor.
Error in classreg.learning.internal.table2PredictMatrix (line 47)
Xout = makeXMatrix(X,CategoricalPredictors,vrange,pnames);
Error in classreg.learning.regr.RegressionModel/predict (line 169)
X = classreg.learning.internal.table2PredictMatrix(X,[],[],...
Error in classreg.learning.regr.CompactRegressionEnsemble/predict (line 95)
yfit = predict@classreg.learning.regr.RegressionModel(this,X,varargin{:});
Error in mlearnapp.internal.model.coremodel.TrainedRegressionEnsemble>@(x)predict(RegressionEnsemble,x) (line 50)
functionHandle = @(x) predict(RegressionEnsemble, 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 166)
newExportableModel.predictFcn = @(x) exportableModel.predictFcn(predictorExtractionFcn(x));
3 个评论
Ridwan Alam
2019-11-25
SK, I understand. On a second thought, I don't think I need to rerun the model. Let's debug step-by-step:
- what are the column names on "Forecast.xlsx"?
- inside the exported "trainedModel" struct, what are the values for "PredictorNames" and "CategoricalPredictors"?
- what are the variable names of T? you can find that out using T.Properties.VariableNames.
采纳的回答
Ridwan Alam
2019-11-25
T = readtable("Forecast.xlsx");
T.HoursEnding = categorical(T.HoursEnding);
T.Month = categorical(T.Month);
yfit = trainedModel.predictFcn(T)
3 个评论
Ridwan Alam
2019-11-25
Thanks! Glad to help. Please vote up if you liked the conversation as well. Have a good day.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Gaussian Process Regression 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!