91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 218KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-02-05
  • 語言: Matlab
  • 標簽:

資源簡介

matlab關于SVM的回歸預測分析(上證指數開盤指數預測)相關代碼

資源截圖

代碼片段和文件信息

%%?Matlab神經網絡43個案例分析

%?基于SVM的回歸預測分析——上證指數開盤指數預測
%?by?李洋(faruto)
%?http://www.matlabsky.com
%?Email:faruto@163.com
%?http://weibo.com/faruto?
%?http://blog.sina.com.cn/faruto
%?2013.01.01
%%?清空環境變量
function?chapter_sh
tic;
close?all;
clear;
clc;
format?compact;
%%?數據的提取和預處理

%?載入測試數據上證指數(1990.12.19-2009.08.19)
%?數據是一個4579*6的double型的矩陣每一行表示每一天的上證指數
%?6列分別表示當天上證指數的開盤指數指數最高值指數最低值收盤指數當日交易量當日交易額.
load?chapter_sh.mat;

%?提取數據
[mn]?=?size(sh);
ts?=?sh(2:m1);
tsx?=?sh(1:m-1:);

%?畫出原始上證指數的每日開盤數
figure;
plot(ts‘LineWidth‘2);
title(‘上證指數的每日開盤數(1990.12.20-2009.08.19)‘‘FontSize‘12);
xlabel(‘交易日天數(1990.12.19-2009.08.19)‘‘FontSize‘12);
ylabel(‘開盤數‘‘FontSize‘12);
grid?on;

%?數據預處理將原始數據進行歸一化
ts?=?ts‘;
tsx?=?tsx‘;

%?mapminmax為matlab自帶的映射函數
%?對ts進行歸一化
[TSTSps]?=?mapminmax(ts12);

%?畫出原始上證指數的每日開盤數歸一化后的圖像
figure;
plot(TS‘LineWidth‘2);
title(‘原始上證指數的每日開盤數歸一化后的圖像‘‘FontSize‘12);
xlabel(‘交易日天數(1990.12.19-2009.08.19)‘‘FontSize‘12);
ylabel(‘歸一化后的開盤數‘‘FontSize‘12);
grid?on;
%?對TS進行轉置以符合libsvm工具箱的數據格式要求
TS?=?TS‘;

%?mapminmax為matlab自帶的映射函數
%?對tsx進行歸一化
[TSXTSXps]?=?mapminmax(tsx12);
%?對TSX進行轉置以符合libsvm工具箱的數據格式要求
TSX?=?TSX‘;

%%?選擇回歸預測分析最佳的SVM參數c&g

%?首先進行粗略選擇:?
[bestmsebestcbestg]?=?SVMcgForRegress(TSTSX-88-88);

%?打印粗略選擇結果
disp(‘打印粗略選擇結果‘);
str?=?sprintf(?‘Best?Cross?Validation?MSE?=?%g?Best?c?=?%g?Best?g?=?%g‘bestmsebestcbestg);
disp(str);

%?根據粗略選擇的結果圖再進行精細選擇:?
[bestmsebestcbestg]?=?SVMcgForRegress(TSTSX-44-4430.50.50.05);

%?打印精細選擇結果
disp(‘打印精細選擇結果‘);
str?=?sprintf(?‘Best?Cross?Validation?MSE?=?%g?Best?c?=?%g?Best?g?=?%g‘bestmsebestcbestg);
disp(str);

%%?利用回歸預測分析最佳的參數進行SVM網絡訓練
cmd?=?[‘-c?‘?num2str(bestc)?‘?-g?‘?num2str(bestg)??‘?-s?3?-p?0.01‘];
model?=?svmtrain(TSTSXcmd);

%%?SVM網絡回歸預測
[predictmse]?=?svmpredict(TSTSXmodel);
predict?=?mapminmax(‘reverse‘predict‘TSps);
predict?=?predict‘;

%?打印回歸結果
str?=?sprintf(?‘均方誤差?MSE?=?%g?相關系數?R?=?%g%%‘mse(2)mse(3)*100);
disp(str);

%%?結果分析
figure;
hold?on;
plot(ts‘-o‘);
plot(predict‘r-^‘);
legend(‘原始數據‘‘回歸預測數據‘);
hold?off;
title(‘原始數據和回歸預測數據對比‘‘FontSize‘12);
xlabel(‘交易日天數(1990.12.19-2009.08.19)‘‘FontSize‘12);
ylabel(‘開盤數‘‘FontSize‘12);
grid?on;

figure;
error?=?predict?-?ts‘;
plot(error‘rd‘);
title(‘誤差圖(predicted?data?-?original?data)‘‘FontSize‘12);
xlabel(‘交易日天數(1990.12.19-2009.08.19)‘‘FontSize‘12);
ylabel(‘誤差量‘‘FontSize‘12);
grid?on;

figure;
error?=?(predict?-?ts‘)./ts‘;
plot(error‘rd‘);
title(‘相對誤差圖(predicted?data?-?original?data)/original?data‘‘FontSize‘12);
xlabel(‘交易日天數(1990.12.19-2009.08.19)‘‘FontSize‘12);
ylabel(‘相對誤差量‘‘FontSize‘12);
grid?on;
snapnow;
toc;

%%?子函數?SVMcgForRegress.m
function?[msebestcbestg]?=?SVMcgForRegress(train_labeltraincmincmaxgmingmaxvcstepgstepmsestep)
%SVMcg?cross?validation?by?faruto

%
%?by?faruto
%Email:patrick.lee@foxmail.com?QQ:516667408?http://blog.sina.com.cn/faruto?BNU
%last?modified?2010.01.17
%Super?Moderator?@?www.ilovematlab.cn

%?若轉載請注明:
%?faruto?and?liyang??LIBSVM-farutoUltimat

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????5529??2013-08-18?10:59??chapter16\chapter_sh.m

?????文件?????219976??2010-01-30?18:39??chapter16\chapter_sh.mat

?????文件??????24872??2013-08-18?11:01??chapter16\html\chapter_sh.html

?????文件???????3998??2013-08-18?11:01??chapter16\html\chapter_sh.png

?????文件???????9331??2013-08-18?10:59??chapter16\html\chapter_sh_01.png

?????文件??????10025??2013-08-18?10:59??chapter16\html\chapter_sh_02.png

?????文件??????17498??2013-08-18?11:01??chapter16\html\chapter_sh_03.png

?????文件??????18915??2013-08-18?11:01??chapter16\html\chapter_sh_04.png

?????文件??????22389??2013-08-18?11:01??chapter16\html\chapter_sh_05.png

?????文件??????17509??2013-08-18?11:01??chapter16\html\chapter_sh_06.png

?????文件??????12441??2013-08-18?11:01??chapter16\html\chapter_sh_07.png

?????文件??????12113??2013-08-18?11:01??chapter16\html\chapter_sh_08.png

?????文件??????10681??2013-08-18?11:01??chapter16\html\chapter_sh_09.png

?????目錄??????????0??2013-08-18?11:01??chapter16\html

?????目錄??????????0??2013-08-18?10:59??chapter16

-----------?---------??----------?-----??----

???????????????385277????????????????????15


評論

共有 條評論