TD_OneClassSVMPredict Example: Outlier/Novelty Detection
The input is the diabetes_train_scaled set used in the example of TD_OneClassSVM.
ID |
Pregnancies |
Glucose |
BloodPressure |
SkinThickness |
Insulin |
BMI |
DiabetesPedigreeFunction |
Age |
5 |
1 |
139 |
80 |
23 |
140 |
27.1 |
1.441 |
57 |
1 |
5 |
116 |
74 |
0 |
0 |
25.6 |
.0201 |
30 |
8 |
2 |
197 |
70 |
45 |
45 |
30.5 |
0.158 |
53 |
2 |
2 |
87 |
58 |
16 |
16 |
32.7 |
0.166 |
25 |
4 |
0 |
128 |
68 |
19 |
19 |
30.5 |
0.121 |
35 |
6 |
4 |
130 |
70 |
0 |
0 |
34.2 |
0.652 |
45 |
7 |
10 |
115 |
0 |
0 |
0 |
35.3 |
0.134 |
29 |
3 |
7 |
129 |
68 |
49 |
49 |
38.5 |
0.439 |
43 |
10 |
4 |
110 |
92 |
0 |
0 |
37.6 |
0.191 |
30 |
9 |
0 |
125 |
96 |
0 |
0 |
22.5 |
0.262 |
21 |
TD_OneClassSVMPredict Model
attribute |
predictor |
estimate |
value |
-3 |
Number of Observations |
10.00000 |
None |
-12 |
Nesterov |
NaN |
FALSE |
-16 |
Kernel |
NaN |
LINEAR |
0 |
(Intercept) |
0.094000 |
None |
5 |
Insulin |
0.988265 |
None |
-5 |
BIC |
20.723266 |
None |
-1 |
Loss Function |
NaN |
HINGE |
-9 |
Learning Rate (Initial) |
0.010000 |
None |
3 |
BloodPressure |
0.642372 |
None |
-7 |
Alpha |
0.000000 |
L2 |
7 |
DiabetesPedigreeFunction |
0.003578 |
None |
-17 |
OneClass SVM |
NaN |
TRUE |
1 |
Pregnancies |
0.033259 |
None |
-13 |
LocalSGD Iterations |
0.000000 |
None |
-11 |
Momentum |
0.000000 |
None |
-2 |
Loglik |
-0.000000 |
None |
-15 |
Intercept Scaling |
1.000000 |
None |
-8 |
Number of Iterations |
52.00000 |
CONVERGED |
-4 |
AIC |
18.00000 |
None |
6 |
BMI |
0.298855 |
None |
8 |
Age |
0.349694 |
None |
-10 |
Learning Rate (Final) |
0.010000 |
None |
4 |
SkinThickness |
.0144439 |
None |
-6 |
Regularization |
0.100000 |
ENABLED |
2 |
Glucose |
1.212525 |
None |
TD_OneClassSVMPredict Call
CREATE multiset table prediction AS (
SELECT * from TD_OneClassSVMPredict(
ON diabetes_test_scaled AS InputTable PARTITION BY ANY
ON oneclasssvm_model AS ModelTable DIMENSION
USING
IDColumn('id')
) AS dt
) WITH DATA;
TD_OneClassSVMPredict Test Data
ID |
Pregnancies |
Glucose |
BloodPressure |
SkinThickness |
Insulin |
BMI |
DiabetesPedigreeFunction |
Age |
20 |
2 |
122 |
70 |
27 |
0 |
36.8 |
0.340 |
27 |
17 |
1 |
97 |
66 |
15 |
140 |
23.2 |
0.487 |
22 |
12 |
1 |
168 |
88 |
29 |
0 |
35.0 |
0.905 |
52 |
19 |
10 |
101 |
76 |
48 |
180 |
32.9 |
0.171 |
63 |
18 |
9 |
145 |
88 |
34 |
0 |
30.3 |
0.771 |
25 |
13 |
5 |
139 |
80 |
35 |
160 |
31.6 |
0.361 |
33 |
15 |
10 |
119 |
80 |
0 |
0 |
32.4 |
0.141 |
49 |
11 |
6 |
125 |
78 |
31 |
0 |
27.6 |
0.565 |
21 |
14 |
2 |
99 |
52 |
15 |
94 |
24.6 |
0.637 |
27 |
16 |
3 |
103 |
70 |
30 |
48 |
27.6 |
0.730 |
|
TD_OneClassSVMPredict Output
ID |
prediction |
20 |
1.0 |
17 |
1.0 |
12 |
1.0 |
19 |
1.0 |
18 |
1.0 |
13 |
1.0 |
15 |
1.0 |
11 |
1.0 |
14 |
1.0 |
16 |
1.0 |
Count normal as opposed to outlier.
SELECT CASE "prediction"
WHEN 1 THEN 'normal'
WHEN 0 THEN 'outlier'
END SIGN,
COUNT (*) counter
from prediction
GROUP BY "prediction"