-
Notifications
You must be signed in to change notification settings - Fork 0
/
LR.ecl
95 lines (69 loc) · 2.43 KB
/
LR.ecl
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#OPTION('obfuscateOutput',TRUE);
IMPORT $;
IMPORT $, LogisticRegression,ML_Core;
ASDDS := $.File__AllData.ASDDS;
ASDRec:= RECORD
REAL8 A1;
REAL8 A2;
REAL8 A3;
REAL8 A4;
REAL8 A5;
REAL8 A6;
REAL8 A7;
REAL8 A8;
REAL8 A9;
REAL8 A10;
STRING1 Sex;
STRING1 Jaundice;
STRING1 Family_mem_with_ASD;
STRING50 Who_completed_the_test;
REAL8 Age_Years_Normalized;
STRING8 ASD_traits;
END;
NewASDDS := PROJECT(ASDDS,ASDRec);
OUTPUT(NewASDDS,NAMED('NewASDDS'));
recn:=RECORD(ASDRec)
UNSIGNED rnd;
END;
tab1:=PROJECT(NewASDDS,TRANSFORM(recn,SELF.rnd:=RANDOM(),SELF:=LEFT));
tab1s:=SORT(tab1,rnd);
OUTPUT(tab1s,NAMED('SORT'));
train:= PROJECT(tab1s[1..3000],ASDRec);
test:=PROJECT(tab1s[3000..3743],ASDRec);
OUTPUT(train,NAMED('train'));
OUTPUT(test,NAMED('test'));
//numeric field matrix conversion
ML_Core.AppendSeqID(train, id, trainid);
ML_Core.AppendSeqID(test, id, testid);
ML_Core.ToField(trainid,trainNF);
ML_Core.ToField(testid,testNF);
indtrainNF:= trainNF(number<16);
deptrainNF:=PROJECT(trainNF(number=16),
TRANSFORM(ML_Core.Types.DiscreteField,
SELF.number:= 1,
SELF:=LEFT));
indtestNF:=testNF(number<16);
deptestNF:=PROJECT(testNF(number=16),
TRANSFORM(ML_Core.Types.DiscreteField,
SELF.number:=1,
SELF:=LEFT));
//OUTPUT(indtrainNF,NAMED('indtrainNF'));
//OUTPUT(deptrainNF,NAMED('deptrainNF'));
//OUTPUT(indtestNF,NAMED('indtestNF'));
//OUTPUT(deptestNF,NAMED('deptestNF'));
mylearner:= LogisticRegression.BinomialLogisticRegression();
mymodel:=mylearner.getModel(indtrainNF,deptrainNF);
mypredict:=mylearner.Classify(mymodel,indtestNF);
OUTPUT(mypredict,NAMED('PREDICT'));
myconfmatrix:=LogisticRegression.Confusion(deptestNF,mypredict);
OUTPUT(myconfmatrix,NAMED('CONFUSION'));
myconfacc:=LogisticRegression.BinomialConfusion(myconfmatrix);
OUTPUT(myconfacc,NAMED('ACCURACY'));
mybeta:=LogisticRegression.ExtractBeta(mymodel);
OUTPUT(mybeta,NAMED('BETAS'));
myscores:=LogisticRegression.LogitScore(mybeta,indtestNF);
OUTPUT(myscores,NAMED('SCORES'));
mydeviance:=LogisticRegression.Deviance_Detail(deptestNF,myscores);
OUTPUT(mydeviance,NAMED('DEVIANCEvalues'));
myaic:=LogisticRegression.Model_Deviance(mydeviance,mybeta);
OUTPUT(myaic,NAMED('DEVIATION'));