Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

% % = = = constants = = = % the time window relative to each event that may be used for classification epoch _

%%=== constants ===
% the time window relative to each event that may be used for classification
epoch_range =[-0.20.8];
% time ranges over which per-channel features should be extracted
time_ranges =[0.250.3; 0.30.35; 0.350.4; 0.40.45; 0.450.5; 0.50.6];
% regularization parameter for the shrinkage LDA
lambda =0.1;
%%=== train an ERP classifier ===
% load the calibration data set
load ERP_CALIB
% identify the sample latencies at which relevant events occur and their
% associated target class (=0 no error, 1=error)
train_events = strcmp({ERP_CALIB.event.type},'S 11')| strcmp({ERP_CALIB.event.type},'S 12')| strcmp({ERP_CALIB.event.type},'S 13');
train_latencies = round([ERP_CALIB.event(train_events).latency]);
train_labels =(~strcmp({ERP_CALIB.event(train_events).type},'S 11'))*2-1;
model = train_erp(ERP_CALIB.data,ERP_CALIB.srate,train_latencies,train_labels,epoch_range,time_ranges,lambda);
%%=== apply the classifier to each event in the test data ===
load ERP_TEST
% determine the relevant event latencies and true labels
test_events = strcmp({ERP_TEST.event.type},'S 11')| strcmp({ERP_TEST.event.type},'S 12')| strcmp({ERP_TEST.event.type},'S 13');
test_latencies = round([ERP_TEST.event(test_events).latency]);
test_labels =(~strcmp({ERP_TEST.event(test_events).type},'S 11'))*2-1;
% also get the sample range that is used to extract epochs relative to the events
epoch_samples = round(epoch_range(1)*ERP_TEST.srate) : round(epoch_range(2)*ERP_TEST.srate);
% for each test event...
predictions =[];
for e=1:length(test_latencies)
% extract the epoch
EPO = ERP_TEST.data(:,epoch_samples + test_latencies(e));
% classify it and record the prediction
predictions(e)= test_erp(EPO,model);
end
%%=== evaluate the loss on the test set ===
loss = eval_mcr(test_labels,predictions);
fprintf('The mis-classification rate on the test set is %.2f percent.
',100*loss);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

Find the opposite of the polynomial. -x-x+6 9

Answered: 1 week ago

Question

2. What role should job descriptions play in training at Apex?

Answered: 1 week ago