mirror of
https://github.com/Doctorado-ML/FImdlp.git
synced 2025-08-17 08:25:51 +00:00
Refactor & integrate proposal & clean
This commit is contained in:
@@ -1,25 +0,0 @@
|
|||||||
Cut point: 4.95 //5 -> 0 yPrev= 2* (5, 4.9)=4.95idxPrev106
|
|
||||||
Cut point: 5.05 //5.1 -> 0 yPrev= 1* (5.1, 5)=5.05idxPrev93
|
|
||||||
Cut point: 5.15 //5.2 -> 0 yPrev= 1* (5.2, 5.1)=5.15idxPrev98
|
|
||||||
Cut point: 5.25 //5.3 -> 0 yPrev= 1* (5.3, 5.2)=5.25idxPrev59
|
|
||||||
Cut point: 5.45 //5.5 -> 0 yPrev= 1* (5.5, 5.4)=5.45idxPrev84
|
|
||||||
Cut point: 5.65 //5.7 -> 0 yPrev= 2* (5.7, 5.6)=5.65idxPrev121
|
|
||||||
Cut point: 5.75 //5.8 -> 0 yPrev= 2* (5.8, 5.7)=5.75idxPrev113
|
|
||||||
Cut point: 5.85 //5.9 -> 1 yPrev= 2* (5.9, 5.8)=5.85idxPrev142
|
|
||||||
Cut point: 5.95 //6 -> 1 yPrev= 2* (6, 5.9)=5.95idxPrev149
|
|
||||||
Cut point: 6.05 //6.1 -> 1 yPrev= 2* (6.1, 6)=6.05idxPrev138
|
|
||||||
Cut point: 6.15 //6.2 -> 1 yPrev= 2* (6.2, 6.1)=6.15idxPrev134
|
|
||||||
Cut point: 6.25 //6.3 -> 1 yPrev= 2* (6.3, 6.2)=6.25idxPrev148
|
|
||||||
Cut point: 6.35 //6.4 -> 1 yPrev= 2* (6.4, 6.3)=6.35idxPrev146
|
|
||||||
Cut point: 6.45 //6.5 -> 1 yPrev= 2* (6.5, 6.4)=6.45idxPrev137
|
|
||||||
Cut point: 6.55 //6.6 -> 1 yPrev= 2* (6.6, 6.5)=6.55idxPrev147
|
|
||||||
Cut point: 6.75 //6.8 -> 1 yPrev= 2* (6.8, 6.7)=6.75idxPrev145
|
|
||||||
Cut point: 6.85 //6.9 -> 1 yPrev= 2* (6.9, 6.8)=6.85idxPrev143
|
|
||||||
Cut point: 6.95 //7 -> 1 yPrev= 2* (7, 6.9)=6.95idxPrev141
|
|
||||||
Cut point: 7.05 //7.1 -> 2 yPrev= 1* (7.1, 7)=7.05idxPrev50
|
|
||||||
[4.949999809265137, 5.050000190734863, 5.150000095367432, 5.25, 5.449999809265137,
|
|
||||||
5.650000095367432, 5.75, 5.850000858306885, 5.949999809265137, 6.050000190734863,
|
|
||||||
6.150000095367432, 6.25, 6.350000858306885, 6.449999809265137, 6.550000190734863,
|
|
||||||
6.75, 6.850000858306885, 6.949999809265137, 7.050000190734863]
|
|
||||||
|
|
||||||
Cuts calculados en python: [4.85, 5.25, 5.35, 6.25, 6.55, 6.95, 7.05]
|
|
212
feature0_new.txt
212
feature0_new.txt
@@ -1,212 +0,0 @@
|
|||||||
*idx=0 -> (-1, -1) Prev(4.3, 0) Elementos: 149
|
|
||||||
<idx=0 -> Prev(4.3, 0) Pivot(4.3, 0) Cur(4.3, 0)
|
|
||||||
>idx=1 -> Prev(4.3, 0) Pivot(4.3, 0) Cur(4.4, 0)
|
|
||||||
<idx=1 -> Prev(4.3, 0) Pivot(4.4, 0) Cur(4.4, 0)
|
|
||||||
>idx=2 -> Prev(4.3, 0) Pivot(4.4, 0) Cur(4.4, 0)
|
|
||||||
>idx=3 -> Prev(4.3, 0) Pivot(4.4, 0) Cur(4.4, 0)
|
|
||||||
>idx=4 -> Prev(4.3, 0) Pivot(4.4, 0) Cur(4.5, 0)
|
|
||||||
<idx=4 -> Prev(4.4, 0) Pivot(4.5, 0) Cur(4.5, 0)
|
|
||||||
>idx=5 -> Prev(4.4, 0) Pivot(4.5, 0) Cur(4.6, 0)
|
|
||||||
<idx=5 -> Prev(4.5, 0) Pivot(4.6, 0) Cur(4.6, 0)
|
|
||||||
>idx=6 -> Prev(4.5, 0) Pivot(4.6, 0) Cur(4.6, 0)
|
|
||||||
>idx=7 -> Prev(4.5, 0) Pivot(4.6, 0) Cur(4.6, 0)
|
|
||||||
>idx=8 -> Prev(4.5, 0) Pivot(4.6, 0) Cur(4.6, 0)
|
|
||||||
>idx=9 -> Prev(4.5, 0) Pivot(4.6, 0) Cur(4.7, 0)
|
|
||||||
<idx=9 -> Prev(4.6, 0) Pivot(4.7, 0) Cur(4.7, 0)
|
|
||||||
>idx=10 -> Prev(4.6, 0) Pivot(4.7, 0) Cur(4.7, 0)
|
|
||||||
>idx=11 -> Prev(4.6, 0) Pivot(4.7, 0) Cur(4.8, 0)
|
|
||||||
<idx=11 -> Prev(4.7, 0) Pivot(4.8, 0) Cur(4.8, 0)
|
|
||||||
>idx=12 -> Prev(4.7, 0) Pivot(4.8, 0) Cur(4.8, 0)
|
|
||||||
>idx=13 -> Prev(4.7, 0) Pivot(4.8, 0) Cur(4.8, 0)
|
|
||||||
>idx=14 -> Prev(4.7, 0) Pivot(4.8, 0) Cur(4.8, 0)
|
|
||||||
>idx=15 -> Prev(4.7, 0) Pivot(4.8, 0) Cur(4.8, 0)
|
|
||||||
>idx=16 -> Prev(4.7, 0) Pivot(4.8, 0) Cur(4.9, 0)
|
|
||||||
<idx=16 -> Prev(4.8, 0) Pivot(4.9, 0) Cur(4.9, 0)
|
|
||||||
>idx=17 -> Prev(4.8, 0) Pivot(4.9, 0) Cur(4.9, 0)
|
|
||||||
>idx=18 -> Prev(4.8, 0) Pivot(4.9, 0) Cur(4.9, 0)
|
|
||||||
>idx=19 -> Prev(4.8, 0) Pivot(4.9, 0) Cur(4.9, 0)
|
|
||||||
>idx=20 -> Prev(4.8, 0) Pivot(4.9, -1) Cur(4.9, 1)
|
|
||||||
>idx=21 -> Prev(4.8, 0) Pivot(4.9, -1) Cur(4.9, 2)
|
|
||||||
>idx=22 -> Prev(4.8, 0) Pivot(4.9, -1) Cur(5.0, 0)
|
|
||||||
Cutpoint idx=22 Cur(5.0, 0) Prev(4.8, 0) Pivot(4.9, -1) = 4.9
|
|
||||||
<idx=22 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=23 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=24 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=25 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=26 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=27 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=28 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=29 -> Prev(4.9, -1) Pivot(5.0, 0) Cur(5.0, 0)
|
|
||||||
>idx=30 -> Prev(4.9, -1) Pivot(5.0, -1) Cur(5.0, 1)
|
|
||||||
>idx=31 -> Prev(4.9, -1) Pivot(5.0, -1) Cur(5.0, 1)
|
|
||||||
>idx=32 -> Prev(4.9, -1) Pivot(5.0, -1) Cur(5.1, 0)
|
|
||||||
Cutpoint idx=32 Cur(5.1, 0) Prev(4.9, -1) Pivot(5.0, -1) = 5.0
|
|
||||||
<idx=32 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=33 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=34 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=35 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=36 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=37 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=38 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=39 -> Prev(5.0, -1) Pivot(5.1, 0) Cur(5.1, 0)
|
|
||||||
>idx=40 -> Prev(5.0, -1) Pivot(5.1, -1) Cur(5.1, 1)
|
|
||||||
>idx=41 -> Prev(5.0, -1) Pivot(5.1, -1) Cur(5.2, 0)
|
|
||||||
Cutpoint idx=41 Cur(5.2, 0) Prev(5.0, -1) Pivot(5.1, -1) = 5.1
|
|
||||||
<idx=41 -> Prev(5.1, -1) Pivot(5.2, 0) Cur(5.2, 0)
|
|
||||||
>idx=42 -> Prev(5.1, -1) Pivot(5.2, 0) Cur(5.2, 0)
|
|
||||||
>idx=43 -> Prev(5.1, -1) Pivot(5.2, 0) Cur(5.2, 0)
|
|
||||||
>idx=44 -> Prev(5.1, -1) Pivot(5.2, -1) Cur(5.2, 1)
|
|
||||||
>idx=45 -> Prev(5.1, -1) Pivot(5.2, -1) Cur(5.3, 0)
|
|
||||||
Cutpoint idx=45 Cur(5.3, 0) Prev(5.1, -1) Pivot(5.2, -1) = 5.2
|
|
||||||
<idx=45 -> Prev(5.2, -1) Pivot(5.3, 0) Cur(5.3, 0)
|
|
||||||
>idx=46 -> Prev(5.2, -1) Pivot(5.3, 0) Cur(5.4, 0)
|
|
||||||
Cutpoint idx=46 Cur(5.4, 0) Prev(5.2, -1) Pivot(5.3, 0) = 5.3
|
|
||||||
<idx=46 -> Prev(5.3, 0) Pivot(5.4, 0) Cur(5.4, 0)
|
|
||||||
>idx=47 -> Prev(5.3, 0) Pivot(5.4, 0) Cur(5.4, 0)
|
|
||||||
>idx=48 -> Prev(5.3, 0) Pivot(5.4, 0) Cur(5.4, 0)
|
|
||||||
>idx=49 -> Prev(5.3, 0) Pivot(5.4, 0) Cur(5.4, 0)
|
|
||||||
>idx=50 -> Prev(5.3, 0) Pivot(5.4, 0) Cur(5.4, 0)
|
|
||||||
>idx=51 -> Prev(5.3, 0) Pivot(5.4, -1) Cur(5.4, 1)
|
|
||||||
>idx=52 -> Prev(5.3, 0) Pivot(5.4, -1) Cur(5.5, 0)
|
|
||||||
Cutpoint idx=52 Cur(5.5, 0) Prev(5.3, 0) Pivot(5.4, -1) = 5.4
|
|
||||||
<idx=52 -> Prev(5.4, -1) Pivot(5.5, 0) Cur(5.5, 0)
|
|
||||||
>idx=53 -> Prev(5.4, -1) Pivot(5.5, 0) Cur(5.5, 0)
|
|
||||||
>idx=54 -> Prev(5.4, -1) Pivot(5.5, -1) Cur(5.5, 1)
|
|
||||||
>idx=55 -> Prev(5.4, -1) Pivot(5.5, -1) Cur(5.5, 1)
|
|
||||||
>idx=56 -> Prev(5.4, -1) Pivot(5.5, -1) Cur(5.5, 1)
|
|
||||||
>idx=57 -> Prev(5.4, -1) Pivot(5.5, -1) Cur(5.5, 1)
|
|
||||||
>idx=58 -> Prev(5.4, -1) Pivot(5.5, -1) Cur(5.5, 1)
|
|
||||||
>idx=59 -> Prev(5.4, -1) Pivot(5.5, -1) Cur(5.6, 1)
|
|
||||||
Cutpoint idx=59 Cur(5.6, 1) Prev(5.4, -1) Pivot(5.5, -1) = 5.5
|
|
||||||
<idx=59 -> Prev(5.5, -1) Pivot(5.6, 1) Cur(5.6, 1)
|
|
||||||
>idx=60 -> Prev(5.5, -1) Pivot(5.6, 1) Cur(5.6, 1)
|
|
||||||
>idx=61 -> Prev(5.5, -1) Pivot(5.6, 1) Cur(5.6, 1)
|
|
||||||
>idx=62 -> Prev(5.5, -1) Pivot(5.6, 1) Cur(5.6, 1)
|
|
||||||
>idx=63 -> Prev(5.5, -1) Pivot(5.6, 1) Cur(5.6, 1)
|
|
||||||
>idx=64 -> Prev(5.5, -1) Pivot(5.6, -1) Cur(5.6, 2)
|
|
||||||
>idx=65 -> Prev(5.5, -1) Pivot(5.6, -1) Cur(5.7, 0)
|
|
||||||
Cutpoint idx=65 Cur(5.7, 0) Prev(5.5, -1) Pivot(5.6, -1) = 5.6
|
|
||||||
<idx=65 -> Prev(5.6, -1) Pivot(5.7, 0) Cur(5.7, 0)
|
|
||||||
>idx=66 -> Prev(5.6, -1) Pivot(5.7, 0) Cur(5.7, 0)
|
|
||||||
>idx=67 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.7, 1)
|
|
||||||
>idx=68 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.7, 1)
|
|
||||||
>idx=69 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.7, 1)
|
|
||||||
>idx=70 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.7, 1)
|
|
||||||
>idx=71 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.7, 1)
|
|
||||||
>idx=72 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.7, 2)
|
|
||||||
>idx=73 -> Prev(5.6, -1) Pivot(5.7, -1) Cur(5.8, 0)
|
|
||||||
Cutpoint idx=73 Cur(5.8, 0) Prev(5.6, -1) Pivot(5.7, -1) = 5.7
|
|
||||||
<idx=73 -> Prev(5.7, -1) Pivot(5.8, 0) Cur(5.8, 0)
|
|
||||||
>idx=74 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.8, 1)
|
|
||||||
>idx=75 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.8, 1)
|
|
||||||
>idx=76 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.8, 1)
|
|
||||||
>idx=77 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.8, 2)
|
|
||||||
>idx=78 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.8, 2)
|
|
||||||
>idx=79 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.8, 2)
|
|
||||||
>idx=80 -> Prev(5.7, -1) Pivot(5.8, -1) Cur(5.9, 1)
|
|
||||||
Cutpoint idx=80 Cur(5.9, 1) Prev(5.7, -1) Pivot(5.8, -1) = 5.8
|
|
||||||
<idx=80 -> Prev(5.8, -1) Pivot(5.9, 1) Cur(5.9, 1)
|
|
||||||
>idx=81 -> Prev(5.8, -1) Pivot(5.9, 1) Cur(5.9, 1)
|
|
||||||
>idx=82 -> Prev(5.8, -1) Pivot(5.9, -1) Cur(5.9, 2)
|
|
||||||
>idx=83 -> Prev(5.8, -1) Pivot(5.9, -1) Cur(6.0, 1)
|
|
||||||
Cutpoint idx=83 Cur(6.0, 1) Prev(5.8, -1) Pivot(5.9, -1) = 5.9
|
|
||||||
<idx=83 -> Prev(5.9, -1) Pivot(6.0, 1) Cur(6.0, 1)
|
|
||||||
>idx=84 -> Prev(5.9, -1) Pivot(6.0, 1) Cur(6.0, 1)
|
|
||||||
>idx=85 -> Prev(5.9, -1) Pivot(6.0, 1) Cur(6.0, 1)
|
|
||||||
>idx=86 -> Prev(5.9, -1) Pivot(6.0, 1) Cur(6.0, 1)
|
|
||||||
>idx=87 -> Prev(5.9, -1) Pivot(6.0, -1) Cur(6.0, 2)
|
|
||||||
>idx=88 -> Prev(5.9, -1) Pivot(6.0, -1) Cur(6.0, 2)
|
|
||||||
>idx=89 -> Prev(5.9, -1) Pivot(6.0, -1) Cur(6.1, 1)
|
|
||||||
Cutpoint idx=89 Cur(6.1, 1) Prev(5.9, -1) Pivot(6.0, -1) = 6.0
|
|
||||||
<idx=89 -> Prev(6.0, -1) Pivot(6.1, 1) Cur(6.1, 1)
|
|
||||||
>idx=90 -> Prev(6.0, -1) Pivot(6.1, 1) Cur(6.1, 1)
|
|
||||||
>idx=91 -> Prev(6.0, -1) Pivot(6.1, 1) Cur(6.1, 1)
|
|
||||||
>idx=92 -> Prev(6.0, -1) Pivot(6.1, 1) Cur(6.1, 1)
|
|
||||||
>idx=93 -> Prev(6.0, -1) Pivot(6.1, -1) Cur(6.1, 2)
|
|
||||||
>idx=94 -> Prev(6.0, -1) Pivot(6.1, -1) Cur(6.1, 2)
|
|
||||||
>idx=95 -> Prev(6.0, -1) Pivot(6.1, -1) Cur(6.2, 1)
|
|
||||||
Cutpoint idx=95 Cur(6.2, 1) Prev(6.0, -1) Pivot(6.1, -1) = 6.1
|
|
||||||
<idx=95 -> Prev(6.1, -1) Pivot(6.2, 1) Cur(6.2, 1)
|
|
||||||
>idx=96 -> Prev(6.1, -1) Pivot(6.2, 1) Cur(6.2, 1)
|
|
||||||
>idx=97 -> Prev(6.1, -1) Pivot(6.2, -1) Cur(6.2, 2)
|
|
||||||
>idx=98 -> Prev(6.1, -1) Pivot(6.2, -1) Cur(6.2, 2)
|
|
||||||
>idx=99 -> Prev(6.1, -1) Pivot(6.2, -1) Cur(6.3, 1)
|
|
||||||
Cutpoint idx=99 Cur(6.3, 1) Prev(6.1, -1) Pivot(6.2, -1) = 6.2
|
|
||||||
<idx=99 -> Prev(6.2, -1) Pivot(6.3, 1) Cur(6.3, 1)
|
|
||||||
>idx=100 -> Prev(6.2, -1) Pivot(6.3, 1) Cur(6.3, 1)
|
|
||||||
>idx=101 -> Prev(6.2, -1) Pivot(6.3, 1) Cur(6.3, 1)
|
|
||||||
>idx=102 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.3, 2)
|
|
||||||
>idx=103 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.3, 2)
|
|
||||||
>idx=104 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.3, 2)
|
|
||||||
>idx=105 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.3, 2)
|
|
||||||
>idx=106 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.3, 2)
|
|
||||||
>idx=107 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.3, 2)
|
|
||||||
>idx=108 -> Prev(6.2, -1) Pivot(6.3, -1) Cur(6.4, 1)
|
|
||||||
Cutpoint idx=108 Cur(6.4, 1) Prev(6.2, -1) Pivot(6.3, -1) = 6.3
|
|
||||||
<idx=108 -> Prev(6.3, -1) Pivot(6.4, 1) Cur(6.4, 1)
|
|
||||||
>idx=109 -> Prev(6.3, -1) Pivot(6.4, 1) Cur(6.4, 1)
|
|
||||||
>idx=110 -> Prev(6.3, -1) Pivot(6.4, -1) Cur(6.4, 2)
|
|
||||||
>idx=111 -> Prev(6.3, -1) Pivot(6.4, -1) Cur(6.4, 2)
|
|
||||||
>idx=112 -> Prev(6.3, -1) Pivot(6.4, -1) Cur(6.4, 2)
|
|
||||||
>idx=113 -> Prev(6.3, -1) Pivot(6.4, -1) Cur(6.4, 2)
|
|
||||||
>idx=114 -> Prev(6.3, -1) Pivot(6.4, -1) Cur(6.4, 2)
|
|
||||||
>idx=115 -> Prev(6.3, -1) Pivot(6.4, -1) Cur(6.5, 1)
|
|
||||||
Cutpoint idx=115 Cur(6.5, 1) Prev(6.3, -1) Pivot(6.4, -1) = 6.4
|
|
||||||
<idx=115 -> Prev(6.4, -1) Pivot(6.5, 1) Cur(6.5, 1)
|
|
||||||
>idx=116 -> Prev(6.4, -1) Pivot(6.5, -1) Cur(6.5, 2)
|
|
||||||
>idx=117 -> Prev(6.4, -1) Pivot(6.5, -1) Cur(6.5, 2)
|
|
||||||
>idx=118 -> Prev(6.4, -1) Pivot(6.5, -1) Cur(6.5, 2)
|
|
||||||
>idx=119 -> Prev(6.4, -1) Pivot(6.5, -1) Cur(6.5, 2)
|
|
||||||
>idx=120 -> Prev(6.4, -1) Pivot(6.5, -1) Cur(6.6, 1)
|
|
||||||
Cutpoint idx=120 Cur(6.6, 1) Prev(6.4, -1) Pivot(6.5, -1) = 6.5
|
|
||||||
<idx=120 -> Prev(6.5, -1) Pivot(6.6, 1) Cur(6.6, 1)
|
|
||||||
>idx=121 -> Prev(6.5, -1) Pivot(6.6, 1) Cur(6.6, 1)
|
|
||||||
>idx=122 -> Prev(6.5, -1) Pivot(6.6, 1) Cur(6.7, 1)
|
|
||||||
Cutpoint idx=122 Cur(6.7, 1) Prev(6.5, -1) Pivot(6.6, 1) = 6.6
|
|
||||||
<idx=122 -> Prev(6.6, 1) Pivot(6.7, 1) Cur(6.7, 1)
|
|
||||||
>idx=123 -> Prev(6.6, 1) Pivot(6.7, 1) Cur(6.7, 1)
|
|
||||||
>idx=124 -> Prev(6.6, 1) Pivot(6.7, 1) Cur(6.7, 1)
|
|
||||||
>idx=125 -> Prev(6.6, 1) Pivot(6.7, -1) Cur(6.7, 2)
|
|
||||||
>idx=126 -> Prev(6.6, 1) Pivot(6.7, -1) Cur(6.7, 2)
|
|
||||||
>idx=127 -> Prev(6.6, 1) Pivot(6.7, -1) Cur(6.7, 2)
|
|
||||||
>idx=128 -> Prev(6.6, 1) Pivot(6.7, -1) Cur(6.7, 2)
|
|
||||||
>idx=129 -> Prev(6.6, 1) Pivot(6.7, -1) Cur(6.7, 2)
|
|
||||||
>idx=130 -> Prev(6.6, 1) Pivot(6.7, -1) Cur(6.8, 1)
|
|
||||||
Cutpoint idx=130 Cur(6.8, 1) Prev(6.6, 1) Pivot(6.7, -1) = 6.7
|
|
||||||
<idx=130 -> Prev(6.7, -1) Pivot(6.8, 1) Cur(6.8, 1)
|
|
||||||
>idx=131 -> Prev(6.7, -1) Pivot(6.8, -1) Cur(6.8, 2)
|
|
||||||
>idx=132 -> Prev(6.7, -1) Pivot(6.8, -1) Cur(6.8, 2)
|
|
||||||
>idx=133 -> Prev(6.7, -1) Pivot(6.8, -1) Cur(6.9, 1)
|
|
||||||
Cutpoint idx=133 Cur(6.9, 1) Prev(6.7, -1) Pivot(6.8, -1) = 6.8
|
|
||||||
<idx=133 -> Prev(6.8, -1) Pivot(6.9, 1) Cur(6.9, 1)
|
|
||||||
>idx=134 -> Prev(6.8, -1) Pivot(6.9, -1) Cur(6.9, 2)
|
|
||||||
>idx=135 -> Prev(6.8, -1) Pivot(6.9, -1) Cur(6.9, 2)
|
|
||||||
>idx=136 -> Prev(6.8, -1) Pivot(6.9, -1) Cur(6.9, 2)
|
|
||||||
>idx=137 -> Prev(6.8, -1) Pivot(6.9, -1) Cur(7.0, 1)
|
|
||||||
Cutpoint idx=137 Cur(7.0, 1) Prev(6.8, -1) Pivot(6.9, -1) = 6.9
|
|
||||||
<idx=137 -> Prev(6.9, -1) Pivot(7.0, 1) Cur(7.0, 1)
|
|
||||||
>idx=138 -> Prev(6.9, -1) Pivot(7.0, 1) Cur(7.1, 2)
|
|
||||||
Cutpoint idx=138 Cur(7.1, 2) Prev(6.9, -1) Pivot(7.0, 1) = 7.0
|
|
||||||
<idx=138 -> Prev(7.0, 1) Pivot(7.1, 2) Cur(7.1, 2)
|
|
||||||
>idx=139 -> Prev(7.0, 1) Pivot(7.1, 2) Cur(7.2, 2)
|
|
||||||
Cutpoint idx=139 Cur(7.2, 2) Prev(7.0, 1) Pivot(7.1, 2) = 7.1
|
|
||||||
<idx=139 -> Prev(7.1, 2) Pivot(7.2, 2) Cur(7.2, 2)
|
|
||||||
>idx=140 -> Prev(7.1, 2) Pivot(7.2, 2) Cur(7.2, 2)
|
|
||||||
>idx=141 -> Prev(7.1, 2) Pivot(7.2, 2) Cur(7.2, 2)
|
|
||||||
>idx=142 -> Prev(7.1, 2) Pivot(7.2, 2) Cur(7.3, 2)
|
|
||||||
<idx=142 -> Prev(7.2, 2) Pivot(7.3, 2) Cur(7.3, 2)
|
|
||||||
>idx=143 -> Prev(7.2, 2) Pivot(7.3, 2) Cur(7.4, 2)
|
|
||||||
<idx=143 -> Prev(7.3, 2) Pivot(7.4, 2) Cur(7.4, 2)
|
|
||||||
>idx=144 -> Prev(7.3, 2) Pivot(7.4, 2) Cur(7.6, 2)
|
|
||||||
<idx=144 -> Prev(7.4, 2) Pivot(7.6, 2) Cur(7.6, 2)
|
|
||||||
>idx=145 -> Prev(7.4, 2) Pivot(7.6, 2) Cur(7.7, 2)
|
|
||||||
<idx=145 -> Prev(7.6, 2) Pivot(7.7, 2) Cur(7.7, 2)
|
|
||||||
>idx=146 -> Prev(7.6, 2) Pivot(7.7, 2) Cur(7.7, 2)
|
|
||||||
>idx=147 -> Prev(7.6, 2) Pivot(7.7, 2) Cur(7.7, 2)
|
|
||||||
>idx=148 -> Prev(7.6, 2) Pivot(7.7, 2) Cur(7.7, 2)
|
|
||||||
>idx=149 -> Prev(7.6, 2) Pivot(7.7, 2) Cur(7.9, 2)
|
|
||||||
[4.900000095367432, 5.0, 5.099999904632568, 5.199999809265137, 5.300000190734863,
|
|
||||||
5.400000095367432, 5.5, 5.599999904632568, 5.699999809265137, 5.800000190734863,
|
|
||||||
5.900000095367432, 6.0, 6.099999904632568, 6.199999809265137, 6.300000190734863,
|
|
||||||
6.400000095367432, 6.5, 6.599999904632568, 6.699999809265137, 6.800000190734863,
|
|
||||||
6.900000095367432, 7.0, 7.099999904632568]
|
|
@@ -28,7 +28,8 @@ namespace mdlp {
|
|||||||
}
|
}
|
||||||
indices = sortIndices(X_);
|
indices = sortIndices(X_);
|
||||||
metrics.setData(y, indices);
|
metrics.setData(y, indices);
|
||||||
computeCutPoints(0, X.size());
|
//computeCutPoints(0, X.size());
|
||||||
|
computeCutPointsProposal();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
void CPPFImdlp::computeCutPoints(size_t start, size_t end)
|
void CPPFImdlp::computeCutPoints(size_t start, size_t end)
|
||||||
@@ -50,6 +51,64 @@ namespace mdlp {
|
|||||||
computeCutPoints(start, cut);
|
computeCutPoints(start, cut);
|
||||||
computeCutPoints(cut, end);
|
computeCutPoints(cut, end);
|
||||||
}
|
}
|
||||||
|
void CPPFImdlp::computeCutPointsOriginal(size_t start, size_t end)
|
||||||
|
{
|
||||||
|
size_t idx;
|
||||||
|
precision_t cut;
|
||||||
|
if (end - start < 2)
|
||||||
|
return;
|
||||||
|
cut = getCandidate(start, end);
|
||||||
|
if (cut == -1)
|
||||||
|
return;
|
||||||
|
if (mdlp(start, cut, end)) {
|
||||||
|
cutPoints.push_back((X[indices[cut]] + X[indices[cut - 1]]) / 2);
|
||||||
|
}
|
||||||
|
computeCutPointsOriginal(start, cut);
|
||||||
|
computeCutPointsOriginal(cut, end);
|
||||||
|
}
|
||||||
|
void CPPFImdlp::computeCutPointsProposal()
|
||||||
|
{
|
||||||
|
precision_t xPrev, xCur, xPivot, cutPoint;
|
||||||
|
int yPrev, yCur, yPivot;
|
||||||
|
size_t idx, numElements, start;
|
||||||
|
|
||||||
|
xCur = xPrev = X[indices[0]];
|
||||||
|
yCur = yPrev = y[indices[0]];
|
||||||
|
numElements = indices.size() - 1;
|
||||||
|
idx = start = 0;
|
||||||
|
bool firstCutPoint = true;
|
||||||
|
if (debug)
|
||||||
|
printf("*idx=%lu -> (-1, -1) Prev(%3.1f, %d) Elementos: %lu\n", idx, xCur, yCur, numElements);
|
||||||
|
while (idx < numElements) {
|
||||||
|
xPivot = xCur;
|
||||||
|
yPivot = yCur;
|
||||||
|
if (debug)
|
||||||
|
printf("<idx=%lu -> Prev(%3.1f, %d) Pivot(%3.1f, %d) Cur(%3.1f, %d) \n", idx, xPrev, yPrev, xPivot, yPivot, xCur, yCur);
|
||||||
|
// Read the same values and check class changes
|
||||||
|
do {
|
||||||
|
idx++;
|
||||||
|
xCur = X[indices[idx]];
|
||||||
|
yCur = y[indices[idx]];
|
||||||
|
if (yCur != yPivot && xCur == xPivot) {
|
||||||
|
yPivot = -1;
|
||||||
|
}
|
||||||
|
if (debug)
|
||||||
|
printf(">idx=%lu -> Prev(%3.1f, %d) Pivot(%3.1f, %d) Cur(%3.1f, %d) \n", idx, xPrev, yPrev, xPivot, yPivot, xCur, yCur);
|
||||||
|
}
|
||||||
|
while (idx < numElements && xCur == xPivot);
|
||||||
|
// Check if the class changed and there are more than 1 element
|
||||||
|
if ((idx - start > 1) && (yPivot == -1 || yPrev != yCur) && mdlp(start, idx, indices.size())) {
|
||||||
|
start = idx;
|
||||||
|
cutPoint = (xPrev + xCur) / 2;
|
||||||
|
if (debug) {
|
||||||
|
printf("Cutpoint idx=%lu Cur(%3.1f, %d) Prev(%3.1f, %d) Pivot(%3.1f, %d) = %3.1g \n", idx, xCur, yCur, xPrev, yPrev, xPivot, yPivot, cutPoint);
|
||||||
|
}
|
||||||
|
cutPoints.push_back(cutPoint);
|
||||||
|
}
|
||||||
|
yPrev = yPivot;
|
||||||
|
xPrev = xPivot;
|
||||||
|
}
|
||||||
|
}
|
||||||
long int CPPFImdlp::getCandidate(size_t start, size_t end)
|
long int CPPFImdlp::getCandidate(size_t start, size_t end)
|
||||||
{
|
{
|
||||||
long int candidate = -1, elements = end - start;
|
long int candidate = -1, elements = end - start;
|
||||||
|
@@ -19,6 +19,11 @@ namespace mdlp {
|
|||||||
long int getCandidate(size_t, size_t);
|
long int getCandidate(size_t, size_t);
|
||||||
bool mdlp(size_t, size_t, size_t);
|
bool mdlp(size_t, size_t, size_t);
|
||||||
|
|
||||||
|
// Original algorithm
|
||||||
|
void computeCutPointsOriginal(size_t, size_t);
|
||||||
|
bool goodCut(size_t, size_t, size_t);
|
||||||
|
void computeCutPointsProposal();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPPFImdlp();
|
CPPFImdlp();
|
||||||
CPPFImdlp(bool, bool debug = false);
|
CPPFImdlp(bool, bool debug = false);
|
||||||
|
@@ -1,286 +0,0 @@
|
|||||||
#include "CPPFImdlp.h"
|
|
||||||
#include <numeric>
|
|
||||||
#include <iostream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include "Metrics.h"
|
|
||||||
|
|
||||||
namespace mdlp {
|
|
||||||
ostream& operator << (ostream& os, const cutPoint_t& cut)
|
|
||||||
{
|
|
||||||
os << cut.classNumber << " -> (" << cut.start << ", " << cut.end <<
|
|
||||||
") - (" << cut.fromValue << ", " << cut.toValue << ") "
|
|
||||||
<< endl;
|
|
||||||
return os;
|
|
||||||
|
|
||||||
}
|
|
||||||
CPPFImdlp::CPPFImdlp(): proposal(true), precision(6), debug(false)
|
|
||||||
{
|
|
||||||
divider = pow(10, precision);
|
|
||||||
numClasses = 0;
|
|
||||||
}
|
|
||||||
CPPFImdlp::CPPFImdlp(bool proposal, int precision, bool debug): proposal(proposal), precision(precision), debug(debug)
|
|
||||||
{
|
|
||||||
divider = pow(10, precision);
|
|
||||||
numClasses = 0;
|
|
||||||
}
|
|
||||||
CPPFImdlp::~CPPFImdlp()
|
|
||||||
= default;
|
|
||||||
samples CPPFImdlp::getCutPoints()
|
|
||||||
{
|
|
||||||
samples output(cutPoints.size());
|
|
||||||
::transform(cutPoints.begin(), cutPoints.end(), output.begin(),
|
|
||||||
[](cutPoint_t cut) { return cut.toValue; });
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
labels CPPFImdlp::getDiscretizedValues()
|
|
||||||
{
|
|
||||||
return xDiscretized;
|
|
||||||
}
|
|
||||||
CPPFImdlp& CPPFImdlp::fit(samples& X_, labels& y_)
|
|
||||||
{
|
|
||||||
X = X_;
|
|
||||||
y = y_;
|
|
||||||
if (X.size() != y.size()) {
|
|
||||||
throw invalid_argument("X and y must have the same size");
|
|
||||||
}
|
|
||||||
if (X.size() == 0 || y.size() == 0) {
|
|
||||||
throw invalid_argument("X and y must have at least one element");
|
|
||||||
}
|
|
||||||
indices = sortIndices(X_);
|
|
||||||
xDiscretized = labels(X.size(), -1);
|
|
||||||
numClasses = Metrics::numClasses(y, indices, 0, X.size());
|
|
||||||
|
|
||||||
if (proposal) {
|
|
||||||
computeCutPointsProposal();
|
|
||||||
} else {
|
|
||||||
computeCutPointsOriginal();
|
|
||||||
}
|
|
||||||
filterCutPoints();
|
|
||||||
// Apply cut points to the input vector
|
|
||||||
for (auto cut : cutPoints) {
|
|
||||||
for (size_t i = cut.start; i < cut.end; i++) {
|
|
||||||
xDiscretized[indices[i]] = cut.classNumber;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
bool CPPFImdlp::evaluateCutPoint(cutPoint_t rest, cutPoint_t candidate)
|
|
||||||
{
|
|
||||||
int k, k1, k2;
|
|
||||||
precision_t ig, delta;
|
|
||||||
precision_t ent, ent1, ent2;
|
|
||||||
auto N = precision_t(rest.end - rest.start);
|
|
||||||
if (N < 2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
k = Metrics::numClasses(y, indices, rest.start, rest.end);
|
|
||||||
k1 = Metrics::numClasses(y, indices, rest.start, candidate.end);
|
|
||||||
k2 = Metrics::numClasses(y, indices, candidate.end, rest.end);
|
|
||||||
ent = Metrics::entropy(y, indices, rest.start, rest.end, numClasses);
|
|
||||||
ent1 = Metrics::entropy(y, indices, rest.start, candidate.end, numClasses);
|
|
||||||
ent2 = Metrics::entropy(y, indices, candidate.end, rest.end, numClasses);
|
|
||||||
ig = Metrics::informationGain(y, indices, rest.start, rest.end, candidate.end, numClasses);
|
|
||||||
delta = log2(pow(3, precision_t(k)) - 2) - (precision_t(k) * ent - precision_t(k1) * ent1 - precision_t(k2) * ent2);
|
|
||||||
precision_t term = 1 / N * (log2(N - 1) + delta);
|
|
||||||
if (debug) {
|
|
||||||
cout << "Rest: " << rest;
|
|
||||||
cout << "Candidate: " << candidate;
|
|
||||||
cout << "k=" << k << " k1=" << k1 << " k2=" << k2 << " ent=" << ent << " ent1=" << ent1 << " ent2=" << ent2 << endl;
|
|
||||||
cout << "ig=" << ig << " delta=" << delta << " N " << N << " term " << term << endl;
|
|
||||||
}
|
|
||||||
return (ig > term);
|
|
||||||
}
|
|
||||||
void CPPFImdlp::filterCutPoints()
|
|
||||||
{
|
|
||||||
cutPoints_t filtered;
|
|
||||||
cutPoint_t rest, item;
|
|
||||||
int classNumber = 0;
|
|
||||||
|
|
||||||
rest.start = 0;
|
|
||||||
rest.end = X.size();
|
|
||||||
rest.fromValue = numeric_limits<precision_t>::lowest();
|
|
||||||
rest.toValue = numeric_limits<precision_t>::max();
|
|
||||||
rest.classNumber = classNumber;
|
|
||||||
bool first = true;
|
|
||||||
for (size_t index = 0; index < size_t(cutPoints.size()); index++) {
|
|
||||||
item = cutPoints[index];
|
|
||||||
if (evaluateCutPoint(rest, item)) {
|
|
||||||
if (debug)
|
|
||||||
cout << "Accepted: " << item << endl;
|
|
||||||
//Assign class number to the interval (cutpoint)
|
|
||||||
item.classNumber = classNumber++;
|
|
||||||
filtered.push_back(item);
|
|
||||||
first = false;
|
|
||||||
rest.start = item.end;
|
|
||||||
} else {
|
|
||||||
if (debug)
|
|
||||||
cout << "Rejected: " << item << endl;
|
|
||||||
if (index != size_t(cutPoints.size()) - 1) {
|
|
||||||
// Try to merge the rejected cutpoint with the next one
|
|
||||||
if (first) {
|
|
||||||
cutPoints[index + 1].fromValue = numeric_limits<precision_t>::lowest();
|
|
||||||
cutPoints[index + 1].start = indices[0];
|
|
||||||
} else {
|
|
||||||
cutPoints[index + 1].fromValue = item.fromValue;
|
|
||||||
cutPoints[index + 1].start = item.start;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!first) {
|
|
||||||
filtered.back().toValue = numeric_limits<precision_t>::max();
|
|
||||||
filtered.back().end = X.size() - 1;
|
|
||||||
} else {
|
|
||||||
filtered.push_back(rest);
|
|
||||||
}
|
|
||||||
cutPoints = filtered;
|
|
||||||
}
|
|
||||||
void CPPFImdlp::computeCutPointsProposal()
|
|
||||||
{
|
|
||||||
cutPoints_t cutPts;
|
|
||||||
cutPoint_t cutPoint;
|
|
||||||
precision_t xPrev, xCur, xPivot;
|
|
||||||
int yPrev, yCur, yPivot;
|
|
||||||
size_t idx, numElements, start;
|
|
||||||
|
|
||||||
xCur = xPrev = X[indices[0]];
|
|
||||||
yCur = yPrev = y[indices[0]];
|
|
||||||
numElements = indices.size() - 1;
|
|
||||||
idx = start = 0;
|
|
||||||
bool firstCutPoint = true;
|
|
||||||
if (debug)
|
|
||||||
printf("*idx=%lu -> (-1, -1) Prev(%3.1f, %d) Elementos: %lu\n", idx, xCur, yCur, numElements);
|
|
||||||
while (idx < numElements) {
|
|
||||||
xPivot = xCur;
|
|
||||||
yPivot = yCur;
|
|
||||||
if (debug)
|
|
||||||
printf("<idx=%lu -> Prev(%3.1f, %d) Pivot(%3.1f, %d) Cur(%3.1f, %d) \n", idx, xPrev, yPrev, xPivot, yPivot, xCur, yCur);
|
|
||||||
// Read the same values and check class changes
|
|
||||||
do {
|
|
||||||
idx++;
|
|
||||||
xCur = X[indices[idx]];
|
|
||||||
yCur = y[indices[idx]];
|
|
||||||
if (yCur != yPivot && xCur == xPivot) {
|
|
||||||
yPivot = -1;
|
|
||||||
}
|
|
||||||
if (debug)
|
|
||||||
printf(">idx=%lu -> Prev(%3.1f, %d) Pivot(%3.1f, %d) Cur(%3.1f, %d) \n", idx, xPrev, yPrev, xPivot, yPivot, xCur, yCur);
|
|
||||||
}
|
|
||||||
while (idx < numElements && xCur == xPivot);
|
|
||||||
// Check if the class changed and there are more than 1 element
|
|
||||||
if ((idx - start > 1) && (yPivot == -1 || yPrev != yCur) && goodCut(start, idx, numElements + 1)) {
|
|
||||||
// Must we add the entropy criteria here?
|
|
||||||
// if (totalEntropy - (entropyLeft + entropyRight) > 0) { Accept cut point }
|
|
||||||
cutPoint.start = start;
|
|
||||||
cutPoint.end = idx;
|
|
||||||
start = idx;
|
|
||||||
cutPoint.fromValue = firstCutPoint ? numeric_limits<precision_t>::lowest() : cutPts.back().toValue;
|
|
||||||
cutPoint.toValue = (xPrev + xCur) / 2;
|
|
||||||
cutPoint.classNumber = -1;
|
|
||||||
firstCutPoint = false;
|
|
||||||
if (debug) {
|
|
||||||
printf("Cutpoint idx=%lu Cur(%3.1f, %d) Prev(%3.1f, %d) Pivot(%3.1f, %d) = (%3.1g, %3.1g] \n", idx, xCur, yCur, xPrev, yPrev, xPivot, yPivot, cutPoint.fromValue, cutPoint.toValue);
|
|
||||||
}
|
|
||||||
cutPts.push_back(cutPoint);
|
|
||||||
}
|
|
||||||
yPrev = yPivot;
|
|
||||||
xPrev = xPivot;
|
|
||||||
}
|
|
||||||
if (idx == numElements) {
|
|
||||||
cutPoint.start = start;
|
|
||||||
cutPoint.end = numElements + 1;
|
|
||||||
cutPoint.fromValue = firstCutPoint ? numeric_limits<precision_t>::lowest() : cutPts.back().toValue;
|
|
||||||
cutPoint.toValue = numeric_limits<precision_t>::max();
|
|
||||||
cutPoint.classNumber = -1;
|
|
||||||
if (debug)
|
|
||||||
printf("Final Cutpoint idx=%lu Cur(%3.1f, %d) Prev(%3.1f, %d) Pivot(%3.1f, %d) = (%3.1g, %3.1g] \n", idx, xCur, yCur, xPrev, yPrev, xPivot, yPivot, cutPoint.fromValue, cutPoint.toValue);
|
|
||||||
cutPts.push_back(cutPoint);
|
|
||||||
}
|
|
||||||
if (debug) {
|
|
||||||
cout << "Entropy of the dataset: " << Metrics::entropy(y, indices, 0, numElements + 1, numClasses) << endl;
|
|
||||||
for (auto cutPt : cutPts)
|
|
||||||
cout << "Entropy: " << Metrics::entropy(y, indices, cutPt.start, cutPt.end, numClasses) << " :Proposal: Cut point: " << cutPt;
|
|
||||||
}
|
|
||||||
cutPoints = cutPts;
|
|
||||||
}
|
|
||||||
void CPPFImdlp::computeCutPointsOriginal()
|
|
||||||
{
|
|
||||||
cutPoints_t cutPts;
|
|
||||||
cutPoint_t cutPoint;
|
|
||||||
precision_t xPrev;
|
|
||||||
int yPrev;
|
|
||||||
bool first = true;
|
|
||||||
// idxPrev is the index of the init instance of the cutPoint
|
|
||||||
size_t index, idxPrev = 0, last, idx = indices[0];
|
|
||||||
xPrev = X[idx];
|
|
||||||
yPrev = y[idx];
|
|
||||||
last = indices.size() - 1;
|
|
||||||
for (index = 0; index < last; index++) {
|
|
||||||
idx = indices[index];
|
|
||||||
// Definition 2 Cut points are always on class boundaries &&
|
|
||||||
// there are more than 1 items in the interval
|
|
||||||
// if (entropy of interval) > (entropyLeft + entropyRight)) { Accept cut point } (goodCut)
|
|
||||||
if (y[idx] != yPrev && xPrev < X[idx] && idxPrev != index - 1 && goodCut(idxPrev, idx, last + 1)) {
|
|
||||||
// Must we add the entropy criteria here?
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
cutPoint.fromValue = numeric_limits<precision_t>::lowest();
|
|
||||||
} else {
|
|
||||||
cutPoint.fromValue = cutPts.back().toValue;
|
|
||||||
}
|
|
||||||
cutPoint.start = idxPrev;
|
|
||||||
cutPoint.end = index;
|
|
||||||
cutPoint.classNumber = -1;
|
|
||||||
cutPoint.toValue = round(divider * (X[idx] + xPrev) / 2) / divider;
|
|
||||||
idxPrev = index;
|
|
||||||
cutPts.push_back(cutPoint);
|
|
||||||
}
|
|
||||||
xPrev = X[idx];
|
|
||||||
yPrev = y[idx];
|
|
||||||
}
|
|
||||||
if (first) {
|
|
||||||
cutPoint.start = 0;
|
|
||||||
cutPoint.classNumber = -1;
|
|
||||||
cutPoint.fromValue = numeric_limits<precision_t>::lowest();
|
|
||||||
cutPoint.toValue = numeric_limits<precision_t>::max();
|
|
||||||
cutPts.push_back(cutPoint);
|
|
||||||
} else
|
|
||||||
cutPts.back().toValue = numeric_limits<precision_t>::max();
|
|
||||||
cutPts.back().end = X.size();
|
|
||||||
if (debug) {
|
|
||||||
cout << "Entropy of the dataset: " << Metrics::entropy(y, indices, 0, indices.size(), numClasses) << endl;
|
|
||||||
for (auto cutPt : cutPts)
|
|
||||||
cout << "Entropy: " << Metrics::entropy(y, indices, cutPt.start, cutPt.end, numClasses) << ": Original: Cut point: " << cutPt;
|
|
||||||
}
|
|
||||||
cutPoints = cutPts;
|
|
||||||
}
|
|
||||||
bool CPPFImdlp::goodCut(size_t start, size_t cut, size_t end)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Meter las entropías en una matríz cuadrada dispersa (samples, samples) M[start, end] iniciada a -1 y si no se ha calculado calcularla y almacenarla
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
precision_t entropyLeft = Metrics::entropy(y, indices, start, cut, numClasses);
|
|
||||||
precision_t entropyRight = Metrics::entropy(y, indices, cut, end, numClasses);
|
|
||||||
precision_t entropyInterval = Metrics::entropy(y, indices, start, end, numClasses);
|
|
||||||
if (debug)
|
|
||||||
printf("Entropy L, R, T: L(%5.3g) + R(%5.3g) - T(%5.3g) \t", entropyLeft, entropyRight, entropyInterval);
|
|
||||||
//return (entropyInterval - (entropyLeft + entropyRight) > 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Argsort from https://stackoverflow.com/questions/1577475/c-sorting-and-keeping-track-of-indexes
|
|
||||||
indices_t CPPFImdlp::sortIndices(samples& X_)
|
|
||||||
{
|
|
||||||
indices_t idx(X_.size());
|
|
||||||
iota(idx.begin(), idx.end(), 0);
|
|
||||||
for (size_t i = 0; i < X_.size(); i++)
|
|
||||||
stable_sort(idx.begin(), idx.end(), [&X_](size_t i1, size_t i2)
|
|
||||||
{ return X_[i1] < X_[i2]; });
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
void CPPFImdlp::setCutPoints(cutPoints_t cutPoints_)
|
|
||||||
{
|
|
||||||
cutPoints = cutPoints_;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
#ifndef CPPFIMDLP_H
|
|
||||||
#define CPPFIMDLP_H
|
|
||||||
#include "typesFImdlp.h"
|
|
||||||
#include <utility>
|
|
||||||
namespace mdlp {
|
|
||||||
class CPPFImdlp {
|
|
||||||
protected:
|
|
||||||
bool proposal; // proposed algorithm or original algorithm
|
|
||||||
int precision;
|
|
||||||
bool debug;
|
|
||||||
precision_t divider;
|
|
||||||
indices_t indices; // sorted indices to use with X and y
|
|
||||||
samples X;
|
|
||||||
labels y;
|
|
||||||
labels xDiscretized;
|
|
||||||
int numClasses;
|
|
||||||
cutPoints_t cutPoints;
|
|
||||||
|
|
||||||
void setCutPoints(cutPoints_t);
|
|
||||||
static indices_t sortIndices(samples&);
|
|
||||||
void computeCutPointsOriginal();
|
|
||||||
void computeCutPointsProposal();
|
|
||||||
bool evaluateCutPoint(cutPoint_t, cutPoint_t);
|
|
||||||
void filterCutPoints();
|
|
||||||
bool goodCut(size_t, size_t, size_t); // if the cut candidate reduces entropy
|
|
||||||
|
|
||||||
public:
|
|
||||||
CPPFImdlp();
|
|
||||||
CPPFImdlp(bool, int, bool debug = false);
|
|
||||||
~CPPFImdlp();
|
|
||||||
samples getCutPoints();
|
|
||||||
indices_t getIndices();
|
|
||||||
labels getDiscretizedValues();
|
|
||||||
void debugPoints(samples&, labels&);
|
|
||||||
CPPFImdlp& fit(samples&, labels&);
|
|
||||||
labels transform(samples&);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
@@ -1,47 +0,0 @@
|
|||||||
#include "Metrics.h"
|
|
||||||
#include <set>
|
|
||||||
namespace mdlp {
|
|
||||||
Metrics::Metrics()
|
|
||||||
= default;
|
|
||||||
int Metrics::numClasses(labels& y, indices_t indices, size_t start, size_t end)
|
|
||||||
{
|
|
||||||
std::set<int> numClasses;
|
|
||||||
for (auto i = start; i < end; ++i) {
|
|
||||||
numClasses.insert(y[indices[i]]);
|
|
||||||
}
|
|
||||||
return numClasses.size();
|
|
||||||
}
|
|
||||||
precision_t Metrics::entropy(labels& y, indices_t& indices, size_t start, size_t end, int nClasses)
|
|
||||||
{
|
|
||||||
precision_t entropy = 0;
|
|
||||||
int nElements = 0;
|
|
||||||
labels counts(nClasses + 1, 0);
|
|
||||||
for (auto i = &indices[start]; i != &indices[end]; ++i) {
|
|
||||||
counts[y[*i]]++;
|
|
||||||
nElements++;
|
|
||||||
}
|
|
||||||
for (auto count : counts) {
|
|
||||||
if (count > 0) {
|
|
||||||
precision_t p = (precision_t)count / nElements;
|
|
||||||
entropy -= p * log2(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entropy < 0 ? 0 : entropy;
|
|
||||||
}
|
|
||||||
precision_t Metrics::informationGain(labels& y, indices_t& indices, size_t start, size_t end, size_t cutPoint, int nClasses)
|
|
||||||
{
|
|
||||||
precision_t iGain;
|
|
||||||
precision_t entropy, entropyLeft, entropyRight;
|
|
||||||
int nClassesLeft, nClassesRight;
|
|
||||||
int nElementsLeft = cutPoint - start, nElementsRight = end - cutPoint;
|
|
||||||
int nElements = end - start;
|
|
||||||
nClassesLeft = Metrics::numClasses(y, indices, start, cutPoint);
|
|
||||||
nClassesRight = Metrics::numClasses(y, indices, cutPoint, end);
|
|
||||||
entropy = Metrics::entropy(y, indices, start, end, nClasses);
|
|
||||||
entropyLeft = Metrics::entropy(y, indices, start, cutPoint, nClassesLeft);
|
|
||||||
entropyRight = Metrics::entropy(y, indices, cutPoint, end, nClassesRight);
|
|
||||||
iGain = entropy - ((precision_t)nElementsLeft * entropyLeft + (precision_t)nElementsRight * entropyRight) / nElements;
|
|
||||||
return iGain;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,14 +0,0 @@
|
|||||||
#ifndef METRICS_H
|
|
||||||
#define METRICS_H
|
|
||||||
#include "typesFImdlp.h"
|
|
||||||
#include <cmath>
|
|
||||||
namespace mdlp {
|
|
||||||
class Metrics {
|
|
||||||
public:
|
|
||||||
Metrics();
|
|
||||||
static int numClasses(labels&, indices_t, size_t, size_t);
|
|
||||||
static precision_t entropy(labels&, indices_t&, size_t, size_t, int);
|
|
||||||
static precision_t informationGain(labels&, indices_t&, size_t, size_t, size_t, int);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
Binary file not shown.
@@ -22,9 +22,6 @@ int main(int argc, char** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//file.load("datasets/mfeat-factors.arff", true);
|
|
||||||
//file.load("/Users/rmontanana/Code/FImdlp/fimdlp/testcpp/datasets/kdd_JapaneseVowels.arff", false);
|
|
||||||
//file.load("/Users/rmontanana/Code/FImdlp/fimdlp/testcpp/datasets/iris.arff", true);
|
|
||||||
file.load(path + argv[1] + ".arff", datasets[argv[1]]);
|
file.load(path + argv[1] + ".arff", datasets[argv[1]]);
|
||||||
auto attributes = file.getAttributes();
|
auto attributes = file.getAttributes();
|
||||||
int items = file.getSize();
|
int items = file.getSize();
|
||||||
|
@@ -38,7 +38,7 @@ vector<int>& ArffFiles::getY()
|
|||||||
{
|
{
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
void ArffFiles::load(string fileName)
|
void ArffFiles::load(string fileName, bool classLast)
|
||||||
{
|
{
|
||||||
ifstream file(fileName);
|
ifstream file(fileName);
|
||||||
string keyword, attribute, type;
|
string keyword, attribute, type;
|
||||||
@@ -62,28 +62,34 @@ void ArffFiles::load(string fileName)
|
|||||||
file.close();
|
file.close();
|
||||||
if (attributes.empty())
|
if (attributes.empty())
|
||||||
throw invalid_argument("No attributes found");
|
throw invalid_argument("No attributes found");
|
||||||
className = get<0>(attributes.back());
|
if (classLast) {
|
||||||
classType = get<1>(attributes.back());
|
className = get<0>(attributes.back());
|
||||||
attributes.pop_back();
|
classType = get<1>(attributes.back());
|
||||||
generateDataset();
|
attributes.pop_back();
|
||||||
|
} else {
|
||||||
|
className = get<0>(attributes.front());
|
||||||
|
classType = get<1>(attributes.front());
|
||||||
|
attributes.erase(attributes.begin());
|
||||||
|
}
|
||||||
|
generateDataset(classLast);
|
||||||
} else
|
} else
|
||||||
throw invalid_argument("Unable to open file");
|
throw invalid_argument("Unable to open file");
|
||||||
}
|
}
|
||||||
void ArffFiles::generateDataset()
|
void ArffFiles::generateDataset(bool classLast)
|
||||||
{
|
{
|
||||||
X = vector<vector<float>>(lines.size(), vector<float>(attributes.size()));
|
X = vector<vector<float>>(attributes.size(), vector<float>(lines.size()));
|
||||||
vector<string> yy = vector<string>(lines.size(), "");
|
vector<string> yy = vector<string>(lines.size(), "");
|
||||||
|
int labelIndex = classLast ? attributes.size() : 0;
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
stringstream ss(lines[i]);
|
stringstream ss(lines[i]);
|
||||||
string value;
|
string value;
|
||||||
int j = 0;
|
int pos = 0, xIndex = 0;
|
||||||
while (getline(ss, value, ',')) {
|
while (getline(ss, value, ',')) {
|
||||||
if (j == attributes.size()) {
|
if (pos++ == labelIndex) {
|
||||||
yy[i] = value;
|
yy[i] = value;
|
||||||
break;
|
} else {
|
||||||
|
X[xIndex++][i] = stof(value);
|
||||||
}
|
}
|
||||||
X[i][j] = stof(value);
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
y = factorize(yy);
|
y = factorize(yy);
|
||||||
|
@@ -11,10 +11,10 @@ private:
|
|||||||
string className, classType;
|
string className, classType;
|
||||||
vector<vector<float>> X;
|
vector<vector<float>> X;
|
||||||
vector<int> y;
|
vector<int> y;
|
||||||
void generateDataset();
|
void generateDataset(bool);
|
||||||
public:
|
public:
|
||||||
ArffFiles();
|
ArffFiles();
|
||||||
void load(string);
|
void load(string, bool = true);
|
||||||
vector<string> getLines();
|
vector<string> getLines();
|
||||||
unsigned long int getSize();
|
unsigned long int getSize();
|
||||||
string getClassName();
|
string getClassName();
|
||||||
|
@@ -3,4 +3,4 @@ project(main)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
add_executable(main main.cpp ArffFiles.cpp)
|
add_executable(main main.cpp ArffFiles.cpp ../../Metrics.cpp ../../CPPFImdlp.cpp)
|
||||||
|
@@ -2,29 +2,53 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include "../../CPPFImdlp.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
ArffFiles file;
|
ArffFiles file;
|
||||||
vector<string> lines;
|
vector<string> lines;
|
||||||
//file.load("datasets/mfeat-factors.arff");
|
string path = "/Users/rmontanana/Code/FImdlp/fimdlp/testcpp/datasets/";
|
||||||
file.load("/Users/rmontanana/Code/FImdlp/fimdlp/testcpp/datasets/mfeat-factors.arff");
|
map<string, bool > datasets = {
|
||||||
cout << "Number of lines: " << file.getSize() << endl;
|
{"mfeat-factors", true},
|
||||||
|
{"iris", true},
|
||||||
|
{"letter", true},
|
||||||
|
{"kdd_JapaneseVowels", false}
|
||||||
|
};
|
||||||
|
if (argc != 2 || datasets.find(argv[1]) == datasets.end()) {
|
||||||
|
cout << "Usage: " << argv[0] << " {mfeat-factors, iris, letter, kdd_JapaneseVowels}" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.load(path + argv[1] + ".arff", datasets[argv[1]]);
|
||||||
|
auto attributes = file.getAttributes();
|
||||||
|
int items = file.getSize();
|
||||||
|
cout << "Number of lines: " << items << endl;
|
||||||
cout << "Attributes: " << endl;
|
cout << "Attributes: " << endl;
|
||||||
for (auto attribute: file.getAttributes()) {
|
for (auto attribute : attributes) {
|
||||||
cout << "Name: " << get<0>(attribute) << " Type: " << get<1>(attribute) << endl;
|
cout << "Name: " << get<0>(attribute) << " Type: " << get<1>(attribute) << endl;
|
||||||
}
|
}
|
||||||
cout << "Class name: " << file.getClassName() << endl;
|
cout << "Class name: " << file.getClassName() << endl;
|
||||||
cout << "Class type: " << file.getClassType() << endl;
|
cout << "Class type: " << file.getClassType() << endl;
|
||||||
cout << "Data: " << endl;
|
cout << "Data: " << endl;
|
||||||
vector<vector<float>> &X = file.getX();
|
vector<vector<float>>& X = file.getX();
|
||||||
vector<int> &y = file.getY();
|
vector<int>& y = file.getY();
|
||||||
for (int i = 0; i < X.size(); i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
for (float value: X[i]) {
|
for (auto feature : X) {
|
||||||
cout << fixed << setprecision(1) << value << " ";
|
cout << fixed << setprecision(1) << feature[i] << " ";
|
||||||
}
|
}
|
||||||
cout << y[i] << endl;
|
cout << y[i] << endl;
|
||||||
}
|
}
|
||||||
|
mdlp::CPPFImdlp test = mdlp::CPPFImdlp();
|
||||||
|
for (auto i = 0; i < attributes.size(); i++) {
|
||||||
|
cout << "Cut points for " << get<0>(attributes[i]) << endl;
|
||||||
|
cout << "--------------------------" << setprecision(3) << endl;
|
||||||
|
test.fit(X[i], y);
|
||||||
|
for (auto item : test.getCutPoints()) {
|
||||||
|
cout << item << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
#include "FImdlp.h"
|
|
||||||
namespace FImdlp {
|
|
||||||
FImdlp::FImdlp()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
FImdlp::~FImdlp()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
samples FImdlp::cutPoints(labels& X, labels& y)
|
|
||||||
{
|
|
||||||
samples cutPts;
|
|
||||||
int i, ant = X.at(0);
|
|
||||||
int n = X.size();
|
|
||||||
for (i = 1; i < n; i++) {
|
|
||||||
if (X.at(i) != ant) {
|
|
||||||
cutPts.push_back(precision_t(X.at(i) + ant) / 2);
|
|
||||||
ant = X.at(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cutPts;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
#ifndef FIMDLP_H
|
|
||||||
#define FIMDLP_H
|
|
||||||
#include <vector>
|
|
||||||
#include <Python.h>
|
|
||||||
namespace FImdlp {
|
|
||||||
class FImdlp {
|
|
||||||
public:
|
|
||||||
FImdlp();
|
|
||||||
~FImdlp();
|
|
||||||
samples cutPoints(labels&, labels&);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Doctorado-ML
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@@ -1,42 +0,0 @@
|
|||||||
SHELL := /bin/bash
|
|
||||||
.DEFAULT_GOAL := help
|
|
||||||
.PHONY: coverage deps help lint push test doc build
|
|
||||||
|
|
||||||
clean: ## Clean up
|
|
||||||
rm -rf build dist *.egg-info
|
|
||||||
for name in fimdlp/cfimdlp.cpp fimdlp/fimdlp.cpython-310-darwin.so
|
|
||||||
do
|
|
||||||
if [ -f $name ]; then rm $name; fi
|
|
||||||
done
|
|
||||||
|
|
||||||
lint: ## Lint and static-check
|
|
||||||
black fimdlp
|
|
||||||
flake8 fimdlp
|
|
||||||
|
|
||||||
push: ## Push code with tags
|
|
||||||
git push && git push --tags
|
|
||||||
|
|
||||||
build: ## Build package
|
|
||||||
rm -fr dist/*
|
|
||||||
rm -fr build/*
|
|
||||||
python setup.py build_ext
|
|
||||||
|
|
||||||
audit: ## Audit pip
|
|
||||||
pip-audit
|
|
||||||
|
|
||||||
help: ## Show help message
|
|
||||||
@IFS=$$'\n' ; \
|
|
||||||
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
|
||||||
printf "%s\n\n" "Usage: make [task]"; \
|
|
||||||
printf "%-20s %s\n" "task" "help" ; \
|
|
||||||
printf "%-20s %s\n" "------" "----" ; \
|
|
||||||
for help_line in $${help_lines[@]}; do \
|
|
||||||
IFS=$$':' ; \
|
|
||||||
help_split=($$help_line) ; \
|
|
||||||
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
|
||||||
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
|
|
||||||
printf '\033[36m'; \
|
|
||||||
printf "%-20s %s" $$help_command ; \
|
|
||||||
printf '\033[0m'; \
|
|
||||||
printf "%s\n" $$help_info; \
|
|
||||||
done
|
|
@@ -1,10 +0,0 @@
|
|||||||
# FImdlp
|
|
||||||
|
|
||||||
Fayyad - Irani MDLP discretization algorithm
|
|
||||||
|
|
||||||
## Build and usage sample
|
|
||||||
|
|
||||||
```bash
|
|
||||||
python setup.py build_ext --inplace
|
|
||||||
python sample.py
|
|
||||||
```
|
|
@@ -1 +0,0 @@
|
|||||||
from ._version import __version__
|
|
@@ -1 +0,0 @@
|
|||||||
__version__ = '0.1.1'
|
|
@@ -1,17 +0,0 @@
|
|||||||
# distutils: language = c++
|
|
||||||
# cython: language_level = 3
|
|
||||||
from libcpp.vector cimport vector
|
|
||||||
|
|
||||||
cdef extern from "FImdlp.h" namespace "FImdlp":
|
|
||||||
cdef cppclass FImdlp:
|
|
||||||
FImdlp() except +
|
|
||||||
vector[precision_t] cutPoints(vector[int]&, vector[int]&)
|
|
||||||
|
|
||||||
cdef class CFImdlp:
|
|
||||||
cdef FImdlp *thisptr
|
|
||||||
def __cinit__(self):
|
|
||||||
self.thisptr = new FImdlp()
|
|
||||||
def __dealloc__(self):
|
|
||||||
del self.thisptr
|
|
||||||
def cut_points(self, X, y):
|
|
||||||
return self.thisptr.cutPoints(X, y)
|
|
@@ -1,38 +0,0 @@
|
|||||||
# pyproject.toml
|
|
||||||
[build-system]
|
|
||||||
requires = ["setuptools", "cython", "wheel"]
|
|
||||||
build-backend = "setuptools.build_meta"
|
|
||||||
|
|
||||||
[tool.setuptools]
|
|
||||||
license-files = ["LICENSE"]
|
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
|
||||||
version = { attr = "fimdlp.__version__" }
|
|
||||||
|
|
||||||
[project]
|
|
||||||
name = "FImdlp"
|
|
||||||
readme = "README.md"
|
|
||||||
authors = [
|
|
||||||
{ name = "Ricardo Montañana", email = "ricardo.montanana@alu.uclm.es" },
|
|
||||||
]
|
|
||||||
dynamic = ['version']
|
|
||||||
dependencies = ["numpy"]
|
|
||||||
requires-python = ">=3.8"
|
|
||||||
classifiers = [
|
|
||||||
"Development Status :: 3 - Alpha",
|
|
||||||
"Intended Audience :: Science/Research",
|
|
||||||
"Intended Audience :: Developers",
|
|
||||||
"Topic :: Software Development",
|
|
||||||
"Topic :: Scientific/Engineering",
|
|
||||||
"License :: OSI Approved :: MIT License",
|
|
||||||
"Natural Language :: English",
|
|
||||||
"Operating System :: OS Independent",
|
|
||||||
"Programming Language :: Python",
|
|
||||||
"Programming Language :: Python",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
|
||||||
"Programming Language :: Python :: 3.9",
|
|
||||||
"Programming Language :: Python :: 3.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[project.urls]
|
|
||||||
Home = "https://github.com/doctorado-ml/FImdlp"
|
|
@@ -1,14 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
from sklearn.datasets import load_iris
|
|
||||||
from fimdlp import CFImdlp
|
|
||||||
|
|
||||||
data = load_iris()
|
|
||||||
X = data.data
|
|
||||||
y = data.target
|
|
||||||
features = data.feature_names
|
|
||||||
test = CFImdlp()
|
|
||||||
print("Cut points for each feature in Iris dataset:")
|
|
||||||
for i in range(0, X.shape[1]):
|
|
||||||
data = np.sort(X[:, i])
|
|
||||||
Xcutpoints = test.cut_points(data, y)
|
|
||||||
print(f"{features[i]:20s}: {Xcutpoints}")
|
|
@@ -1,32 +0,0 @@
|
|||||||
"""
|
|
||||||
Calling
|
|
||||||
$python setup.py build_ext --inplace
|
|
||||||
will build the extension library in the current file.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from setuptools import Extension, setup
|
|
||||||
|
|
||||||
setup(
|
|
||||||
ext_modules=[
|
|
||||||
Extension(
|
|
||||||
name="fimdlp",
|
|
||||||
sources=["cfimdlp.pyx", "FImdlp.cpp"],
|
|
||||||
language="c++",
|
|
||||||
include_dirs=["fimdlp"],
|
|
||||||
),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
# from Cython.Build import cythonize
|
|
||||||
# setup(
|
|
||||||
# ext_modules=cythonize(
|
|
||||||
# Extension(
|
|
||||||
# "fimdlp",
|
|
||||||
# sources=["fimdlp/cfimdlp.pyx", "fimdlp/FImdlp.cpp"],
|
|
||||||
# language="c++",
|
|
||||||
# include_dirs=["fimdlp"],
|
|
||||||
# ),
|
|
||||||
# include_path=["./fimdlp"],
|
|
||||||
# )
|
|
||||||
# )
|
|
||||||
|
|
11
sample.py
11
sample.py
@@ -1,19 +1,18 @@
|
|||||||
from sklearn.datasets import load_iris
|
|
||||||
from fimdlp.mdlp import FImdlp
|
from fimdlp.mdlp import FImdlp
|
||||||
from fimdlp.cppfimdlp import CFImdlp
|
from fimdlp.cppfimdlp import CFImdlp
|
||||||
from sklearn.ensemble import RandomForestClassifier
|
from sklearn.ensemble import RandomForestClassifier
|
||||||
import numpy as np
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from scipy.io import arff
|
from scipy.io import arff
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
path = "fimdlp/testcpp/datasets/"
|
||||||
# class_name = "speaker"
|
# class_name = "speaker"
|
||||||
# file_name = "kdd_JapaneseVowels.arff"
|
# file_name = "kdd_JapaneseVowels.arff"
|
||||||
class_name = "class"
|
class_name = "class"
|
||||||
# file_name = "mfeat-factors.arff"
|
# file_name = "mfeat-factors.arff"
|
||||||
file_name = "letter.arff"
|
file_name = "letter.arff"
|
||||||
data = arff.loadarff(file_name)
|
data = arff.loadarff(path + file_name)
|
||||||
df = pd.DataFrame(data[0])
|
df = pd.DataFrame(data[0])
|
||||||
df.dropna(axis=0, how="any", inplace=True)
|
df.dropna(axis=0, how="any", inplace=True)
|
||||||
dataset = df
|
dataset = df
|
||||||
@@ -23,12 +22,6 @@ class_name = class_name
|
|||||||
y, _ = pd.factorize(df[class_name])
|
y, _ = pd.factorize(df[class_name])
|
||||||
X = X.to_numpy()
|
X = X.to_numpy()
|
||||||
|
|
||||||
# data = load_iris()
|
|
||||||
# X = data.data
|
|
||||||
# y = data.target
|
|
||||||
# features = data.feature_names
|
|
||||||
|
|
||||||
|
|
||||||
test = FImdlp()
|
test = FImdlp()
|
||||||
now = time.time()
|
now = time.time()
|
||||||
# test.fit(X, y, features=[i for i in (range(3, 14))])
|
# test.fit(X, y, features=[i for i in (range(3, 14))])
|
||||||
|
Reference in New Issue
Block a user