-
Notifications
You must be signed in to change notification settings - Fork 0
/
Predict_Ar.m
43 lines (40 loc) · 1.24 KB
/
Predict_Ar.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
clc
clear all
close all
warning off
%% Read Data
AllData=xlsread('AllData.xlsx');
[Row, Col] = size(AllData);
%% Normalization
Data=AllData(:,1:end-1);
Data=mapminmax(Data',0,1)';
AllData(:,1:end-1)=Data;
%%
RandInd=randperm(Row);
AllData=AllData(RandInd,:);
%% Make Train and Test Set (Train Set = 70%, Test Set = 30%)
TrainInfo=AllData(1:ceil(0.7*Row),:);
TestInfo=AllData(ceil(0.7*Row)+1:end,:);
%%
TrainTarget=TrainInfo(:,end); % Ar
TrainData=TrainInfo(:,1:end-1); % Parameters
TestTarget=TestInfo(:,end);
TestData=TestInfo(:,1:end-1);
% [Row,Col]=size(TrainData);
%% Determine New Data
SelectedParam=[1 2 3 4 5 6];
TrainData=TrainData(:,SelectedParam);
TestData=TestData(:,SelectedParam);
%% Make ANN Model
Plot=1; % 1. show net and Train Result , 0: Don't Show
[ AnnModel,TrResult ] = ANN_regression( TrainData,TrainTarget,Plot );
%%
Predicted=sim(AnnModel,TestData'); %simulation the network
TeResult.MSE=mse(Predicted'-TestTarget);
TeResult.RMSE=sqrt(mse(Predicted'-TestTarget));
TeResult.CORR=corr2(Predicted',TestTarget);
TeResult.R2 = rsquare(Predicted',TestTarget);
figure
PlotResults(Predicted', TestTarget, 'Test Data')
%%
xlswrite('R2.xlsx',[Predicted', TestTarget, Predicted'-TestTarget]);