-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b601404
commit 40e49a2
Showing
21 changed files
with
1,654 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function DupdateK=Bayesian_Clement(hypps,N,f,clfx,ytrain,oldfolder,ytrue,alpha,combo1) | ||
% ytrain=y_train; | ||
Sim=zeros(2,N); | ||
for i=1:N | ||
aa=(hypps(:,i))'; | ||
Sim(:,i)=abs((Forwarding(aa,f,clfx,ytrain,oldfolder,combo1))'); | ||
end | ||
|
||
% ytrue=y_train(5,:); | ||
|
||
[DupdateK] = ESMDA (hypps,ytrue', N, Sim,alpha); | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function DupdateK=Bayesian_Clement_2(hypps,N,f,clfx,ytrain,... | ||
oldfolder,ytrue,alpha,combo1,suni) | ||
% ytrain=y_train; | ||
%Sim=zeros(2,N); | ||
parfor i=1:N | ||
aa=(hypps(:,i)); | ||
aa=reshape(aa,[],suni) | ||
spit=abs((Forwarding(aa,f,clfx,ytrain,oldfolder,combo1))); | ||
spit=reshape(spit,[],1); | ||
Sim(:,i)=spit; | ||
end | ||
|
||
% ytrue=y_train(5,:); | ||
|
||
[DupdateK] = ESMDA (hypps,reshape(ytrue,[],1), N, Sim,alpha); | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
function [DupdateK] = ESMDA (sgsim,f, N, Sim1,alpha) | ||
sd=1; | ||
rng(sd) | ||
|
||
%----------------------------------------------------------------------------- | ||
|
||
parfor i=1:size(f,1) | ||
aa=f(i,:); | ||
aa1=num2str(aa); | ||
usee=str2num(aa1(1)); | ||
stddWOPR1 =1 %0.01*f(i,:); | ||
stdall(i,:)=stddWOPR1; | ||
end | ||
|
||
nobs = length(f); | ||
noise = randn(max(10000,nobs),1); | ||
|
||
Error1=stdall; | ||
sig=Error1; | ||
parfor i = 1 : length(f) | ||
f(i) = f(i) + sig(i)*noise(end-nobs+i); | ||
end | ||
R = sig.^2; | ||
Dj = repmat(f, 1, N); | ||
parfor i = 1:size(Dj,1) | ||
rndm(i,:) = randn(1,N); | ||
rndm(i,:) = rndm(i,:) - mean(rndm(i,:)); | ||
rndm(i,:) = rndm(i,:) / std(rndm(i,:)); | ||
Dj(i,:) = Dj(i,:) + sqrt(alpha)*sqrt(R(i)) * rndm(i,:); | ||
end | ||
|
||
|
||
Cd2 =diag(R); | ||
overall=sgsim; | ||
|
||
Y=overall; %State variable,it is important we include simulated measurements in the ensemble state variable | ||
M = mean(Sim1,2); | ||
% Mean of the ensemble state | ||
M2=mean(overall,2); | ||
%M=M' | ||
% Get the ensemble states pertubations | ||
parfor j=1:N | ||
S(:,j)=Sim1(:,j)-M; | ||
end | ||
parfor j=1:N | ||
yprime(:,j)=overall(:,j)-M2; | ||
end | ||
Cyd=(yprime*S')./((N-1)); | ||
Cdd=(S*S')./((N-1)); | ||
|
||
Ynew=Y+(Cyd*pinv2((Cdd+(alpha.*Cd2))))*(Dj-Sim1); | ||
|
||
DupdateK=Ynew; | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
function [Hardmean,Softmean]=Forwarding(parameters,fv,... | ||
clfx,y_train,oldfolder,combo1) | ||
|
||
X_test=(clfx.transform(parameters)); | ||
|
||
cd(oldfolder); | ||
|
||
%% | ||
for ii=1:size(y_train,2) | ||
% fprintf('Predicting measurement %d | %d .\n', ii,2); | ||
folderk = fv; | ||
switch combo1 | ||
case 1 | ||
|
||
cd(folderk) | ||
|
||
Classifiers=load('Classifiers'); | ||
Classifiers=Classifiers.Classifiers; | ||
|
||
Experts=load('Experts.out'); | ||
|
||
|
||
clfysses=load('clfysses'); | ||
clfysses=clfysses.clfysses; | ||
|
||
% clfy = MinMaxScalery(); | ||
% (clfy.fit(y_train(:,ii))); | ||
|
||
|
||
Regressors=load('Regressors'); | ||
Regressors=Regressors.Regressors; | ||
|
||
|
||
Xtrainbig=load('Xtrainbig'); | ||
Xtrainbig=Xtrainbig.Xtrainbig; | ||
|
||
ytrainbig=load('ytrainbig'); | ||
ytrainbig=ytrainbig.ytrainbig; | ||
|
||
[Hardmean(:,ii)]=prediction_1(Regressors{ii,1},... | ||
pred_class(X_test, Classifiers{ii,1})... | ||
,X_test,Xtrainbig{ii,1},ytrainbig{ii,1},Experts(ii,1),clfysses{ii,1}); | ||
|
||
[Softmean(:,ii),~]=Unseen_soft_1(Regressors{ii,1},... | ||
Classifiers{ii,1},X_test,Xtrainbig{ii,1},ytrainbig{ii,1}... | ||
,Experts(ii,1),clfysses{ii,1}); | ||
|
||
case 2 | ||
|
||
cd(folderk) | ||
|
||
% disp('Expert=DNN, Gate=DNN') | ||
Classifiers=load('Classifiers'); | ||
Classifiers=Classifiers.Classifiers; | ||
|
||
Experts=load('Experts.out'); | ||
|
||
Classallsbig=load('Classallsbig'); | ||
Classallsbig=Classallsbig.Classallsbig; | ||
|
||
clfysses=load('clfysses'); | ||
clfysses=clfysses.clfysses; | ||
|
||
Regressors=load('Regressors'); | ||
Regressors=Regressors.Regressors; | ||
|
||
% cd(oldfolder) | ||
[Hardmean(:,ii)]=prediction_2(Regressors{ii,1},pred_class(X_test... | ||
, Classifiers{ii,1})... | ||
,X_test,Classallsbig{ii,1},Experts(ii,1),clfysses{ii,1}); | ||
|
||
[Softmean(:,ii)]=Unseen_soft_2(Regressors{ii,1},... | ||
Classifiers{ii,1},X_test,Classallsbig{ii,1},Experts(ii,1),... | ||
clfysses{ii,1}); | ||
case 3 | ||
|
||
cd(folderk) | ||
Classifiers=load('Classifiers'); | ||
Classifiers=Classifiers.Classifiers; | ||
|
||
Experts=load('Experts.out'); | ||
|
||
Classallsbig=load('Classallsbig'); | ||
Classallsbig=Classallsbig.Classallsbig; | ||
|
||
|
||
clfysses=load('clfysses'); | ||
clfysses=clfysses.clfysses; | ||
|
||
Regressors=load('Regressors'); | ||
Regressors=Regressors.Regressors; | ||
|
||
% cd(oldfolder) | ||
[Hardmean(:,ii)]=prediction_3(Regressors{ii,1}... | ||
,str2double(predict(Classifiers{ii,1},X_test))... | ||
,X_test,Classallsbig{ii,1},Experts(ii,1),clfysses{ii,1}); | ||
|
||
[Softmean(:,ii),~]=Unseen_soft_3(Regressors{ii,1}... | ||
,Classifiers{ii,1},X_test,Experts(ii,1),clfysses{ii,1}); | ||
% | ||
end | ||
cd(oldfolder) | ||
end | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
function [Hardmean,Softmean]=Forwarding_prime(parameters,... | ||
fv,clfx,y_train,oldfolder,combo1) | ||
X_test=(parameters); | ||
cd(oldfolder); | ||
|
||
%% | ||
% Answerhard=cell(2,1); | ||
% Answersoft=cell(2,1); | ||
for ii=1:2 | ||
% fprintf('Predicting measurement %d | %d .\n', ii,2); | ||
folderk = fv; | ||
|
||
switch combo1 | ||
case 1 | ||
|
||
cd(folderk) | ||
|
||
|
||
Classifiers=load('Classifiers'); | ||
Classifiers=Classifiers.Classifiers; | ||
|
||
Experts=load('Experts.out'); | ||
|
||
|
||
clfysses=load('clfysses'); | ||
clfysses=clfysses.clfysses; | ||
|
||
% clfy = MinMaxScalery(); | ||
% (clfy.fit(y_train(:,ii))); | ||
|
||
|
||
Regressors=load('Regressors'); | ||
Regressors=Regressors.Regressors; | ||
|
||
|
||
Xtrainbig=load('Xtrainbig'); | ||
Xtrainbig=Xtrainbig.Xtrainbig; | ||
|
||
ytrainbig=load('ytrainbig'); | ||
ytrainbig=ytrainbig.ytrainbig; | ||
|
||
[Hardmean(:,ii),Hardvariance(:,ii)]=prediction_1(Regressors{ii,1},... | ||
pred_class(X_test, Classifiers{ii,1})... | ||
,X_test,Xtrainbig{ii,1},ytrainbig{ii,1},Experts,clfysses{ii,1}); | ||
[Softmean(:,ii),Softvariance(:,ii)]=Unseen_soft_1(Regressors{ii,1},... | ||
Classifiers{ii,1},X_test,Xtrainbig{ii,1},ytrainbig{ii,1}... | ||
,Experts,clfysses{ii,1}); | ||
|
||
case 2 | ||
|
||
cd(folderk) | ||
|
||
% disp('Expert=DNN, Gate=DNN') | ||
Classifiers=load('Classifiers'); | ||
Classifiers=Classifiers.Classifiers; | ||
|
||
Experts=load('Experts.out'); | ||
|
||
Classallsbig=load('Classallsbig'); | ||
Classallsbig=Classallsbig.Classallsbig; | ||
|
||
clfysses=load('clfysses'); | ||
clfysses=clfysses.clfysses; | ||
|
||
Regressors=load('Regressors'); | ||
Regressors=Regressors.Regressors; | ||
|
||
% cd(oldfolder) | ||
[Hardmean(:,ii)]=prediction_2(Regressors{ii,1},pred_class(X_test... | ||
, Classifiers{ii,1})... | ||
,X_test,Classallsbig{ii,1},Experts,clfysses{ii,1}); | ||
|
||
[Softmean(:,ii)]=Unseen_soft_2(Regressors{ii,1},... | ||
Classifiers{ii,1},X_test,Classallsbig{ii,1},... | ||
Experts,clfysses{ii,1}); | ||
case 3 | ||
|
||
cd(folderk) | ||
Classifiers=load('Classifiers'); | ||
Classifiers=Classifiers.Classifiers; | ||
|
||
Experts=load('Experts.out'); | ||
|
||
Classallsbig=load('Classallsbig'); | ||
Classallsbig=Classallsbig.Classallsbig; | ||
|
||
|
||
clfysses=load('clfysses'); | ||
clfysses=clfysses.clfysses; | ||
|
||
Regressors=load('Regressors'); | ||
Regressors=Regressors.Regressors; | ||
|
||
% cd(oldfolder) | ||
[Hardmean(:,ii),Hardvariance(:,ii)]=prediction_3(Regressors{ii,1}... | ||
,str2double(predict(Classifiers{ii,1},X_test))... | ||
,X_test,Classallsbig{ii,1},Experts,clfysses{ii,1}); | ||
|
||
[Softmean(:,ii),Softvariance(:,ii)]=Unseen_soft_3(Regressors{ii,1}... | ||
,Classifiers{ii,1},X_test,Experts,clfysses{ii,1}); | ||
% | ||
end | ||
cd(oldfolder) | ||
end | ||
|
||
|
||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function cov_big= Get_cov(X_test2,hyp_updated) | ||
for ik=1:size(X_test2,2) | ||
cov_big(:,ik)=cov(hyp_updated(:,ik)); | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function ensemble_ini=Get_ensemble(N,X_test2,meanss2,meanss) | ||
% for j=1:N | ||
% for jj=1:size(X_test2,2) | ||
% hyp_inipure(:,jj) = normrnd( meanss2(:,jj),0.1*meanss2(:,jj),1,1) ; | ||
% end | ||
% hyp_inipure=abs(hyp_inipure); | ||
% hyp_inipure(:,6)=round(hyp_inipure(:,6)); | ||
% hyp_inipure(:,8)=round(hyp_inipure(:,8)); | ||
% hyp_ini=(clfx.transform(hyp_inipure)); | ||
% ensemble_ini(:,j)=hyp_ini'; | ||
% end | ||
|
||
for jj=1:size(X_test2,2) | ||
hyp_inipuree(1:N,jj) = unifrnd(meanss2(:,jj),meanss(:,jj),10,1); | ||
end | ||
ensemble_ini=hyp_inipuree'; | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function ensemble_ini=Get_ensemble_2(N,X_test2,meanss2,meanss,Nop) | ||
|
||
p=2; | ||
szss=Nop; | ||
for k=1:N | ||
for jj=1:size(X_test2,2) | ||
aj=meanss2(:,jj)+ (meanss(:,jj)- meanss2(:,jj))*sum(rand(szss,p),2)/p; | ||
% hyp_inipuree(:,jj) = unifrnd(meanss2(:,jj),meanss(:,jj),szss,1); | ||
hyp_inipuree(:,jj) = reshape(aj,[],1); | ||
end | ||
|
||
ensemble_ini(:,k)=reshape(hyp_inipuree,[],1); | ||
end |
Oops, something went wrong.