-
Notifications
You must be signed in to change notification settings - Fork 0
/
trainClassifier.m
95 lines (85 loc) · 40 KB
/
trainClassifier.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function [trainedClassifier, validationAccuracy] = trainClassifier(trainingData)
% trainClassifier(trainingData)
% returns a trained classifier and its accuracy.
% This code recreates the classification model trained in
% Classification Learner app.
%
% Input:
% trainingData: the training data of same data type as imported
% in the app (table or matrix).
%
% Output:
% trainedClassifier: a struct containing the trained classifier.
% The struct contains various fields with information about the
% trained classifier.
%
% trainedClassifier.predictFcn: a function to make predictions
% on new data. It takes an input of the same form as this training
% code (table or matrix) and returns predictions for the response.
% If you supply a matrix, include only the predictors columns (or
% rows).
%
% validationAccuracy: a double containing the accuracy in
% percent. In the app, the History list displays this
% overall accuracy score for each model.
%
% Use the code to train the model with new data.
% To retrain your classifier, call the function from the command line
% with your original data or new data as the input argument trainingData.
%
% For example, to retrain a classifier trained with the original data set
% T, enter:
% [trainedClassifier, validationAccuracy] = trainClassifier(T)
%
% To make predictions with the returned 'trainedClassifier' on new data T,
% use
% yfit = trainedClassifier.predictFcn(T)
%
% To automate training the same classifier with new data, or to learn how
% to programmatically train classifiers, examine the generated code.
% Auto-generated by MATLAB on 24-Feb-2017 12:42:06
% Extract predictors and response
% This code processes the data into the right shape for training the
% classifier.
inputTable = trainingData;
predictorNames = {'infectiondata1', 'infectiondata2', 'infectiondata3', 'infectiondata4', 'infectiondata5', 'infectiondata6', 'infectiondata7', 'infectiondata8', 'infectiondata9', 'infectiondata10', 'infectiondata11', 'infectiondata12', 'infectiondata13', 'infectiondata14', 'infectiondata15', 'infectiondata16', 'infectiondata17', 'infectiondata18', 'infectiondata19', 'infectiondata20', 'infectiondata21', 'infectiondata22', 'infectiondata23', 'infectiondata24', 'infectiondata25', 'infectiondata26', 'infectiondata27', 'infectiondata28', 'infectiondata29', 'infectiondata30', 'infectiondata31', 'infectiondata32', 'infectiondata33', 'infectiondata34', 'infectiondata35', 'infectiondata36', 'infectiondata37', 'infectiondata38', 'infectiondata39', 'infectiondata40', 'infectiondata41', 'infectiondata42', 'infectiondata43', 'infectiondata44', 'infectiondata45', 'infectiondata46', 'infectiondata47', 'infectiondata48', 'infectiondata49', 'infectiondata50', 'infectiondata51', 'infectiondata52', 'infectiondata53', 'infectiondata54', 'infectiondata55', 'infectiondata56', 'infectiondata57', 'infectiondata58', 'infectiondata59', 'infectiondata60', 'infectiondata61', 'infectiondata62', 'infectiondata63', 'infectiondata64', 'infectiondata65', 'infectiondata66', 'infectiondata67', 'infectiondata68', 'infectiondata69', 'infectiondata70', 'infectiondata71', 'infectiondata72', 'infectiondata73', 'infectiondata74', 'infectiondata75', 'infectiondata76', 'infectiondata77', 'infectiondata78', 'infectiondata79', 'infectiondata80', 'infectiondata81', 'infectiondata82', 'infectiondata83', 'infectiondata84', 'infectiondata85', 'infectiondata86', 'infectiondata87', 'infectiondata88', 'infectiondata89', 'infectiondata90', 'infectiondata91', 'infectiondata92', 'infectiondata93', 'infectiondata94', 'infectiondata95', 'infectiondata96', 'infectiondata97', 'infectiondata98', 'infectiondata99', 'infectiondata100', 'infectiondata101', 'infectiondata102', 'infectiondata103', 'infectiondata104', 'infectiondata105', 'infectiondata106', 'infectiondata107', 'infectiondata108', 'infectiondata109', 'infectiondata110', 'infectiondata111', 'infectiondata112', 'infectiondata113', 'infectiondata114', 'infectiondata115', 'infectiondata116', 'infectiondata117', 'infectiondata118', 'infectiondata119', 'infectiondata120', 'infectiondata121', 'infectiondata122', 'infectiondata123', 'infectiondata124', 'infectiondata125', 'infectiondata126', 'infectiondata127', 'infectiondata128', 'infectiondata129', 'infectiondata130', 'infectiondata131', 'infectiondata132', 'infectiondata133', 'infectiondata134', 'infectiondata135', 'infectiondata136', 'infectiondata137', 'infectiondata138', 'infectiondata139', 'infectiondata140', 'infectiondata141', 'infectiondata142', 'infectiondata143', 'infectiondata144', 'infectiondata145', 'infectiondata146', 'infectiondata147', 'infectiondata148', 'infectiondata149', 'infectiondata150', 'infectiondata151', 'infectiondata152', 'infectiondata153', 'infectiondata154', 'infectiondata155', 'infectiondata156', 'infectiondata157', 'infectiondata158', 'infectiondata159', 'infectiondata160', 'infectiondata161', 'infectiondata162', 'infectiondata163', 'infectiondata164', 'infectiondata165', 'infectiondata166', 'infectiondata167', 'infectiondata168', 'infectiondata169', 'infectiondata170', 'infectiondata171', 'infectiondata172', 'infectiondata173', 'infectiondata174', 'infectiondata175', 'infectiondata176', 'infectiondata177', 'infectiondata178', 'infectiondata179', 'infectiondata180', 'infectiondata181', 'infectiondata182', 'infectiondata183', 'infectiondata184', 'infectiondata185', 'infectiondata186', 'infectiondata187', 'infectiondata188', 'infectiondata189', 'infectiondata190', 'infectiondata191', 'infectiondata192', 'infectiondata193', 'infectiondata194', 'infectiondata195', 'infectiondata196', 'infectiondata197', 'infectiondata198', 'infectiondata199', 'infectiondata200', 'infectiondata201', 'infectiondata202', 'infectiondata203', 'infectiondata204', 'infectiondata205', 'infectiondata206', 'infectiondata207', 'infectiondata208', 'infectiondata209', 'infectiondata210', 'infectiondata211', 'infectiondata212', 'infectiondata213', 'infectiondata214', 'infectiondata215', 'infectiondata216', 'infectiondata217', 'infectiondata218', 'infectiondata219', 'infectiondata220', 'infectiondata221', 'infectiondata222', 'infectiondata223', 'infectiondata224', 'infectiondata225', 'infectiondata226', 'infectiondata227', 'infectiondata228', 'infectiondata229', 'infectiondata230', 'infectiondata231', 'infectiondata232', 'infectiondata233', 'infectiondata234', 'infectiondata235', 'infectiondata236', 'infectiondata237', 'infectiondata238', 'infectiondata239', 'infectiondata240', 'infectiondata241', 'infectiondata242', 'infectiondata243', 'infectiondata244', 'infectiondata245', 'infectiondata246', 'infectiondata247', 'infectiondata248', 'infectiondata249', 'infectiondata250', 'infectiondata251', 'infectiondata252', 'infectiondata253', 'infectiondata254', 'infectiondata255', 'infectiondata256', 'infectiondata257', 'infectiondata258', 'infectiondata259', 'infectiondata260', 'infectiondata261', 'infectiondata262', 'infectiondata263', 'infectiondata264', 'infectiondata265', 'infectiondata266', 'infectiondata267', 'infectiondata268', 'infectiondata269', 'infectiondata270', 'infectiondata271', 'infectiondata272', 'infectiondata273', 'infectiondata274', 'infectiondata275', 'infectiondata276', 'infectiondata277', 'infectiondata278', 'infectiondata279', 'infectiondata280', 'infectiondata281', 'infectiondata282', 'infectiondata283', 'infectiondata284', 'infectiondata285', 'infectiondata286', 'infectiondata287', 'infectiondata288', 'infectiondata289', 'infectiondata290', 'infectiondata291', 'infectiondata292', 'infectiondata293', 'infectiondata294', 'infectiondata295', 'infectiondata296', 'infectiondata297', 'infectiondata298', 'infectiondata299', 'infectiondata300', 'infectiondata301', 'infectiondata302', 'infectiondata303', 'infectiondata304', 'infectiondata305', 'infectiondata306', 'infectiondata307', 'infectiondata308', 'infectiondata309', 'infectiondata310', 'infectiondata311', 'infectiondata312', 'infectiondata313', 'infectiondata314', 'infectiondata315', 'infectiondata316', 'infectiondata317', 'infectiondata318', 'infectiondata319', 'infectiondata320', 'infectiondata321', 'infectiondata322', 'infectiondata323', 'infectiondata324', 'infectiondata325', 'infectiondata326', 'infectiondata327', 'infectiondata328', 'infectiondata329', 'infectiondata330', 'infectiondata331', 'infectiondata332', 'infectiondata333', 'infectiondata334', 'infectiondata335', 'infectiondata336', 'infectiondata337', 'infectiondata338', 'infectiondata339', 'infectiondata340', 'infectiondata341', 'infectiondata342', 'infectiondata343', 'infectiondata344', 'infectiondata345', 'infectiondata346', 'infectiondata347', 'infectiondata348', 'infectiondata349', 'infectiondata350', 'infectiondata351', 'infectiondata352', 'infectiondata353', 'infectiondata354', 'infectiondata355', 'infectiondata356', 'infectiondata357', 'infectiondata358', 'infectiondata359', 'infectiondata360', 'infectiondata361', 'infectiondata362', 'infectiondata363', 'infectiondata364', 'infectiondata365', 'infectiondata366', 'infectiondata367', 'infectiondata368', 'infectiondata369', 'infectiondata370', 'infectiondata371', 'infectiondata372', 'infectiondata373', 'infectiondata374', 'infectiondata375', 'infectiondata376', 'infectiondata377', 'infectiondata378', 'infectiondata379', 'infectiondata380', 'infectiondata381', 'infectiondata382', 'infectiondata383', 'infectiondata384', 'infectiondata385', 'infectiondata386', 'infectiondata387', 'infectiondata388', 'infectiondata389', 'infectiondata390', 'infectiondata391', 'infectiondata392', 'infectiondata393', 'infectiondata394', 'infectiondata395', 'infectiondata396', 'infectiondata397', 'infectiondata398', 'infectiondata399', 'infectiondata400', 'infectiondata401', 'infectiondata402', 'infectiondata403', 'infectiondata404', 'infectiondata405', 'infectiondata406', 'infectiondata407', 'infectiondata408', 'infectiondata409', 'infectiondata410', 'infectiondata411', 'infectiondata412', 'infectiondata413', 'infectiondata414', 'infectiondata415', 'infectiondata416', 'infectiondata417', 'infectiondata418', 'infectiondata419', 'infectiondata420', 'infectiondata421', 'infectiondata422', 'infectiondata423', 'infectiondata424', 'infectiondata425', 'infectiondata426', 'infectiondata427', 'infectiondata428', 'infectiondata429', 'infectiondata430', 'infectiondata431', 'infectiondata432', 'infectiondata433', 'infectiondata434', 'infectiondata435', 'infectiondata436', 'infectiondata437', 'infectiondata438', 'infectiondata439', 'infectiondata440', 'infectiondata441', 'infectiondata442', 'infectiondata443', 'infectiondata444', 'infectiondata445', 'infectiondata446', 'infectiondata447', 'infectiondata448', 'infectiondata449', 'infectiondata450', 'infectiondata451', 'infectiondata452', 'infectiondata453', 'infectiondata454', 'infectiondata455', 'infectiondata456', 'infectiondata457', 'infectiondata458', 'infectiondata459', 'infectiondata460', 'infectiondata461', 'infectiondata462', 'infectiondata463', 'infectiondata464', 'infectiondata465', 'infectiondata466', 'infectiondata467', 'infectiondata468', 'infectiondata469', 'infectiondata470', 'infectiondata471', 'infectiondata472', 'infectiondata473', 'infectiondata474', 'infectiondata475', 'infectiondata476', 'infectiondata477', 'infectiondata478', 'infectiondata479', 'infectiondata480', 'infectiondata481', 'infectiondata482', 'infectiondata483', 'infectiondata484', 'infectiondata485', 'infectiondata486', 'infectiondata487', 'infectiondata488', 'infectiondata489', 'infectiondata490', 'infectiondata491', 'infectiondata492', 'infectiondata493', 'infectiondata494', 'infectiondata495', 'infectiondata496', 'infectiondata497', 'infectiondata498', 'infectiondata499', 'infectiondata500'};
predictors = inputTable(:, predictorNames);
response = inputTable.infectionType;
isCategoricalPredictor = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
% Train a classifier
% This code specifies all the classifier options and trains the classifier.
template = templateSVM(...
'KernelFunction', 'polynomial', ...
'PolynomialOrder', 2, ...
'KernelScale', 'auto', ...
'BoxConstraint', 1, ...
'Standardize', true);
classificationSVM = fitcecoc(...
predictors, ...
response, ...
'Learners', template, ...
'Coding', 'onevsone', ...
'ClassNames', categorical({'babesiosis'; 'leishmaniasis'; 'plasmodium'; 'trypanosomiasis'}));
% Create the result struct with predict function
predictorExtractionFcn = @(t) t(:, predictorNames);
svmPredictFcn = @(x) predict(classificationSVM, x);
trainedClassifier.predictFcn = @(x) svmPredictFcn(predictorExtractionFcn(x));
% Add additional fields to the result struct
trainedClassifier.RequiredVariables = {'infectiondata1', 'infectiondata2', 'infectiondata3', 'infectiondata4', 'infectiondata5', 'infectiondata6', 'infectiondata7', 'infectiondata8', 'infectiondata9', 'infectiondata10', 'infectiondata11', 'infectiondata12', 'infectiondata13', 'infectiondata14', 'infectiondata15', 'infectiondata16', 'infectiondata17', 'infectiondata18', 'infectiondata19', 'infectiondata20', 'infectiondata21', 'infectiondata22', 'infectiondata23', 'infectiondata24', 'infectiondata25', 'infectiondata26', 'infectiondata27', 'infectiondata28', 'infectiondata29', 'infectiondata30', 'infectiondata31', 'infectiondata32', 'infectiondata33', 'infectiondata34', 'infectiondata35', 'infectiondata36', 'infectiondata37', 'infectiondata38', 'infectiondata39', 'infectiondata40', 'infectiondata41', 'infectiondata42', 'infectiondata43', 'infectiondata44', 'infectiondata45', 'infectiondata46', 'infectiondata47', 'infectiondata48', 'infectiondata49', 'infectiondata50', 'infectiondata51', 'infectiondata52', 'infectiondata53', 'infectiondata54', 'infectiondata55', 'infectiondata56', 'infectiondata57', 'infectiondata58', 'infectiondata59', 'infectiondata60', 'infectiondata61', 'infectiondata62', 'infectiondata63', 'infectiondata64', 'infectiondata65', 'infectiondata66', 'infectiondata67', 'infectiondata68', 'infectiondata69', 'infectiondata70', 'infectiondata71', 'infectiondata72', 'infectiondata73', 'infectiondata74', 'infectiondata75', 'infectiondata76', 'infectiondata77', 'infectiondata78', 'infectiondata79', 'infectiondata80', 'infectiondata81', 'infectiondata82', 'infectiondata83', 'infectiondata84', 'infectiondata85', 'infectiondata86', 'infectiondata87', 'infectiondata88', 'infectiondata89', 'infectiondata90', 'infectiondata91', 'infectiondata92', 'infectiondata93', 'infectiondata94', 'infectiondata95', 'infectiondata96', 'infectiondata97', 'infectiondata98', 'infectiondata99', 'infectiondata100', 'infectiondata101', 'infectiondata102', 'infectiondata103', 'infectiondata104', 'infectiondata105', 'infectiondata106', 'infectiondata107', 'infectiondata108', 'infectiondata109', 'infectiondata110', 'infectiondata111', 'infectiondata112', 'infectiondata113', 'infectiondata114', 'infectiondata115', 'infectiondata116', 'infectiondata117', 'infectiondata118', 'infectiondata119', 'infectiondata120', 'infectiondata121', 'infectiondata122', 'infectiondata123', 'infectiondata124', 'infectiondata125', 'infectiondata126', 'infectiondata127', 'infectiondata128', 'infectiondata129', 'infectiondata130', 'infectiondata131', 'infectiondata132', 'infectiondata133', 'infectiondata134', 'infectiondata135', 'infectiondata136', 'infectiondata137', 'infectiondata138', 'infectiondata139', 'infectiondata140', 'infectiondata141', 'infectiondata142', 'infectiondata143', 'infectiondata144', 'infectiondata145', 'infectiondata146', 'infectiondata147', 'infectiondata148', 'infectiondata149', 'infectiondata150', 'infectiondata151', 'infectiondata152', 'infectiondata153', 'infectiondata154', 'infectiondata155', 'infectiondata156', 'infectiondata157', 'infectiondata158', 'infectiondata159', 'infectiondata160', 'infectiondata161', 'infectiondata162', 'infectiondata163', 'infectiondata164', 'infectiondata165', 'infectiondata166', 'infectiondata167', 'infectiondata168', 'infectiondata169', 'infectiondata170', 'infectiondata171', 'infectiondata172', 'infectiondata173', 'infectiondata174', 'infectiondata175', 'infectiondata176', 'infectiondata177', 'infectiondata178', 'infectiondata179', 'infectiondata180', 'infectiondata181', 'infectiondata182', 'infectiondata183', 'infectiondata184', 'infectiondata185', 'infectiondata186', 'infectiondata187', 'infectiondata188', 'infectiondata189', 'infectiondata190', 'infectiondata191', 'infectiondata192', 'infectiondata193', 'infectiondata194', 'infectiondata195', 'infectiondata196', 'infectiondata197', 'infectiondata198', 'infectiondata199', 'infectiondata200', 'infectiondata201', 'infectiondata202', 'infectiondata203', 'infectiondata204', 'infectiondata205', 'infectiondata206', 'infectiondata207', 'infectiondata208', 'infectiondata209', 'infectiondata210', 'infectiondata211', 'infectiondata212', 'infectiondata213', 'infectiondata214', 'infectiondata215', 'infectiondata216', 'infectiondata217', 'infectiondata218', 'infectiondata219', 'infectiondata220', 'infectiondata221', 'infectiondata222', 'infectiondata223', 'infectiondata224', 'infectiondata225', 'infectiondata226', 'infectiondata227', 'infectiondata228', 'infectiondata229', 'infectiondata230', 'infectiondata231', 'infectiondata232', 'infectiondata233', 'infectiondata234', 'infectiondata235', 'infectiondata236', 'infectiondata237', 'infectiondata238', 'infectiondata239', 'infectiondata240', 'infectiondata241', 'infectiondata242', 'infectiondata243', 'infectiondata244', 'infectiondata245', 'infectiondata246', 'infectiondata247', 'infectiondata248', 'infectiondata249', 'infectiondata250', 'infectiondata251', 'infectiondata252', 'infectiondata253', 'infectiondata254', 'infectiondata255', 'infectiondata256', 'infectiondata257', 'infectiondata258', 'infectiondata259', 'infectiondata260', 'infectiondata261', 'infectiondata262', 'infectiondata263', 'infectiondata264', 'infectiondata265', 'infectiondata266', 'infectiondata267', 'infectiondata268', 'infectiondata269', 'infectiondata270', 'infectiondata271', 'infectiondata272', 'infectiondata273', 'infectiondata274', 'infectiondata275', 'infectiondata276', 'infectiondata277', 'infectiondata278', 'infectiondata279', 'infectiondata280', 'infectiondata281', 'infectiondata282', 'infectiondata283', 'infectiondata284', 'infectiondata285', 'infectiondata286', 'infectiondata287', 'infectiondata288', 'infectiondata289', 'infectiondata290', 'infectiondata291', 'infectiondata292', 'infectiondata293', 'infectiondata294', 'infectiondata295', 'infectiondata296', 'infectiondata297', 'infectiondata298', 'infectiondata299', 'infectiondata300', 'infectiondata301', 'infectiondata302', 'infectiondata303', 'infectiondata304', 'infectiondata305', 'infectiondata306', 'infectiondata307', 'infectiondata308', 'infectiondata309', 'infectiondata310', 'infectiondata311', 'infectiondata312', 'infectiondata313', 'infectiondata314', 'infectiondata315', 'infectiondata316', 'infectiondata317', 'infectiondata318', 'infectiondata319', 'infectiondata320', 'infectiondata321', 'infectiondata322', 'infectiondata323', 'infectiondata324', 'infectiondata325', 'infectiondata326', 'infectiondata327', 'infectiondata328', 'infectiondata329', 'infectiondata330', 'infectiondata331', 'infectiondata332', 'infectiondata333', 'infectiondata334', 'infectiondata335', 'infectiondata336', 'infectiondata337', 'infectiondata338', 'infectiondata339', 'infectiondata340', 'infectiondata341', 'infectiondata342', 'infectiondata343', 'infectiondata344', 'infectiondata345', 'infectiondata346', 'infectiondata347', 'infectiondata348', 'infectiondata349', 'infectiondata350', 'infectiondata351', 'infectiondata352', 'infectiondata353', 'infectiondata354', 'infectiondata355', 'infectiondata356', 'infectiondata357', 'infectiondata358', 'infectiondata359', 'infectiondata360', 'infectiondata361', 'infectiondata362', 'infectiondata363', 'infectiondata364', 'infectiondata365', 'infectiondata366', 'infectiondata367', 'infectiondata368', 'infectiondata369', 'infectiondata370', 'infectiondata371', 'infectiondata372', 'infectiondata373', 'infectiondata374', 'infectiondata375', 'infectiondata376', 'infectiondata377', 'infectiondata378', 'infectiondata379', 'infectiondata380', 'infectiondata381', 'infectiondata382', 'infectiondata383', 'infectiondata384', 'infectiondata385', 'infectiondata386', 'infectiondata387', 'infectiondata388', 'infectiondata389', 'infectiondata390', 'infectiondata391', 'infectiondata392', 'infectiondata393', 'infectiondata394', 'infectiondata395', 'infectiondata396', 'infectiondata397', 'infectiondata398', 'infectiondata399', 'infectiondata400', 'infectiondata401', 'infectiondata402', 'infectiondata403', 'infectiondata404', 'infectiondata405', 'infectiondata406', 'infectiondata407', 'infectiondata408', 'infectiondata409', 'infectiondata410', 'infectiondata411', 'infectiondata412', 'infectiondata413', 'infectiondata414', 'infectiondata415', 'infectiondata416', 'infectiondata417', 'infectiondata418', 'infectiondata419', 'infectiondata420', 'infectiondata421', 'infectiondata422', 'infectiondata423', 'infectiondata424', 'infectiondata425', 'infectiondata426', 'infectiondata427', 'infectiondata428', 'infectiondata429', 'infectiondata430', 'infectiondata431', 'infectiondata432', 'infectiondata433', 'infectiondata434', 'infectiondata435', 'infectiondata436', 'infectiondata437', 'infectiondata438', 'infectiondata439', 'infectiondata440', 'infectiondata441', 'infectiondata442', 'infectiondata443', 'infectiondata444', 'infectiondata445', 'infectiondata446', 'infectiondata447', 'infectiondata448', 'infectiondata449', 'infectiondata450', 'infectiondata451', 'infectiondata452', 'infectiondata453', 'infectiondata454', 'infectiondata455', 'infectiondata456', 'infectiondata457', 'infectiondata458', 'infectiondata459', 'infectiondata460', 'infectiondata461', 'infectiondata462', 'infectiondata463', 'infectiondata464', 'infectiondata465', 'infectiondata466', 'infectiondata467', 'infectiondata468', 'infectiondata469', 'infectiondata470', 'infectiondata471', 'infectiondata472', 'infectiondata473', 'infectiondata474', 'infectiondata475', 'infectiondata476', 'infectiondata477', 'infectiondata478', 'infectiondata479', 'infectiondata480', 'infectiondata481', 'infectiondata482', 'infectiondata483', 'infectiondata484', 'infectiondata485', 'infectiondata486', 'infectiondata487', 'infectiondata488', 'infectiondata489', 'infectiondata490', 'infectiondata491', 'infectiondata492', 'infectiondata493', 'infectiondata494', 'infectiondata495', 'infectiondata496', 'infectiondata497', 'infectiondata498', 'infectiondata499', 'infectiondata500'};
trainedClassifier.ClassificationSVM = classificationSVM;
trainedClassifier.About = 'This struct is a trained classifier exported from Classification Learner R2016b.';
trainedClassifier.HowToPredict = sprintf('To make predictions on a new table, T, use: \n yfit = c.predictFcn(T) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedClassifier''. \n \nThe table, T, must contain the variables returned by: \n c.RequiredVariables \nVariable formats (e.g. matrix/vector, datatype) must match the original training data. \nAdditional variables are ignored. \n \nFor more information, see <a href="matlab:helpview(fullfile(docroot, ''stats'', ''stats.map''), ''appclassification_exportmodeltoworkspace'')">How to predict using an exported model</a>.');
% Extract predictors and response
% This code processes the data into the right shape for training the
% classifier.
inputTable = trainingData;
predictorNames = {'infectiondata1', 'infectiondata2', 'infectiondata3', 'infectiondata4', 'infectiondata5', 'infectiondata6', 'infectiondata7', 'infectiondata8', 'infectiondata9', 'infectiondata10', 'infectiondata11', 'infectiondata12', 'infectiondata13', 'infectiondata14', 'infectiondata15', 'infectiondata16', 'infectiondata17', 'infectiondata18', 'infectiondata19', 'infectiondata20', 'infectiondata21', 'infectiondata22', 'infectiondata23', 'infectiondata24', 'infectiondata25', 'infectiondata26', 'infectiondata27', 'infectiondata28', 'infectiondata29', 'infectiondata30', 'infectiondata31', 'infectiondata32', 'infectiondata33', 'infectiondata34', 'infectiondata35', 'infectiondata36', 'infectiondata37', 'infectiondata38', 'infectiondata39', 'infectiondata40', 'infectiondata41', 'infectiondata42', 'infectiondata43', 'infectiondata44', 'infectiondata45', 'infectiondata46', 'infectiondata47', 'infectiondata48', 'infectiondata49', 'infectiondata50', 'infectiondata51', 'infectiondata52', 'infectiondata53', 'infectiondata54', 'infectiondata55', 'infectiondata56', 'infectiondata57', 'infectiondata58', 'infectiondata59', 'infectiondata60', 'infectiondata61', 'infectiondata62', 'infectiondata63', 'infectiondata64', 'infectiondata65', 'infectiondata66', 'infectiondata67', 'infectiondata68', 'infectiondata69', 'infectiondata70', 'infectiondata71', 'infectiondata72', 'infectiondata73', 'infectiondata74', 'infectiondata75', 'infectiondata76', 'infectiondata77', 'infectiondata78', 'infectiondata79', 'infectiondata80', 'infectiondata81', 'infectiondata82', 'infectiondata83', 'infectiondata84', 'infectiondata85', 'infectiondata86', 'infectiondata87', 'infectiondata88', 'infectiondata89', 'infectiondata90', 'infectiondata91', 'infectiondata92', 'infectiondata93', 'infectiondata94', 'infectiondata95', 'infectiondata96', 'infectiondata97', 'infectiondata98', 'infectiondata99', 'infectiondata100', 'infectiondata101', 'infectiondata102', 'infectiondata103', 'infectiondata104', 'infectiondata105', 'infectiondata106', 'infectiondata107', 'infectiondata108', 'infectiondata109', 'infectiondata110', 'infectiondata111', 'infectiondata112', 'infectiondata113', 'infectiondata114', 'infectiondata115', 'infectiondata116', 'infectiondata117', 'infectiondata118', 'infectiondata119', 'infectiondata120', 'infectiondata121', 'infectiondata122', 'infectiondata123', 'infectiondata124', 'infectiondata125', 'infectiondata126', 'infectiondata127', 'infectiondata128', 'infectiondata129', 'infectiondata130', 'infectiondata131', 'infectiondata132', 'infectiondata133', 'infectiondata134', 'infectiondata135', 'infectiondata136', 'infectiondata137', 'infectiondata138', 'infectiondata139', 'infectiondata140', 'infectiondata141', 'infectiondata142', 'infectiondata143', 'infectiondata144', 'infectiondata145', 'infectiondata146', 'infectiondata147', 'infectiondata148', 'infectiondata149', 'infectiondata150', 'infectiondata151', 'infectiondata152', 'infectiondata153', 'infectiondata154', 'infectiondata155', 'infectiondata156', 'infectiondata157', 'infectiondata158', 'infectiondata159', 'infectiondata160', 'infectiondata161', 'infectiondata162', 'infectiondata163', 'infectiondata164', 'infectiondata165', 'infectiondata166', 'infectiondata167', 'infectiondata168', 'infectiondata169', 'infectiondata170', 'infectiondata171', 'infectiondata172', 'infectiondata173', 'infectiondata174', 'infectiondata175', 'infectiondata176', 'infectiondata177', 'infectiondata178', 'infectiondata179', 'infectiondata180', 'infectiondata181', 'infectiondata182', 'infectiondata183', 'infectiondata184', 'infectiondata185', 'infectiondata186', 'infectiondata187', 'infectiondata188', 'infectiondata189', 'infectiondata190', 'infectiondata191', 'infectiondata192', 'infectiondata193', 'infectiondata194', 'infectiondata195', 'infectiondata196', 'infectiondata197', 'infectiondata198', 'infectiondata199', 'infectiondata200', 'infectiondata201', 'infectiondata202', 'infectiondata203', 'infectiondata204', 'infectiondata205', 'infectiondata206', 'infectiondata207', 'infectiondata208', 'infectiondata209', 'infectiondata210', 'infectiondata211', 'infectiondata212', 'infectiondata213', 'infectiondata214', 'infectiondata215', 'infectiondata216', 'infectiondata217', 'infectiondata218', 'infectiondata219', 'infectiondata220', 'infectiondata221', 'infectiondata222', 'infectiondata223', 'infectiondata224', 'infectiondata225', 'infectiondata226', 'infectiondata227', 'infectiondata228', 'infectiondata229', 'infectiondata230', 'infectiondata231', 'infectiondata232', 'infectiondata233', 'infectiondata234', 'infectiondata235', 'infectiondata236', 'infectiondata237', 'infectiondata238', 'infectiondata239', 'infectiondata240', 'infectiondata241', 'infectiondata242', 'infectiondata243', 'infectiondata244', 'infectiondata245', 'infectiondata246', 'infectiondata247', 'infectiondata248', 'infectiondata249', 'infectiondata250', 'infectiondata251', 'infectiondata252', 'infectiondata253', 'infectiondata254', 'infectiondata255', 'infectiondata256', 'infectiondata257', 'infectiondata258', 'infectiondata259', 'infectiondata260', 'infectiondata261', 'infectiondata262', 'infectiondata263', 'infectiondata264', 'infectiondata265', 'infectiondata266', 'infectiondata267', 'infectiondata268', 'infectiondata269', 'infectiondata270', 'infectiondata271', 'infectiondata272', 'infectiondata273', 'infectiondata274', 'infectiondata275', 'infectiondata276', 'infectiondata277', 'infectiondata278', 'infectiondata279', 'infectiondata280', 'infectiondata281', 'infectiondata282', 'infectiondata283', 'infectiondata284', 'infectiondata285', 'infectiondata286', 'infectiondata287', 'infectiondata288', 'infectiondata289', 'infectiondata290', 'infectiondata291', 'infectiondata292', 'infectiondata293', 'infectiondata294', 'infectiondata295', 'infectiondata296', 'infectiondata297', 'infectiondata298', 'infectiondata299', 'infectiondata300', 'infectiondata301', 'infectiondata302', 'infectiondata303', 'infectiondata304', 'infectiondata305', 'infectiondata306', 'infectiondata307', 'infectiondata308', 'infectiondata309', 'infectiondata310', 'infectiondata311', 'infectiondata312', 'infectiondata313', 'infectiondata314', 'infectiondata315', 'infectiondata316', 'infectiondata317', 'infectiondata318', 'infectiondata319', 'infectiondata320', 'infectiondata321', 'infectiondata322', 'infectiondata323', 'infectiondata324', 'infectiondata325', 'infectiondata326', 'infectiondata327', 'infectiondata328', 'infectiondata329', 'infectiondata330', 'infectiondata331', 'infectiondata332', 'infectiondata333', 'infectiondata334', 'infectiondata335', 'infectiondata336', 'infectiondata337', 'infectiondata338', 'infectiondata339', 'infectiondata340', 'infectiondata341', 'infectiondata342', 'infectiondata343', 'infectiondata344', 'infectiondata345', 'infectiondata346', 'infectiondata347', 'infectiondata348', 'infectiondata349', 'infectiondata350', 'infectiondata351', 'infectiondata352', 'infectiondata353', 'infectiondata354', 'infectiondata355', 'infectiondata356', 'infectiondata357', 'infectiondata358', 'infectiondata359', 'infectiondata360', 'infectiondata361', 'infectiondata362', 'infectiondata363', 'infectiondata364', 'infectiondata365', 'infectiondata366', 'infectiondata367', 'infectiondata368', 'infectiondata369', 'infectiondata370', 'infectiondata371', 'infectiondata372', 'infectiondata373', 'infectiondata374', 'infectiondata375', 'infectiondata376', 'infectiondata377', 'infectiondata378', 'infectiondata379', 'infectiondata380', 'infectiondata381', 'infectiondata382', 'infectiondata383', 'infectiondata384', 'infectiondata385', 'infectiondata386', 'infectiondata387', 'infectiondata388', 'infectiondata389', 'infectiondata390', 'infectiondata391', 'infectiondata392', 'infectiondata393', 'infectiondata394', 'infectiondata395', 'infectiondata396', 'infectiondata397', 'infectiondata398', 'infectiondata399', 'infectiondata400', 'infectiondata401', 'infectiondata402', 'infectiondata403', 'infectiondata404', 'infectiondata405', 'infectiondata406', 'infectiondata407', 'infectiondata408', 'infectiondata409', 'infectiondata410', 'infectiondata411', 'infectiondata412', 'infectiondata413', 'infectiondata414', 'infectiondata415', 'infectiondata416', 'infectiondata417', 'infectiondata418', 'infectiondata419', 'infectiondata420', 'infectiondata421', 'infectiondata422', 'infectiondata423', 'infectiondata424', 'infectiondata425', 'infectiondata426', 'infectiondata427', 'infectiondata428', 'infectiondata429', 'infectiondata430', 'infectiondata431', 'infectiondata432', 'infectiondata433', 'infectiondata434', 'infectiondata435', 'infectiondata436', 'infectiondata437', 'infectiondata438', 'infectiondata439', 'infectiondata440', 'infectiondata441', 'infectiondata442', 'infectiondata443', 'infectiondata444', 'infectiondata445', 'infectiondata446', 'infectiondata447', 'infectiondata448', 'infectiondata449', 'infectiondata450', 'infectiondata451', 'infectiondata452', 'infectiondata453', 'infectiondata454', 'infectiondata455', 'infectiondata456', 'infectiondata457', 'infectiondata458', 'infectiondata459', 'infectiondata460', 'infectiondata461', 'infectiondata462', 'infectiondata463', 'infectiondata464', 'infectiondata465', 'infectiondata466', 'infectiondata467', 'infectiondata468', 'infectiondata469', 'infectiondata470', 'infectiondata471', 'infectiondata472', 'infectiondata473', 'infectiondata474', 'infectiondata475', 'infectiondata476', 'infectiondata477', 'infectiondata478', 'infectiondata479', 'infectiondata480', 'infectiondata481', 'infectiondata482', 'infectiondata483', 'infectiondata484', 'infectiondata485', 'infectiondata486', 'infectiondata487', 'infectiondata488', 'infectiondata489', 'infectiondata490', 'infectiondata491', 'infectiondata492', 'infectiondata493', 'infectiondata494', 'infectiondata495', 'infectiondata496', 'infectiondata497', 'infectiondata498', 'infectiondata499', 'infectiondata500'};
predictors = inputTable(:, predictorNames);
response = inputTable.infectionType;
isCategoricalPredictor = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
% Perform cross-validation
partitionedModel = crossval(trainedClassifier.ClassificationSVM, 'KFold', 5);
% Compute validation accuracy
validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError');
% Compute validation predictions and scores
[validationPredictions, validationScores] = kfoldPredict(partitionedModel);