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?
Sensor-Depression/demo_balanced_cluster_GPS.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
623 lines (607 sloc)
23.5 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
%% | |
clc, clear all, close all | |
%% | |
% Load Data | |
load 'data\conv_feature.mat' | |
load 'data\activity_feature.mat' | |
load 'data\dark_feature.mat' | |
load 'data\phonecharge_feature.mat' | |
load 'data\phonelock_feature.mat' | |
load 'data\audio_feature.mat' | |
load 'data\pre_PHQ9.mat' | |
load 'data\post_PHQ9.mat' | |
load 'data\gps_Processesed_feature.mat' | |
% Path setting | |
prefix='\Depression_2\'; | |
addpath([prefix '\utility_code_1\clustering\ssvd-code']); | |
addpath([prefix '\utility_code_1\clustering\spectralCoClustering']); | |
addpath([prefix '\utility_code_1\clustering']); | |
addpath([prefix '\utility_code_1\short_functions']); | |
addpath([prefix '\utility_code_1\InfoTheory']); | |
addpath([prefix '\utility_code_1\kernel']); | |
addpath([prefix '\utility_code_1\evaluate']); | |
addpath([prefix '\utility_code_1\code']); | |
addpath([prefix '\code\exsiting_algorithm']); | |
addpath([prefix '\code']); | |
prefix='\Multi-view-Clustering\'; | |
addpath([prefix '\proximal_2']); | |
%% read the raw data for activity, conversation, dark, audio, phonelock records and give the average on day values as view1. Each row of view1 is an instance from the population. | |
% average one user/day - % for all 49 user get 1 value | |
view1(:, 1) = average_c(activity_feature, 3); % Activity = No Movement | |
view1(:, 2) = average_c(conv_feature, 3); % Conversation duration | |
view1(:, 3) = average_c(dark_feature, 3); % Dark duration | |
view1(:, 4) = average_c(dark_feature, 4); % Dark count | |
view1(:, 5) = average_c(conv_feature, 2); % Conversation count | |
view1(:, 6) = average_c(activity_feature, 4); % Activity = Walk | |
view1(:, 7) = average_c(activity_feature, 5); % Activity = Run | |
view1(:, 8) = average_c(audio_feature, 3); % Audio = Quite | |
view1(:, 9) = average_c(audio_feature, 4); % Audio = Noisy | |
view1(:, 10) = average_c(audio_feature, 5); % Audio = Loud | |
view1(:, 11) = average_c(phonelock_feature, 2); % Phone lock = Count | |
view1(:, 12) = average_c(phonelock_feature, 3); % Phone lock = Duration | |
%% read the sine parameters which fit the time series data of activity, audio, conversation, phonelock as view2. | |
% amp, phase, intercept and freq ///for all 49 user get 4 value | |
view2(:, 1:4) = denoising_wl_sin(activity_feature, 4, [800 14 0 6100]); % Walking -> amp, freq, phase, intercept | |
view2(:, 5:8) = denoising_wl_sin(audio_feature, 4, [400 14 0 1000]); % Noisy -> amp, phase, intercept and frequency | |
view2(:, 9:12) = denoising_wl_sin(conv_feature, 3, [200 14 0 7000]); % Conve | |
% view2(:, 13:16) = denoising_wl_sin(phonelock_feature, 3); | |
% view2 = [sin_act_5, sin_audio_5, sin_conv_5, sin_lock_5]; | |
%% View 3 have the GPS features that include: | |
% Location variance, Time spent in each cluster (K = 3), Entropy, | |
% Normalized entropy, percentage of time @ home, Transition time, and | |
% distance traveled in km. | |
view3 = gpsFeatures(:, 1:end-2);% End = User ids | |
%% Reassigning to different variables - no need though | |
view1_data = view1; | |
view2_data = view2; | |
view3_data = view3; | |
% normalize the data. | |
n = size(view1_data, 1); % total rows - 49 users | |
% d1 = size(view1_data, 2); | |
% d2 = size(view2_data, 2); | |
% d3 = size(view3_data, 2); | |
M_1_norm = normc(view1_data); | |
M_2_norm = normc(view2_data); | |
M_3_norm = normc(view3_data); | |
% Reassign the normalized data | |
M_1 = M_1_norm; | |
M_2 = M_2_norm; | |
M_3 = M_3_norm; | |
%a small experiment | |
% [m,n] = size(M_1_norm); | |
% M_1(:,1) = M_1_norm(:,n-3); | |
% M_1(:,n-3) = M_1_norm(:,1); | |
% Getting all values as in a single cell | |
M = cell(1, 1); | |
M{1} = M_1; | |
M{2} = M_2; | |
M{3} = M_3; | |
%% using cv to find the proper parameters lambda_z, lambda_2 then run | |
% Multiview Biclustering method to get the 1st cluster. lambda_z is for the | |
% size of the cluster we want. lambda_2 is for the number of features to | |
% differentiate the cluster from the rest of the population. | |
lambda_z = 9;%9; | |
lambda_2 = 5;%5; | |
iSeedV1 = 12;%12; | |
lambda_z2 = 7; | |
iSeedV2 = 1; | |
%% z1 is a binary vector as a idnetifier of our explored cluster. 1 means | |
% the ith instance on the ith row belong to the identified cluster. 0 means | |
% this instance does not belong to this cluster. V is a matrix shows the | |
% significantly useful features that be detected to diffentiate the | |
% identified cluster Clus1 from the rest by our method. | |
% Depressed people identification, also find what features are important | |
% for our clustering method | |
% cluster people into group, and see how they are related to depression | |
[z1, U, V, obj] = proxi3_3(M, lambda_z, [lambda_2; lambda_2; lambda_2], iSeedV1); | |
rowClus1 = double(z1~=0); | |
Clus1 = rowClus1; % After finding one cluster, erase that from data and then move forward for next clustering | |
%% erase the instances in Clus1, then prepare for the next clustering process. | |
IND = find(z1~=0); | |
M2_1 = M_1; | |
M2_2 = M_2; | |
M2_3 = M_3; | |
M2_1(IND, :)=[]; | |
M2_2(IND, :)=[]; | |
M2_3(IND, :)=[]; | |
M2{1} = M2_1; | |
M2{2} = M2_2; | |
M2{3} = M2_3; | |
%% run multiview biclustering method again to detect the 2nd cluster Clus2. | |
n_1_pre = []; | |
n_2_pre = []; | |
n_3_pre = []; | |
n_1_post = []; | |
n_2_post = []; | |
n_3_post = []; | |
[z2, U2, V2, obj] = proxi3_3(M2, lambda_z2, [lambda_2; lambda_2; lambda_2], iSeedV2); | |
rowClus2 = double(z2~=0); | |
Clus2 = zeros(n, 1); | |
Clus2(IND) = 0; | |
IND2 = 1:1:49; | |
IND2(IND) = []; | |
TN = find(z2==0); | |
IND2(TN) = []; | |
Clus2(IND2) = 1; | |
Clus3 = ones(n, 1) - Clus1 - Clus2; | |
% view 1 is ok | |
% view 2, wavelet filtering, f transformation -> raw data...can improve ft | |
% method. using ft to find most important point. Also we can add useful | |
% descrption - more features | |
% ------------------------------------------------------------------------ | |
%% Asma starts here - After adding view 3 i.e. GPS | |
% ------------------------------------------------------------------------ | |
%% Get data from View 1, 2 and 3 for Random forest | |
% First get all the values for view 1 based on V value | |
% For all users, get the average of each feature i.e. 49 rows/users, we | |
% will have 12 columns containing average of that perticular feature | |
for k = 1:49 %kth user | |
view1Data(k,1:12) = view1(k,:); % Jin's feature | |
% For testing purpose - delete later - successful test, id maches | |
% view1Data(k, 13) = double(activity_feature{k}(1, 1)); % Activity user id | |
% view1Data(k, 14) = double(conv_feature{k}(1, 1)); % conv user id | |
% view1Data(k, 15) = double(dark_feature{k}(1, 1)); % dark feature user id | |
% view1Data(k, 16) = double(audio_feature{k}(1, 1)); % audio user id | |
% view1Data(k, 17) = double(phonelock_feature{k}(1, 1)); % ph lock user id | |
% if (view1Data(k, 13) == view1Data(k, 15)) && (view1Data(k, 13) == view1Data(k, 16)) | |
% igetthevalues(k) = 1; | |
% else | |
% igetthevalues(k) = 0; | |
% end | |
end | |
% View 2 data | |
view1Data(:, 13:24) = view2(:, :); % amp, phase, intercept and freq of activity, Audio feature, Conversation feaure | |
% view1Data(:, 22:25) = view2(:, 5:8); % | |
% view1Data(:, 26:29) = view2(:, 9:12); % | |
% View 3 data - GPS Features | |
view1Data(:,25:33) = view3; | |
view1Data(:,34) = gpsFeatures(:, end-1); % the user ids - for matching | |
% purpose only - successful test, id maches | |
% Match user ids and assign both PHQ9 id and score, else keep -1 | |
x = 1; | |
z = size(view1Data,2); % To add more columns | |
for i = 1:size(view1Data,1) | |
if view1Data(i, 34) == pre_PHQ9(x,1)% == view1Data(:,39) %if ids match - pre-phq9 | |
% view1Data(i, z+1) = pre_PHQ9(x,1); % User id | |
view1Data(i, z+1) = pre_PHQ9(x, 2); % User's pre-phq9 score | |
x = x + 1; | |
else % If user not exists | |
view1Data(i, z+1) = -1; | |
% view1Data(i, z+2) = -1; | |
end | |
end | |
% Same for post phq-9 | |
x = 1; | |
for i = 1:size(view1Data,1) | |
if view1Data(i, 34) == post_PHQ9(x,1)% == view1Data(i,39) %if ids match - post-phq9 | |
% view1Data(i, z+3) = post_PHQ9(x,1); % User id | |
view1Data(i, z+2) = post_PHQ9(x, 2); % User's pre-phq9 score | |
x = x + 1; | |
else % If user not exists | |
view1Data(i, z+2) = -1; | |
% view1Data(i, z+4) = -1; | |
end | |
end | |
plotData = view1Data; | |
% Feature selection through multiview - might have to change | |
fSetV1 = V{1}(:,1); | |
fSetV2 = V{2}(:,1); | |
fSetV3 = V{3}(:,1); | |
fSetV1_2 = V2{1}(:,1); | |
fSetV2_2 = V2{2}(:,1); | |
fSetV3_2 = V2{3}(:,1); | |
j = 1; | |
v1_p = 0; | |
for i = 1:size(fSetV1,1) | |
% if (fSetV1(i,1) ~= 0 | fSetV1_2(i,1) ~= 0 ) % If feature is selected by the clustering algorithm | |
fSetV1Data(:,j) = view1Data(:,i); % Get the whole column of that feature | |
j = j + 1; | |
v1_p = v1_p + 1; | |
%end | |
end | |
%View 2 | |
v2_p = 0; | |
for i = 1:size(fSetV2,1) | |
if (fSetV2(i,1) ~= 0 | fSetV2_2(i,1) ~= 0) % If feature is selected by the clustering algorithm | |
fSetV1Data(:,j) = view1Data(:,12+i); % Get the whole column of that feature | |
j = j + 1; | |
v2_p = v2_p + 1; | |
end | |
end | |
%View 3 | |
v3_p = 0; | |
for i = 1:size(fSetV3,1) | |
if (fSetV3(i,1) >= 0 | fSetV3_2(i,1) ~= 0 ) % See if we need to handle the negitive values | |
fSetV1Data(:,j) = view1Data(:,24+i); % Get the whole column of that feature | |
j = j + 1; | |
v3_p = v3_p + 1; | |
end | |
end | |
b1 = size(fSetV1Data,2); | |
testAsma = fSetV1Data; | |
fSetV1Data(:,j) = view1Data(:,z+1); % pre Phq-9 score | |
fSetV1Data(:,j+1) = view1Data(:,z+2); % post Phq-9 score | |
for i = 1:size(fSetV1Data,1) | |
fSetV1Data(i,j+2) = mean(fSetV1Data(i,j:j+1)); %PHQ-9 scores | |
end | |
% for i = 1:size(fSetV1Data,1) | |
% if fSetV1Data(i,j+2) >= 10 % Cut off at 10 for the mean PHQ-9 | |
% fSetV1Data(i,j+3) = 1; | |
% else | |
% fSetV1Data(i,j+3) = 0; | |
% end | |
% end | |
AllClusData = zeros(size(Clus1,1),1); | |
for i = 1:size(AllClusData,1) | |
if (Clus1(i,1) == 1) | |
AllClusData(i,1) = 1; % Cluster 1 (-1) | |
elseif (Clus2(i,1) == 1) | |
AllClusData(i,1) = 2; % Cluster 2 (1) | |
elseif (Clus3(i,1) == 1) | |
AllClusData(i,1) = 3; % Cluster 3 (0) | |
end | |
end | |
fSetV1Data(:,end+1) = AllClusData; | |
plotData(:,end+1) = AllClusData; | |
% fSetV1Data(:,end+1) = Clus1(:,1); | |
% fSetV1Data(:,end+1) = Clus2(:,1); | |
% fSetV1Data(:,end+1) = Clus3(:,1); | |
%% | |
% Creating a balanced data set | |
Clus1Assign = find(fSetV1Data(:,end) == 1); | |
x_d = fSetV1Data(Clus1Assign,:); | |
y_d = fSetV1Data(Clus1Assign,:); | |
z_d = fSetV1Data(Clus1Assign,:); | |
%% | |
Clus2Assign = find(fSetV1Data(:,end) == 2); | |
x_d1 = fSetV1Data(Clus2Assign,:); | |
y_d1 = fSetV1Data(Clus2Assign,:); | |
z_d1= fSetV1Data(Clus2Assign,:); | |
fSetV1Data = [fSetV1Data; x_d; y_d; z_d; x_d1; y_d1; z_d1; z_d1]; | |
% fSetV1Data(50:end, end-3) = 1; % Self assignment | |
% Normalize the data set | |
d3 = fSetV1Data(:,1:end-4); % Remove other cols - Self assignment | |
d3 = [normc(d3) fSetV1Data(:,end)]; % Normalize the data, but not labels - for random forest | |
%% | |
% Plotting - asma starts here | |
% Get the cluster wise data | |
plotData1 = plotData(:,1:33); % features | |
plotData1(:,end+1) = plotData(:,35); % pre-phq | |
plotData1(:,end+1) = (plotData(:,36)+plotData(:,35)/2);% post-phq | |
plotData1(:,end+1) = plotData(:,end);% cluster label | |
p = find(plotData1(:, end) == 1); | |
q = find(plotData1(:, end) == 2); | |
r = find(plotData1(:, end) == 3); | |
for i = 1:(size(plotData1,2)-1) | |
meanAll(i) = mean(plotData1(:,i)); % mean of all, not cluster wise | |
stdAll(i) = std(plotData1(:,i)); % std of all, not cluster wise | |
meanc1(i) = mean(plotData1(p,i)); % mean of cluster 1 in view 1 | |
val1(i) = (meanc1(i) - meanAll(i))/stdAll(i); | |
meanc2(i) = mean(plotData1(q,i)); % mean of cluster 2 | |
val2(i) = (meanc2(i) - meanAll(i))/stdAll(i); | |
meanc3(i) = mean(plotData1(r,i)); % mean of cluster 3 | |
val3(i) = (meanc3(i) - meanAll(i))/stdAll(i); | |
end | |
% Lets plot view 1 - 1:12, 3 clusters | |
% Titles - amp, freq, phase, intercept | |
view1Title2 = {'PHQ9_{avg}','Activity_s', 'Conv_d', 'Dark_d', 'Dark_c', 'Conv_c', 'Activity_w', 'Activity_r', 'Audio_q', 'Audio_n','Audio_v','PhoneLock_c','PhoneLock_d'}'; | |
view2Title2 = {'PHQ9_{avg}','Walk_a', 'Walk_p','Walk_{ph}','Walk_i','Noise_a', 'Noise_p','Noise_{ph}','Noise_i', 'ConD_a','ConD_p','ConD_{ph}','ConD_i'}; | |
view3Title2 = {'PHQ9_{avg}','Location_{var}','Time_c_1','Time_c_2', 'Time_c_3','Entropy','Entropy_N','Home_d','Move_{percent}', 'Dist'}'; | |
% Get view 1, cluster 1 | |
clus1v1 = val1(1,1:12); % cluster 1 | |
clus2v1 = val2(1,1:12); % cluster 2 | |
clus3v1 = val3(1,1:12); % cluster 3 | |
clusPHQc1 = val1(1,end-1);%end-2: | |
clusPHQc2 = val2(1,end-1);%end-2: | |
clusPHQc3 = val3(1,end-1);%end-2: | |
TT = [clusPHQc1, clus1v1]; | |
TT2 = [clusPHQc2, clus2v1]; | |
TT3 = [clusPHQc3, clus3v1]; | |
figure(1), | |
hdl1 = bar(1:3, [TT; TT2; TT3]); | |
set(gca,'XTickLabel',{'Cluster1','Cluster2','Cluster3'}, 'FontSize',20) | |
xlabel('Average View','FontSize',20),ylabel('Relative Mean Value','FontSize',20) | |
gridLegend(hdl1,6,view1Title2, 'Fontsize',16);%, 'location','northoutside','Fontsize',12);%,'Box','off'););%,'location','northoutside','Fontsize',10,'Box','off'); | |
%axis([0,4 ,-1,2 ]); | |
grid on | |
grid minor | |
% view 2 | |
clus1v2 = val1(1,13:24); % cluster 1 | |
clus2v2 = val2(1,13:24); % cluster 2 | |
clus3v2 = val3(1,13:24); % cluster 3 | |
clusPHQc1 = val1(1,end-1);%end-2: | |
clusPHQc2 = val2(1,end-1);%end-2: | |
clusPHQc3 = val3(1,end-1);%end-2: | |
TT = [clusPHQc1, clus1v2]; | |
TT2 = [clusPHQc2, clus2v2]; | |
TT3 = [clusPHQc3, clus3v2]; | |
figure(2), | |
hdl2 = bar(1:3, [TT; TT2; TT3]); | |
set(gca,'XTickLabel',{'Cluster1','Cluster2','Cluster3'}, 'FontSize',20) | |
xlabel('Trend View','FontSize',20),ylabel('Relative Mean Value','FontSize',20) | |
gridLegend(hdl2,6,view2Title2, 'Fontsize',16);%, 'location','northoutside','Fontsize',12);%,'Box','off'); | |
%axis([0,4 ,-1,2 ]); | |
grid on | |
grid minor | |
% view 3 | |
clus1v3 = val1(1,25:33); % cluster 1 | |
clus2v3 = val2(1,25:33); % cluster 2 | |
clus3v3 = val3(1,25:33); % cluster 3 | |
clusPHQc1 = val1(1,end-1);%end-2: | |
clusPHQc2 = val2(1,end-1);%end-2: | |
clusPHQc3 = val3(1,end-1);%end-2: | |
TT = [clusPHQc1, clus1v3]; | |
TT2 = [clusPHQc2, clus2v3]; | |
TT3 = [clusPHQc3, clus3v3]; | |
figure(3), | |
hdl3 = bar(1:3, [TT; TT2; TT3]); | |
set(gca,'XTickLabel',{'Cluster1','Cluster2','Cluster3'}, 'FontSize',20) | |
xlabel('Mobility View','FontSize',20),ylabel('Relative Mean Value','FontSize',20) | |
gridLegend(hdl3,5,view3Title2, 'Fontsize',16);%, 'location','northoutside','Fontsize',12);%,'Box','off'););%,'location','northoutside','Fontsize',10,'Box','off'); | |
%axis([0,4 ,-1,2 ]); | |
grid on | |
grid minor | |
%% Plot average PHQ-9 score and features for each view | |
%% | |
% phqmat = -ones(60,5); | |
% for i = 1: 49 | |
% te = audio_feature{1,i}; | |
% id(i) = te(1,1); | |
% end | |
% for i = 1 :46 | |
% phqmat(pre_PHQ9(i, 1)+1, 1) = pre_PHQ9(i, 2); | |
% end | |
% for i = 1 :38 | |
% phqmat(post_PHQ9(i, 1)+1, 2) = post_PHQ9(i, 2); | |
% end | |
% for i = 1 :49 | |
% phqmat(id(i)+1, 3) = Clus1(i); | |
% end | |
% for i = 1 :49 | |
% phqmat(id(i)+1, 4) = Clus2(i); | |
% end | |
% for i = 1 :49 | |
% phqmat(id(i)+1, 5) = Clus3(i); | |
% end | |
% sum_1_pre = 0; | |
% t =0; | |
% for i = 1 : 60 | |
% if(phqmat(i,3) == 1 && phqmat(i, 1) > 0) | |
% t = t+1; | |
% sum_1_pre = sum_1_pre + phqmat(i, 1); | |
% n_1_pre(t) = phqmat(i, 1); | |
% end | |
% end | |
% sum_1_pre = sum_1_pre/t; | |
% | |
% t=0; | |
% sum_1_post = 0; | |
% for i = 1 : 60 | |
% if(phqmat(i,3)==1 && phqmat(i, 2)>0) | |
% t = t+1; | |
% sum_1_post = sum_1_post + phqmat(i, 2); | |
% n_1_post(t) = phqmat(i, 2); | |
% end | |
% end | |
% sum_1_post = sum_1_post/t; | |
% | |
% t=0; | |
% sum_2_pre = 0; | |
% for i = 1 : 60 | |
% if(phqmat(i,4)==1 && phqmat(i, 1)>0) | |
% t = t+1; | |
% sum_2_pre = sum_2_pre + phqmat(i, 1); | |
% n_2_pre(t) = phqmat(i, 1); | |
% end | |
% end | |
% sum_2_pre = sum_2_pre/t; | |
% | |
% t=0; | |
% sum_2_post = 0; | |
% for i = 1 : 60 | |
% if(phqmat(i,4)==1 && phqmat(i, 2)>0) | |
% t = t+1; | |
% sum_2_post = sum_2_post + phqmat(i, 2); | |
% n_2_post(t) = phqmat(i, 2); | |
% end | |
% end | |
% sum_2_post = sum_2_post/t; | |
% | |
% | |
% t=0; | |
% sum_3_pre = 0; | |
% for i = 1 : 60 | |
% if(phqmat(i,5)==1 && phqmat(i, 1)>0) | |
% t = t+1; | |
% sum_3_pre = sum_3_pre + phqmat(i, 1); | |
% n_3_pre(t) = phqmat(i, 1); | |
% end | |
% end | |
% sum_3_pre = sum_3_pre/t; | |
% | |
% t=0; | |
% sum_3_post = 0; | |
% for i = 1 : 60 | |
% if(phqmat(i,5)==1 && phqmat(i, 2)>0) | |
% t = t+1; | |
% sum_3_post = sum_3_post + phqmat(i, 2); | |
% n_3_post(t) = phqmat(i, 2); | |
% end | |
% end | |
% sum_3_post = sum_3_post/t; | |
% | |
% var_1_pre = std(n_1_pre); | |
% var_2_pre = std(n_2_pre); | |
% var_3_pre = std(n_3_pre); | |
% var_1_post = std(n_1_post); | |
% var_2_post = std(n_2_post); | |
% var_3_post = std(n_3_post); | |
% var_pre = std(pre_PHQ9(:, 2)); | |
% var_post = std(post_PHQ9(:, 2)); | |
% avar_1_pre = var_1_pre/var_pre ; | |
% avar_2_pre = var_2_pre/var_pre; | |
% avar_3_pre = var_3_pre/var_pre; | |
% avar_1_post = var_1_post/var_post; | |
% avar_2_post = var_2_post/var_post; | |
% avar_3_post = var_3_post/var_post; | |
% | |
% sum_pre = sum(pre_PHQ9(:, 2))/46; | |
% sum_post = sum(post_PHQ9(:, 2))/38; | |
% aver_1_pre = sum_1_pre / sum_pre;%sum_1_pre = sum(where clus=1 & score >0 /total such instances) | |
% aver_2_pre = sum_2_pre / sum_pre; | |
% aver_3_pre = sum_3_pre / sum_pre; | |
% aver_1_post = sum_1_post / sum_post; | |
% aver_2_post = sum_2_post / sum_post; | |
% aver_3_post = sum_3_post / sum_post; | |
% | |
% vari1 = zeros(3, 14); | |
% vari1(1,1) = avar_1_pre/ sum_pre; | |
% vari1(1,2) = avar_1_post/ sum_post; | |
% vari1(2,1) = avar_2_pre/ sum_pre; | |
% vari1(2,2) = avar_2_post/ sum_post; | |
% vari1(3,1) = avar_3_pre/ sum_pre; | |
% vari1(3,2) = avar_3_post/ sum_post; | |
% | |
% vari2 = zeros(3, 18); | |
% vari2(1,1) = avar_1_pre/ sum_pre; | |
% vari2(1,2) = avar_1_post/ sum_post; | |
% vari2(2,1) = avar_2_pre/ sum_pre; | |
% vari2(2,2) = avar_2_post/ sum_post; | |
% vari2(3,1) = avar_3_pre/ sum_pre; % Asma changed from vari1 | |
% vari2(3,2) = avar_3_post/ sum_post; % Asma changed from vari1 | |
% | |
% % Asma added | |
% vari3 = zeros(3, 18); | |
% vari3(1,1) = avar_1_pre/ sum_pre; | |
% vari3(1,2) = avar_1_post/ sum_post; | |
% vari3(2,1) = avar_2_pre/ sum_pre; | |
% vari3(2,2) = avar_2_post/ sum_post; | |
% vari3(3,1) = avar_3_pre/ sum_pre; | |
% vari3(3,2) = avar_3_post/ sum_post; | |
% | |
% indCon_3 = find(V{1,1} ~= 0); | |
% indIgn_3 = find(V{1,1} == 0); | |
% NC = vertcat(indCon_3, indIgn_3); | |
% view1ReOrder = view1(:,NC); | |
% view1Title2 = {'Act_{still}', 'Conv_{dur}', 'Dark_{dur}', 'Dark_{cnt}', 'Conv_{cnt}', 'Act_{walk}', 'Act_{run}', 'Aud_{quiet}', 'Aud_{noisy}','Aud_{loud}','Loc_{cnt}','Loc_{dur}'}; | |
% view1Title = {'PRE-PHQ','POST-PHQ',view1Title2{1,indCon_3},view1Title2{1,indIgn_3}}; | |
% clc | |
% disp('----------------------------Ignored View 1-------------------------------------') | |
% view1Title2{1,indIgn_3} | |
% | |
% indCon_3 = find(V{2,1} ~= 0); | |
% indIgn_3 = find(V{2,1} == 0); | |
% NC = vertcat(indCon_3, indIgn_3); | |
% view2ReOrder = view2(:,NC); | |
%view1Title2 = {'Act_{still}', 'Conv_{dur}', 'Dark_{dur}', 'Dark_{cnt}', 'Conv_{cnt}', 'Act_{walk}', 'Act_{run}', 'Aud_{quiet}', 'Aud_{noisy}','Aud_{loud}','Loc_{cnt}','Loc_{dur}'}; | |
%view2Title2 = {'walk_{amp}', 'walk_{phase}','walk_{intcept}','walk{freq}','audio_{noise(amp)}', 'audio_{noise(phase)}','audio_{noise(intcept)}','audio_{noise(freq)}', 'conv_{cnt(amp)}','conv_{cnt(phase)}','conv_{cnt(intcept)}','conv_{cnt(freq)}'}; | |
% view2Title = {'PRE-PHQ','POST-PHQ',view2Title2{1,indCon_3},view2Title2{1,indIgn_3}}; | |
% disp('----------------------Ignored View 2--------------------------------') | |
% view2Title2{1,indIgn_3} | |
% | |
% | |
% | |
% indCon_3 = find(V{3,1} ~= 0); | |
% indIgn_3 = find(V{3,1} == 0); | |
% NC = vertcat(indCon_3, indIgn_3); | |
% view3ReOrder = view3(:,NC); | |
% view3Title2 = {'Var','Time in K-1','Time in K-2', 'Time in K-3','Entropy','N.Entropy','Time@Home','Transition time', 'Distance travel'}; | |
% view3Title = {'PRE-PHQ','POST-PHQ',view3Title2{1,indCon_3},view3Title2{1,indIgn_3}}; | |
% disp('----------------------Ignored View 3--------------------------------') | |
% view3Title2{1,indIgn_3} | |
% | |
% Clusmat = [Clus1, Clus2, Clus3]; | |
% View1_perc = Clusmat' * view1ReOrder; | |
% View2_perc = Clusmat' * view2ReOrder; | |
% | |
% View3_perc = Clusmat' * view3ReOrder; | |
% | |
% | |
% View1_perc(1, :) = View1_perc(1, :) / sum(Clus1); | |
% View1_perc(2, :) = View1_perc(2, :) / sum(Clus2); | |
% View1_perc(3, :) = View1_perc(3, :) / sum(Clus3); | |
% View2_perc(1, :) = View2_perc(1, :) / sum(Clus1); | |
% View2_perc(2, :) = View2_perc(2, :) / sum(Clus2); | |
% View2_perc(3, :) = View2_perc(3, :) / sum(Clus3); | |
% View3_perc(1, :) = View3_perc(1, :) / sum(Clus1); | |
% View3_perc(2, :) = View3_perc(2, :) / sum(Clus2); | |
% View3_perc(3, :) = View3_perc(3, :) / sum(Clus3); | |
% | |
% | |
% | |
% Clusall = double(Clus1|Clus2|Clus3); | |
% averView1 = (Clusall' * view1ReOrder) / sum(Clusall); | |
% averView2 = (Clusall' * view2ReOrder) / sum(Clusall); | |
% averView3 = (Clusall' * view3ReOrder) / sum(Clusall); | |
% | |
% PHQ = [aver_1_pre,aver_1_post;aver_2_pre,aver_2_post;aver_3_pre,aver_3_post]; | |
% for i = 1 : 3 | |
% View1_perc(i, :) = View1_perc(i, :) ./ averView1; | |
% View2_perc(i, :) = View2_perc(i, :) ./ averView2; | |
% View3_perc(i, :) = View3_perc(i, :) ./ averView3; | |
% end | |
% TT = [PHQ, View1_perc]; | |
% figure(1); bar(TT,1); | |
% | |
% | |
% | |
% set(gca,'XTickLabel',{'Cluster1','Cluster2','Cluster3'}, 'FontSize',20) | |
% xlabel('View-Average','FontSize',20),ylabel('Relative distance to the average','FontSize',20) | |
% legend(view1Title,-1, 'FontSize',14)%'ConvDur', 'DarkCnt', 'DarkDur','AudLd','PhlckDur','ActNoMvt','ConvCnt', 'ActWalk', 'ActRun', 'AudQte', 'AudNoisy', 'PhLckCnt', -1) | |
% grid on | |
% grid minor | |
% % legend('PRE-PHQ','POST-PHQ','Act_1', 'Conv_t', 'Dark_n', 'Dark_t', 'Conv_n', 'Act_2', 'Act_3', 'Aud_1', 'Aud_2','Aud_3','Loc_n','Loc_t',-1) | |
% % axis([0,4 ,0.6, 1.8 ]); | |
% axis([0,4 ,0,3 ]); | |
% hold on; | |
% numgroups = size(View1_perc, 1); | |
% numbars = size(View1_perc, 2)+2; | |
% groupwidth = min(0.8, numbars/(numbars+1.5)); | |
% for u = 1:numbars | |
% % Based on barweb.m by Bolu Ajiboye from MATLAB File Exchange | |
% x = (1:numgroups) - groupwidth/2 + (2*u-1) * groupwidth / (2*numbars); % Aligning error bar with individual bar | |
% errorbar(x, TT(:, u), vari1(:,u), 'k', 'linestyle', 'none'); | |
% end | |
% | |
% TT = [PHQ, View2_perc]; | |
% figure(2); bar(TT,1); | |
% set(gca,'XTickLabel',{'Cluster1','Cluster2','Cluster3'}, 'FontSize',20) | |
% xlabel('View-Variance','FontSize',20),ylabel('Relative distance to the average','FontSize',20) | |
% legend(view2Title,-1, 'FontSize',14)%'act_1(amp)', 'act_2(phase)','act_4(Freq)','audio_4(Freq)','conv_4(Freq)', 'act_3(intcpt)','audio_1(amp)', 'audio_2(phase)','audio_3(intcpt)','conv_1(amp)','conv_2(phase)','conv_3(intcpt)', -1) | |
% grid on | |
% grid minor | |
% % amp, phase, intercept and freq | |
% % legend('PRE-PHQ','POST-PHQ','act_1', 'act_2','act_3','act_4','audio_1', 'audio_2','audio_3','audio_4','conv_1','conv_2','conv_3','conv_4', 'lock_1','lock_2','lock_3','lock_4',-1) | |
% % axis([0,4 ,0,3 ]); | |
% axis([0,4 ,-1,3 ]); | |
% hold on; | |
% numgroups = size(View2_perc, 1); | |
% numbars = size(View2_perc, 2)+2; | |
% groupwidth = min(0.8, numbars/(numbars+1.5)); | |
% for u = 1:numbars | |
% % Based on barweb.m by Bolu Ajiboye from MATLAB File Exchange | |
% x = (1:numgroups) - groupwidth/2 + (2*u-1) * groupwidth / (2*numbars); % Aligning error bar with individual bar | |
% errorbar(x, TT(:, u), vari2(:,u), 'k', 'linestyle', 'none'); | |
% end | |
% | |
% TT = [PHQ, View3_perc]; | |
% figure(3); bar(TT,1); | |
% set(gca,'XTickLabel',{'Cluster1','Cluster2','Cluster3'},'FontSize',20) | |
% xlabel('GPS Features','FontSize',20),ylabel('Relative distance to the average','FontSize',20) | |
% legend(view3Title,-1, 'FontSize',14)%'Var','Time in K-1','Ent','N.Ent','Time@Home','Transition time', 'Time in K-2', 'Time in K-3', 'Distance travel',-1) | |
% grid on | |
% grid minor | |
% axis([0,4 ,0,3 ]); | |
% % axis([0,4 ,-1,3 ]); | |
% hold on; | |
% numgroups = size(View3_perc, 1); | |
% numbars = size(View3_perc, 2)+2; | |
% groupwidth = min(0.8, numbars/(numbars+1.5)); | |
% for u = 1:numbars | |
% % Based on barweb.m by Bolu Ajiboye from MATLAB File Exchange | |
% x = (1:numgroups) - groupwidth/2 + (2*u-1) * groupwidth / (2*numbars); % Aligning error bar with individual bar | |
% errorbar(x, TT(:, u), vari3(:,u), 'k', 'linestyle', 'none'); | |
% end | |
% %% View 3 have the GPS features that include: Location variance[1 ], Time spent in each cluster (K = 3)[2,3,4], | |
% % Entropy [5], Normalized entropy [6], percentage of time @ home[7], Transition time[8], and distance traveled in km [9]. | |
% % Time spent in first cluster, Entropy [5], Normalized entropy [6], percentage of time @ home[7], Transition time[8] |