matlab notequal,MATLAB出现 number of datapoints not equal to number of targetpoints错误

R=[134.972961100000,15989.3046000000,1492597.77800000,3.40790271200000;

269.608102000000,31907.3332400000,5947109.56900000,3.40790271200000;

672.135466000000,79297.5187200000,36797224.2400000,17.0307146700000;

939.537699500000,110609.085900000,71681393.9300000,23.8540848400000;

295.777975500000,35504.8105700000,7263170.77000000,7.36954974600000;

481.514152600000,57723.9934500000,19212865.0500000,12.0115579000000;

982.603474600000,117353.154100000,79579747.3000000,24.5968228800000;

170.905795000000,20839.0898200000,2465657.65200000,4.19338087700000;

320.203003500000,39007.7869400000,8643798.98600000,7.86322989100000;

511.878867400000,62278.7678400000,22049524.5300000,12.5849698200000;

745.764725400000,90587.3586700000,46693775.3900000,18.3624642100000;

187.217091700000,23177.9398300000,3006232.60900000,4.52562385900000;

342.999747900000,42427.1437500000,10078084.3400000,8.29800341100000;

540.061174800000,66721.0961100000,24941406.8700000,13.0798579400000;

1057.35455900000,130177.369800000,95133400.9600000,25.6873477800000];

X=R';

D=[0.100000000000000,0.100000000000000;

0.100000000000000,0.150000000000000;

0.100000000000000,0.250000000000000;

0.100000000000000,0.300000000000000;

0.150000000000000,0.150000000000000;

0.150000000000000,0.200000000000000;

0.150000000000000,0.300000000000000;

0.200000000000000,0.100000000000000;

0.200000000000000,0.150000000000000;

0.200000000000000,0.200000000000000;

0.200000000000000,0.250000000000000;

0.250000000000000,0.100000000000000;

0.250000000000000,0.150000000000000;

0.250000000000000,0.200000000000000;

0.250000000000000,0.300000000000000];

Y=D';

R_test=[448.740003800000,53034.5057300000,16442940.3700000,11.3532774800000;

153.508237000000,18444.3821400000,1959051.78900000,3.82173486600000;

710.527095000000,85033.9431700000,41733485.6700000,17.7524389600000;

1021.66656700000,123855.291800000,87386886.7200000,25.2005793400000;

778.241067800000,95996.5073900000,51676861.5700000,18.8748137000000];

Xt=R_test';

D_test=[0.100000000000000,0.200000000000000;

0.150000000000000,0.100000000000000;

0.150000000000000,0.250000000000000;

0.200000000000000,0.300000000000000;

0.250000000000000,0.250000000000000];

Yt=D_test';

type = 'function estimation';

kernel = 'RBF_kernel';

gam = [10]; %正则化参数

sig2 = [32];                 % 内核参数'

model = initlssvm(X,Y,type,gam,sig2,kernel);                 % 模型初始化

%---------------------------------------------------

% 训练与测试

model = trainlssvm(model);  % 训练

Yp = simlssvm(model,Xt);    % 回归

%---------------------------------------------------

% 结果作图

plot(1:length(Yt),Yt,'r+:',1:length(Yp),Yp,'bo:')

title('+为真实值,o为预测值')

错误使用 initlssvm (line 55)

number of datapoints not equal to number of targetpoints...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LSSVM做回归希望对大家有用-源程序以及数据.rar 源代码 %% ==============清除代码窗口和工作空间=============== clc; clear; %% ==================下载数据======================= load surdata1.mat; load surdata2.mat; load wearvol.mat; load workcondition.mat; %% ==================训练数据======================== % 数据预处理 xx=surdata1'; yy=surdata2'; zz=wearvol; ww=workcondition; % 训练数据提取 X=ww; X=xx; Y=yy; %% =====================测试数据===================== Xt=ww; Xt=xx; %% =====================模型初始化===================== type = 'function estimation'; kernel = 'RBF_kernel'; gam = 100;                 % Regularization parameter sig2 = 0.01;              % Kernel parameter (bandwidth in the case of the 'RBF_kernel' % 寻优之后的参数 % gam =  0.0869335 ;                 % Regularization parameter % sig2 =  83.8678 ;              % Kernel parameter (bandwidth in the case of the 'RBF_kernel' %% =====================参数寻优====================== model = initlssvm;                 % 模型初始化 costfun = 'crossvalidatelssvm'; costfun_args = {10,'mse'}; optfun = 'gridsearch'; model = tunelssvm;   % 模型参数优化 %% ======================测试数据======================= model = trainlssvm;  % 训练 Yp = simlssvm; %% ======================结果显示======================== figure; plot,Yp,'ro:') hold on plot,Yp,'b*:') hold on plot,Yp,'k :') grid on; 源程序以及数据.rar

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值