资源简介
支持向量机(SVM)matlab代码,用于二分类问题的模板。
代码片段和文件信息
%function [predY]=speakingDetection(X)
s=load(‘training.data‘);
[xy]=size(s);
vec = zeros(61);
xapp = [];
yapp = [];
i=1;j=1;
%数据初步处理
while (i<=x)
vec(1) = s(i1);
vec(2) = s(i2);
vec(3) = s(i3);
vec(4) = s(i4);
vec(5) = s(i5);
vec(6) = s(i6);
xapp = [xappvec];
yapp = [yapps(i7)];
i=i+1;
end;
[NM] = size(xapp);
p = randperm(M); %直接打乱了训练样本
numberOfSamplesForTraining = 60000; %6000个数据训练
xTraining = [];
yTraining = [];
for i=1:numberOfSamplesForTraining
xTraining = [xTrainingxapp(:p(i))];
yTraining = [yTrainingyapp(p(i))];
end;
xTraining = xTraining‘; %转置
yTraining = yTraining‘;
xTesting = [];
yTesting = [];
for i=numberOfSamplesForTraining+1:M
xTesting = [xTestingxapp(:p(i))];
yTesting = [yTestingyapp(p(i))];
end;
xTesting = xTesting‘;
yTesting = yTesting‘;
%%%%%%%%%%%%%%%%%%%%%%%%
% %Normalization
% [numVecnumDim] = size(xTraining);
% avgX = mean(xTraining);
% stdX = std(xTraining);
% for i = 1:numVec
% xTraining(i:) = (xTraining(i:)-avgX)./stdX;
% end;
% [numVecnumDim] = size(xTesting);
%
% for i = 1:numVec
% xTesting(i:) = (xTesting(i:)-avgX)./stdX;
% end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SVM Gaussian kernel
%Search for the optimal C and gamma K(x1x2) = exp{-||x1-x2||^2/gamma} to
%make the recognition rate maximum.
%Firstly search C and gamma in a crude scale (as recommended in ‘A practical Guide to Support Vector Classification‘))
CScale = [-5-3 -1 1 3 579111315];
gammaScale = [-15-13-11-9-7-5-3-113];
C = 2.^CScale;
gamma = 2.^gammaScale;
maxRecognitionRate = 0;
for i = 1:length(C)
for j = 1:length(gamma)
cmd=[‘-t 2 -c ‘num2str(C(i))‘ -g ‘num2str(gamma(j))‘ -v 10‘]; %转化为字符高斯核五折交叉检验
recognitionRate = svmtrain(yTrainingxTrainingcmd);
if recognitionRate>maxRecognitionRate
maxRecogn
- 上一篇:DPSK的MATLAB实现53470
- 下一篇:求动态条件相关系数
相关资源
- DPSK的MATLAB实现53470
- 投影寻踪优化模型Matlab源代码
- LEACH改进算法MATLAB实现
- K-means聚类算法初始聚类中心确定 ma
- 多种核函数的SVM分类器matlab程序
- 极限学习机ELM 算法及MATLAB程序实现
- 基于UIC513标准的乘坐舒适度算法MATL
- 人工智能蜂群算法ABCMATLAB版本带注释
- 基于MATLAB的GUI设计,密码输入
- matlab gui UDP通信
- 惯性导航扩展卡尔曼滤波MATLAB
- 模糊PID的MATLAB程序
- matlab代码DFT与DCT变换
- 基于密度的聚类
- 水下初至波程序
- 基于matlab的免疫遗传算法
- LCMV算法下的波束形成实现
- 最优潮流计算MATLAB仿真模型
-
发动机simuli
nk仿真 - 卡尔曼滤波matlab
-
Simuli
nk二自由度整车模型 - [精品]matlab仿真A*路径规划算法,100
- 人工神经网络实验 用CHNN算法求解T
- AGC的MATLAB仿真代码
- matlab绘制三维立方体
- matlab灰色预测程序代码
- matlab 欧式距离
- 机器人手眼标定Matlab程序高精度
- MATLAB求解图像信息熵可用于图像融合
-
SPWM_simuli
nk.zip
评论
共有 条评论