-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcosmo_cross_validation_measure.m
26 lines (24 loc) · 1.1 KB
/
cosmo_cross_validation_measure.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
function accuracy = cosmo_cross_validation_measure(dataset, args)
% performs cross-validation using a classifier
%
% accuracy = cosmo_cross_validate(dataset, args)
%
% Inputs
% dataset struct with fields .samples (PxQ for P samples and
% Q features) and .sa.targets (Px1 labels of samples)
% args struct containing classifier, partitions, and opt (which
% is optional)
% args.classifier function handle to classifier, e.g.
% @classify_naive_baysian
% args.partitions For example the output from nfold_partition
%
% ACC. Modified to conform to signature of generic datset 'measure'
% NNO made this a wrapper function
if ~isfield(args,'opt') args.opt = struct(); end
if ~isfield(args,'classifier') error('Missing input args.classifier'); end
if ~isfield(args,'partitions') error('Missing input args.partitions'); end
% Run cross validation to get the accuracy (see the help of
% cosmo_cross_validate)
% >>
[pred, accuracy]=cosmo_cross_validate(dataset, args.classifier, args.partitions, args.opt);
% <<