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

📄 perceptron_vc.m

📁 最新的模式识别分类工具箱,希望对朋友们有用!
💻 M
字号:
% Learns classifier and classifies test set%  using the perceptron learning algorithm%%  If there are 2 classes, there is no problem (except that the labels are%     converted to 0 and 1).%  If there are more than 2 classes, pairwise classification is made,%  followed by majority vote.%  % Inputs:% Usage%      [trainError, testError] = ...%           Perceptron_VC(trainFeatures, trainLabels,algParam ,testFeatures, testLabels)% where%% Inputs:% 	trainFeatures  - the training set vectors, one vector per column%	trainLabels    - the labels of the above%       algParam       - algorithm parameters%	                  Number of iterations, or weights vector, or [weights, number of iterations]%       testFeatures   - test set, one column per vector%       testLabels     - labels  for test set%% Outputs%	trainError     - the error rate on the training set (one entry per%	                   class + total error)%	testError      - the error rate on the test set (one entry per class%	                  + total error)%       estTrainLabels - the labels produced by the algorithm for the%                          training samples%       estTestLabels - the labels produced by the algorithm for the%                          test samplesfunction   [trainError, testError] = ...    Perceptron_VC(trainFeatures, trainLabels,algoParams,testFeatures, testLabels)[Nclasses, classes]  = find_classes([trainLabels(:);testLabels(:)]); % Number of classes in labelsif (Nclasses > 2)  [trainError, testError] = classifierWrapper(trainFeatures, trainLabels, ...      'Perceptron_VCcore', algoParams, testFeatures, testLabels);else  if (max(classes) > 1 | min(classes) <0)    ind0tr = find(trainLabels == min(classes));    ind0te = find(testLabels  == min(classes));    ind1tr = find(trainLabels == max(classes));    ind1te = find(testLabels  == max(classes));    trainLabels(ind0tr) = 0;    trainLabels(ind1tr) = 1;    testLabels(ind0te)  = 0;    testLabels(ind1te)  = 1;  end  [trainError, testError] = Perceptron_VCcore(trainFeatures, trainLabels, algoParams, testFeatures, testLabels);endtrainError = reshape(trainError,length(trainError),1);testError  = reshape(testError,length(testError),1);

⌨️ 快捷键说明

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