A list,
Support Vector Machine (SVM) was first proposed by Cortes and Vapnik in 1995. It shows many unique advantages in solving small sample size, nonlinear and high-dimensional pattern recognition, and can be generalized to other Machine learning problems such as function fitting.
1. Mathematics
1.1 Two-dimensional Space
2 algorithm Part
Ii. Source code
clear;
clc;
%load financial data of the stock price of Apple company
%The data is from Nov 18 1982-Nov 18 2012
%The data contains six collums:Open, High, Low, Close, Volume, Adj Close
sh = dlmread('yahoo.csv');
%The data needs to flip because the data is from latest to earliest.
sh = flipdim(sh,1);
%extract data
[m,n] = size(sh);
ts = sh(2:m,1);
tsx = sh(1:m- 1, :); original = ts(length(sh)*0.7+1:end,:);
% Draw the original graphic of the stock price
figure;
plot(ts,'LineWidth'.1);
title(Yahoo Stock Price(1996.4.12-2012.11.16) Before Mapping '.'FontSize'.12);
grid on;
fprintf('Plot the stock price before mapping.\n');
fprintf('Program paused. Press enter to continue.\n');
pause;
%data preprocessing
ts = ts';
tsx = tsx';
% mapminmax is an mapping function in matlab
%Use mapminmax to do mapping
[TS,TSps] = mapminmax(ts);
% The scale of the data from 1 to 2
TSps.ymin = 1;
TSps.ymax = 2;
%normalization
[TS,TSps] = mapminmax(ts,TSps);
% plot the graphic of the stock price after mapping
figure;
plot(TS,'LineWidth'.1);
title('Yahoo Stock price after mapping'.'FontSize'.12);
grid on;
fprintf('\nPlot the stock price after mapping.\n');
fprintf('Program paused. Press enter to continue.\n');
pause;
% Transpose the data in order to meet the requirement of libsvm
fprintf('\n Initializing....... \n');
TS = TS';
[TSX,TSXps] = mapminmax(tsx);
TSXps.ymin = 1;
TSXps.ymax = 2;
[TSX,TSXps] = mapminmax(tsx,TSXps);
TSX = TSX';
Copy the code
3. Operation results
Fourth, note
Version: 2014 a