原来是小飞 发表于 2014-7-5 17:00

预测代码的优化问题

以下是用支持向量机预测混沌时间序列的一个代码,可是预测时间要好长,上午10:40运行,到下午16:55还是没有出结果,大家看下,可否帮忙优化下?代码如下:clc;
clear all;

load data20.txt;
=size(data20);
x=zeros(nrow,3);
tao=24*6;
for i=1:nrow
    x(i,1)=data20(i);   
    if mod(i,tao)==0
      x(i,2)=fix(i/tao);
      x(i,3)=24*6;
    else
      x(i,3)=mod(i,tao);
      x(i,2)=fix(i/tao)+1;
    end
end
tau=12;
m_demension=14;
% cur_day=30;
% datanum_day=144;
%preday_index=2;
p=3;
cur_index=2736;%x(t)中的t
n_used_datset=cur_index +p;
n_record=cur_index - (m_demension -1)*tau;


for i=1:n_record
    for j=1:m_demension
      row_t_index=cur_index -(i -1);
      jindex=row_t_index-(m_demension -j)*tau;
      x_jihe(2580-(i-1),j)=x(jindex,1);
    end
    kk=row_t_index + p;
    y_jihe(2580-(i-1),1)=x(kk,1);
end
x_train=x_jihe(1:(n_record-1),:);
y_train=y_jihe(1:(n_record-1),:);
x_fina= x_jihe(n_record,:);
y_fina= y_jihe(n_record,:);
%%%%yuce
y_pre_test=0;
e=0;

gam=10;
sig2=2;
=bay_initlssvm({x_train,y_train,'f',gam,sig2,'RBF_kernel'});
=bay_optimize({x_train,y_train,'f',gam0,sig20,'RBF_kernel','preprocess'},2);
=bay_optimize({x_train,y_train,'f',gamopt,sig20,'RBF_kernel','preprocess'},3);
gamopt
sig2opt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

x_test=x_fina;
y_test=y_fina;
%%%%%%%%%%%%%%%%%%%%
type = 'function approximation';%这个引号里面的内容说明了用于回归运算,还有另一种查手册把。
    = trainlssvm({x_train,y_train,type,gamopt,sig2opt,'RBF_kernel'});
    x_single_test=x_fina;
    y_pre_test= simlssvm({x_train,y_train,type,gamopt,sig2opt,'RBF_kernel','preprocess'},{alpha,b},x_single_test);
    actal=y_pre_test;
    %fe(i)=e(i)/y_test_fgyh*100;
% FCaculate=max(e);
% Femain=sum(abs(fe))/31
%%%%%1—————输出求得的极值
% plot(1:max_iter,actal,'-')
% hold on
% plot(1:max_iter,predict_load,'-.d')
   
   
PS:x_jihe为2580x14的矩阵;y_jihe为2580x1的矩阵。谢谢大家了!急求
页: [1]
查看完整版本: 预测代码的优化问题