forked from viggin/yan-prtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
classf_gauss_tr.m
37 lines (32 loc) · 1.39 KB
/
classf_gauss_tr.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [model] = classf_gauss_tr(X,Y,param)
%Wrapper of the classify function in matlab.
%
% Methods like naive Bayes, fitting normal density function, Mahalanobis
% distance, etc.
% X : each row is a sample.
% Y : a column vector, class labels for X starting from 1.
% PARAM: struct of parameters. The beginning part of this code (before
% defParam) explains each parameter, and also sets the default parameters.
% You can change parameter p to x by setting PARAM.p = x. For parameters
% that are not set, default values will be used.
% Return:
% MODEL: a struct containing coefficients.
%
% Ke YAN, 2016, Tsinghua Univ. http://yanke23.com, [email protected]
% algorithm to use, see the doc of classify or the bottom of the code
% type = 'quadratic';
type = 'diagquadratic';
% type = 'linear';
% type = 'mahalanobis';
defParam
model.X = X;
model.Y = Y;
model.type = type;
end
% type:
% linear ¡ª Fits a multivariate normal density to each group, with a pooled estimate of covariance.
% This is the default.
% diaglinear ¡ª Similar to linear, but with a diagonal covariance matrix estimate (naive Bayes classifiers).
% quadratic ¡ª Fits multivariate normal densities with covariance estimates stratified by group.
% diagquadratic ¡ª Similar to quadratic, but with a diagonal covariance matrix estimate (naive Bayes classifiers).
% mahalanobis ¡ª Uses Mahalanobis distances with stratified covariance estimates.