Summary of discriminant or predictive methods (discriminant analysis, neural networks, SVM for support vector machines, etc.)

Source: Internet
Author: User
Tags svm

Percent "input": s_train (Input sample data, number of rows is sample count, column dimension); S_group (training sample category); S_sample (data to be distinguished)
Percent "Output": Cla (Forecast category)

function Cla = Fun_panbie (S_train,s_group,s_sample,index)
Switch index
Case 1%classify
%[s_train,~]=mapminmax (s_train);% Standardized handling
%[s_sample,~]=mapminmax (s_sample);% Standardized handling
[Cla,err,posterior,~,~]=classify (S_sample,s_train,s_group, ' linear ', ' empirical ');%ss={' linear ', ' diaglinear ', ' Quadratic ', ' diagquadratic ', ' mahalanobis '};% discriminant function
Case 2%SVM
Net=svmtrain (S_train,s_group, ' kernel_function ', ' linear ');% kernel function ss={' linear ', ' quadratic ', ' polynomial ', ' RBF ', ' MLP ' }
Cla=svmclassify (net,s_sample);
Case 3%knnclassify
% slightly
Case 4%RBF
NET=NEWRB (S_train ', S_group ', 0.1,0.1);
Cla=int16 (NET (s_sample)) ';
Case 5%LVQ
T=ind2vec (S_group ' + 1);
NET=NEWLVQ (Minmax (S_train '), 5);
net.trainparam.showwindow=0;
Net=train (Net,s_train ', T);
Y=sim (Net,s_sample ');
Cla=vec2ind (y) '-1;
Case 6%elman
[Pn,minp,maxp,tn,mint,maxt]=premnmx (S_train ', s_group ');% data Normalization
p2= tramnmx (s_sample ', MINP,MAXP);
Net=newelm (Minmax (PN), [3,size (s_group,2)],{' Tansig ', ' Tansig '});% establishes a network model where parameters can be modified as required
net.trainparam.show=100;% shown 1 times per iteration 100 times
net.trainparam.epochs=1000;% Maximum number of iterations 2000
net.trainparam.goal=0.001;% Iteration Target
Net=init (NET);% Initialize Network
net.trainparam.showwindow=0;% Neural Network The window of the training process does not bounce out
[Net,tr]=train (NET,PN,TN);% Training Network
Cla=sim (net,s_sample ') ';% emulation
Cla=postmnmx (cla,mint,maxt); inverse normalization of simulation values
Case 7% Single-layer Perceptron
Yy=minmax (S_train ');
NET=NEWP (yy,1);
net.trainparam.epochs=20;
net.trainparam.showwindow=0;
Net=train (Net,s_train ', S_group ');
Cla=sim (net,s_sample) ';
Case 8% Linear Neural network
T=repmat (S_group,1,size (S_train ', 2));
Net=newlin (Minmax (S_train '), size (t,1), 10,0.05);
net.trainparam.epochs=500;
net.trainparam.goal=0.0001;
net.trainparam.showwindow=0;
Net=train (Net,s_train ', T);
Y=sim (Net,s_sample ');
Cla=y (:, 1);
Case 9% single layer competitive neural network
Mm=s_train (:);
Mm=minmax (mm ');
Q=repmat (Mm,size (s_train,2), 1);
NET=NEWC (q,2,0.1);
Net=init (NET);
net.trainparam.showwindow=0;
net.trainparam.epochs=20;
Net=train (Net,s_train ');
A=sim (Net,s_train ');
Cla=vec2ind (s_sample ') ';
Case 10%BP Neural Network
Mm=s_train (:);
Mm=minmax (mm ');
NET=NEWFF (Repmat (Mm,size (S_train ', 1), 1), [5,3,3,1],{' Tansig ', ' tansig ', ' tansig ', ' Purelin '}, ' Traingd ');
net.trainparam.epochs=300;
net.trainparam.lr=0.05;
net.trainparam.show=50;
net.trainparam.goal=1e-5;
net.trainparam.showwindow=0;
[Net,tr]=train (Net,s_train ', S_group ');
Cla=sim (net,s_sample ') ';
otherwise

End

End

Summary of discriminant or predictive methods (discriminant analysis, neural networks, SVM for support vector machines, etc.)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.