How to develop "a model" from a given m-file of regression analysis?

조회 수: 1 (최근 30일)
Sergio
Sergio 2024년 2월 29일
댓글: Sergio 2024년 3월 2일
With the help of the attached code I need to develop a model for the price variation based on a combined (linear) dependence on model year such as mileage, plot the result, and develop a corresponding R2 value.
But what does this mean? Does it mean to get a function, where the price is the function f(x) and mileage and model year are parameters in the form of f(x)=ax+b ?
If so, how is that done? I can only find B, L and c in the output.
Anhy suggestions welcomed.
Thanks!

채택된 답변

Star Strider
Star Strider 2024년 2월 29일
If your data are the same as in your earlier post, you can get all that information from the Curve Fitting Toolbox result.
That call would be:
fordfocusfit = fit(num{:,[1 2]}, num{:,3}, 'poly11') % The ‘poly11’ Model Does A Linear Surface Fit In Each Independent Variable
figure
plot(fordfocusfit, num{:,[1 2]}, num{:,3})
You can of course change the model from 'poly11' to whatever you want that works with 3-dimensional data (two independent variables and one dependent variable in this instance, if the data are the same as previously).
If you return a handle to the plot, you can use it to change the appearance (marker, colour, etc.).
  댓글 수: 5
Sergio
Sergio 2024년 2월 29일
편집: Sergio 2024년 2월 29일
@Star Strider did you get an R^2 value with your code? I got one with:
mdl = fitlm(A,B)
Star Strider
Star Strider 2024년 2월 29일
The fitlm call will certainly work. I generally use it because I do not have the Curve Fitting Toolbox, so I only use that in MATLAB Answers posts, since everything is available here.
The Curve Fitting Toolbox requires a separate ‘goodness-of-fit’ output:
[fordfocusfit,GOF] = fit(num(:,[1 2]), num(:,3), 'poly11') % The ‘poly11’ Model Does A Linear Surface Fit In Each Independent Variable
The ‘GOF’ output then has the , adjusted , and other statistics.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2024년 2월 29일
What I would do is to use the Regression Learner app on the Apps tab of the tool ribbon. It's in the Statistics and Machine Learning Toolbox.
Put in your inputs into a table called predictors, and your "response" variable would be the price vector. Then tell it to use all models to do a regression. Look at the errors and choose the model with the lowest errors. Then click the Export button to save the model into a .mat file. The mat file will contain a string that tells you how to apply the model to obtain an estimated price given a set of predictor values.
Attach your workbook if you need more help.
  댓글 수: 5
Image Analyst
Image Analyst 2024년 2월 29일
Slightly better than that : 0.76
That's on the validation data (not used in training). It should be higher if you included the training data of course, but that's not really fair, especially if you're using it on new data, so the r squared on the validation data is what's fair to use.

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

카테고리

Help CenterFile Exchange에서 Support Vector Machine Regression에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by