⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svm_scale_firsttime_newlibsvm.m

📁 libsvm-demo,支持向量机的演示程序,对初学者很有用!
💻 M
字号:
function [scaled , scale_parameter] = svm_scale_firsttime_newlibsvm(Data, Lower, Upper)

% Usages:
%  [scaled , MinV , MaxV] = svm_scale_firsttime_newlibsvm(Data, Lower, Upper) 
%  scales each dimension (col) of the "Data" to ["Lower" "Upper"] (default 
%  are [-1 1]. The outputs are the scaled data "scaled", the scale_parameter
%  are to be used for scaling of the future data.
%
% Examples:
%  For the osu_svm data with rows of feature vectors,
%  [scaled , scale_parameter] = svm_scale_firsttime_newlibsvm(Data);
%
% By Tian Tsong Ng, July 2005

if (nargin<3) 
   Lower = -1;
   Upper = 1;
elseif (Lower > Upper)
   disp (['Wrong Lower or Upper values!']);
end

[MaxV, I]=max(Data);
[MinV, I]=min(Data);

[R,C]= size(Data);

gap = MaxV-MinV;
I = find(gap==0);
gap(I) = 1;
scaled=(Data-ones(R,1)*MinV).*(ones(R,1)*((Upper-Lower)*ones(1,C)./gap))+Lower;
    
scale_parameter = struct('Lower',Lower,'Upper',Upper,'MinV',MinV,'MaxV',MaxV);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -