How to do basic linear prediction with Classification Learner?

조회 수: 2 (최근 30일)
tayfun kuzu
tayfun kuzu 2019년 8월 15일
답변: Uttiya Ghosh 2020년 7월 15일
I did really basic operation with Classification Learner. I defined a 4x2 matrix and first column is my input [1;2;3;4], second is my output [2;4;6;8]. I trained this with Classificaiton Learner. I got 100% at SVM model. Then i tried new data x=[5;6;7;8] with this trained model then i got y=[8;8;8;2]. But i supposed to get y=[10;12;14;16]. Why this error occured? Can Classification do such things? Can anyone help me? What is the right code?

답변 (1개)

Uttiya Ghosh
Uttiya Ghosh 2020년 7월 15일
Hi Tayfun,
As per my understanding you would like to predict a continuous target feature using continuous numeric features. A classification model works well for situations where the target feature is discrete in nature. A regression model on the other hands predicts a continuous target feature. PFB the code of a linear regression model that can be used to achieve your task.
mdl = fitlm ([1;2;3;4],[2;4;6;8]);
pred = predict(mdl,[5;6;7;8]);
For more information, refer to the following link.

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by