example.m

来自「麻省理工学院的人工智能工具箱,很珍贵,希望对大家有用!」· M 代码 · 共 42 行

M
42
字号
dmn=readDomain('Iberia');
Stations.Network={'GSN'};
Stations.Stations={'Spain.stn'};
Stations.Variable={'Precip'};

%Training data
dates={'1-Jan-1960','31-Dec-1998'};
[EOF,CP]=getEOF(dmn,'ncp',50,'dates',dates);
[dataE,Stations]=loadStations(Stations,'dates',dates,'ascfile',1);

%Test data
dates={'1-Jan-1999','31-Dec-1999'};
[EOF,CPT]=getEOF(dmn,'ncp',50,'dates',dates);
[dataT,Stations]=loadStations(Stations,'dates',dates,'ascfile',1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%DETERMINISTIC (forecasting with the mean of the analog ensemble)
O=[];P=[];
for j=1:1:180
   [AnalogPat,Neig,NeigDist]=getAnalogous(CPT(j,:),CP,25,'knn',[]);
   O=[O;dataT(j,:)];
   P=[P;nanmean(dataE(Neig,:))];
end
plot([O(:,1),P(:,1)])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%PROBABILISTIC (forecasting with the frequency of the event)
umbral=5;
i=find(~isnan(dataE));
dataE(i)=dataE(i)>umbral;
dataT(:)=dataT(:)>umbral;

O=[];P=[];
for j=1:1:180
   [AnalogPat,Neig,NeigDist]=getAnalogous(CPT(j,:),CP,25,'knn',[]);
   O=[O;dataT(j,:)];
   P=[P;nanmean(dataE(Neig,:))];
end
%validation of the probabilistic forecast
makeValidation(O(:,1),P(:,1))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?