Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
jpm-behavior/Run_Pareto.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
66 lines (53 sloc)
1.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [] = Run_Pareto(dirstring, beh_type, filepath, file_ext, mode, ... | |
kernel) | |
% This function sets up a Pareto Analysis to run for eligible | |
% individuals. | |
% Parameters: | |
% dirstring: string to load from and save to | |
% beh type: "AGG","SIB",or "BOTH", the type of behavior | |
% filepath: file path leading to the individual model files | |
% file_ext: file name of the individual model files | |
% mode: 'linear' or 'logistic' activation function | |
% kernel: 'yes' or 'no', direct kernel transformation or not | |
% Set random seed | |
rng(0,'twister') | |
tic | |
% Load all people | |
load(strcat(dirstring,'/', beh_type,'people2.mat')); | |
for person = 1:length(eligible_people) | |
curr_person = eligible_people(person); | |
load(strcat(filepath,beh_type,file_ext,string(curr_person),'.mat')) ; | |
if WT1{1}.Best == -1 | |
continue | |
end | |
bcrs = NaN(1,30); | |
for i=1:30 | |
bcr = WT1{i}.BCR; | |
bcrs(i) = bcr; | |
end | |
% Sort the BCRs ascending | |
[B, I] = sort(bcrs); | |
% Find the indices that are nan | |
nanB = isnan(B); | |
% Get rid of the NaN indices | |
I = I(~nanB); | |
B = B(~nanB); | |
% Find the median of the valid BCRs | |
med = median(bcrs,'omitnan'); | |
med | |
% Find the index of the value closest to this median | |
[c ind] = min(abs(B-med)); | |
% Find the index in terms of the original indices | |
ind = I(ind); | |
% Get the model at that index | |
Model = WT1{ind}; | |
% Run the pareto analysis | |
Model = ParetoAnalysis_Features(Model, Model.Xtrain, ... | |
Model.Prototypes, mode, kernel, Model.sigma); | |
STDs(person,:) = Model.Var; | |
yhats{person} = Model.yhats; | |
end | |
% Save out data | |
save(strcat(dirstring, '/', beh_type,'STDs.mat'),'STDs'); | |
save(strcat(dirstring, '/', beh_type,'yhats.mat'),'yhats'); | |
end |