资源简介

非常有戏的机器学习课程设计《基于朴素贝叶斯方法的fMRI数据分析》。压缩包内附有课程设计原文,word版本。同时,附有实验用全部程序,由数十个matlab函数组成。所以,也是学习matlab和朴素贝叶斯的好资料!数据集相信可以从网站下载,也可以向本人索要。

资源截图

代码片段和文件信息

% applyClassifier(examplesclassifier)
%
% Apply a learnt classifier (from trainClassifier) to the new examples and
% get the scores for classification.
%
% This function outputs a matrix of scores of the labelling over all the
% classes present in the test set. The columns of that matrix
% correspond to the labels sorted in increasing order of their
% numeric values
% (e.g. columns 1-6 would be labels 2-7 in the sixcategories study
% which has 6 classes)
%
% The specific scoring measure will depend on the classifier used
% see classifier code for details
%
% Input:
%  - examples a matrix of real numbers with dimenstion of #examples*#features
%  - classifier (learnt by trainClassifier)
%
% Output:
%  - score a matrix of real number with dimension of #examples*#classes
%    Each row contains [score(1st class|data) ... score(kth class|data)]
%
% Dependencies:
%  - serious dependence on the “classifier“ format produced by trainClassifier.
%
% Example:
%  - [predictions] = applyClassifier(examplesclassifier);
%
% History:
%  - Oct072005 Wei - redocument
%  - 10 Mar 05 - fpereira - adapted from previous code



function [scores] = applyClassifier( varargin )

%
% Process parameters


l = length(varargin);
if l < 2; help applyClassifier; return; end;
  
examples          = varargin{1};
trainedClassifier = varargin{2};

classifierType   = trainedClassifier.classifier;
classifierParams = trainedClassifier.classifierParameters;
models           = trainedClassifier.models;

lastpos           = size(models1);%返回5
trainingSetInfo   = trainedClassifier.trainingSetInfo;
sortedLabelValues = trainingSetInfo.sortedLabelValues;%  12
nClasses          = length(sortedLabelValues);
nFeatures         = size(examples2);
nExamples         = size(examples1);
  
% This matrix will keep the prediction scores and feature relevance values
% corresponding to each example
% - scores is a #examples*#classes matrix
%   (each line is scores for one example in label value order)
% - cFeatureContribution is a cell array where each cell contains
%   a featureContribution map for a class
%   A featureContribution map is a #examples*#features matrix
  
scores            = zeros(nExamplesnClasses);
cFeatureContribution = cell(nClasses1);
cFeatureLogProbs  = cell(nClasses1);
    
%
%下面是针对不同类型的方法,执行的函数体,贝叶斯的只是很小一部分
% run the classifier - eventually we will encapsulate this and
% the code for different kinds of classifier for now a large switch statement

trainingSetInfo = models{nClasses+2};%和上面的赋值内容一样

priors          = trainingSetInfo.classPriors;%先验概率
  
switch classifierType

  %
  % Logistic regression
  %
  
  
 case {‘logisticRegression2‘}

  % discriminative model weights;
  W = models{nClasses+1};
  
  tmp = models{nClasses+3}{1}; % parameters used to train此时是空的
  transform = tmp{3}; lambda = tmp{2}; eta = tmp{1};

  switch transform
    
   case {‘none‘}
    % vanilla logistic regression
    tmp    = exp([ones(nExamples1)examples] * W);
    scores = tmp ./ r

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     460338  2012-07-18 22:11  《机器学习》课程设计论文.doc

     文件      19258  2010-03-05 22:21  程序\applyClassifier.m

     文件      16513  2010-03-03 22:45  程序\classifierBayes.m

     文件        874  2005-10-13 20:17  程序\computeCorrelation.m

     文件       2777  2010-03-04 17:01  程序\idmToExamples_condLabel.m

     文件       1059  2005-10-13 20:17  程序\mergeExamples.m

     文件       3537  2005-10-13 20:17  程序\mri_mergeIDM.m

     文件       9123  2010-03-05 11:17  程序\summarizePredictions.m

     文件       2244  2010-03-10 03:44  程序\TestROI.m

     文件       9718  2010-03-04 00:01  程序\trainClassifier.m

     文件       2129  2005-10-13 20:17  程序\transformIDM_avgROIVoxels.m

     文件       3115  2005-10-13 20:17  程序\transformIDM_avgVoxels.m

     文件       5810  2005-10-13 20:17  程序\transformIDM_selectActiveVoxact.m

     文件       1195  2005-10-13 20:17  程序\transformIDM_selectROIVoxels.m

     文件        840  2005-10-13 20:17  程序\transformIDM_selectTimewindow.m

     文件        968  2005-10-13 20:17  程序\transformIDM_selectTrials.m

     文件       8765  2005-10-13 20:17  程序\transformIDM_smoothingKR.m

     目录          0  2012-07-18 22:12  程序

----------- ---------  ---------- -----  ----

               548263                    18


评论

共有 条评论