# Lack of fit with fitrlinear on multivariate data (version 2016a and later)

2 Ansichten (letzte 30 Tage)
Jeffrey Hawkes am 19 Dez. 2017
Kommentiert: Jeffrey Hawkes am 22 Dez. 2017
I'm trying to use this function, fitrlinear, to develop a linear regression model to predict a variable x1. There are 15 predictor variables (y1:y15) and 74 observations of each. I'm attaching a csv of the data.
% code
predX=table2array(pred);
x1=predX(:,1);
y=predX(:,2:end);
%
cvp = cvpartition(74,'Holdout',0.05);
idxTrain = training(cvp); % Extract training set indices
y = y';
Mdl = fitrlinear(y(:,idxTrain),x1(idxTrain),'ObservationsIn','columns');
%
idxTest = test(cvp); % Extract test set indices
yHat = predict(Mdl,y(:,idxTest),'ObservationsIn','columns');
L = loss(Mdl,y(:,idxTest),x1(idxTest),'ObservationsIn','columns')
This gives an enormous mean squared error (L, at the end), and I can see that the predicted values in yHat are far off. Most of this code is taken from the Matlab examples and tutorials on how to run this function... what am I missing?
perhaps you can suggest a better way to predict this data.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Ben Drebing am 21 Dez. 2017
I would recommend using the Regression Learner app in MATLAB. I find that it really helps when you want to quickly try a bunch of different models on some data. You can get to it by typing
>> regressionLearner
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Ilya am 21 Dez. 2017
Your test set has floor(74*0.05)=3 observations. You can't measure error of any model on such a tiny test set.
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Jeffrey Hawkes am 22 Dez. 2017
Hi llya, thanks for the input. If I change the test set to 20 or 30% of the observations, it doesn't help. One of the variables, y4, is highly correlated with x1, so this model shouldn't be difficult to run and get a good prediction of x1.

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Support Vector Machine Regression finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by