필터 지우기
필터 지우기

How can I fix Errors when predicting values in trained LSBoost model?

조회 수: 4 (최근 30일)
SK
SK 2019년 11월 25일
댓글: SK 2019년 11월 25일
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
SK
SK 2019년 11월 25일
Ridwan, I appreciate your willingness to help. trainedModel.mat exeeds 5MB limit even if zipped and I couldn't attach it here. Would you mind sharing your email so I could send you both? or please send an email to chigapo@gmail.com and I will respond. Thanks again!
Ridwan Alam
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:
  1. what are the column names on "Forecast.xlsx"?
  2. inside the exported "trainedModel" struct, what are the values for "PredictorNames" and "CategoricalPredictors"?
  3. what are the variable names of T? you can find that out using T.Properties.VariableNames.

댓글을 달려면 로그인하십시오.

채택된 답변

Ridwan Alam
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
Ridwan Alam 2019년 11월 25일
Thanks! Glad to help. Please vote up if you liked the conversation as well. Have a good day.
SK
SK 2019년 11월 25일
Voted you up ma friend.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by