mirror of
https://github.com/rmontanana/mdlp.git
synced 2025-08-16 07:55:58 +00:00
Discretizer (#8)
* Add better check in testKBins.py * Add Discretizer base class for Both discretizers * Refactor order of constructors init
This commit is contained in:
committed by
GitHub
parent
f258fc220f
commit
638bb2a59e
@@ -89,6 +89,7 @@ print(f"Quaintile {clf4q.bin_edges_=}")
|
||||
print("-" * 80)
|
||||
#
|
||||
data, meta = loadarff("tests/datasets/iris.arff")
|
||||
|
||||
labelsu = [
|
||||
0,
|
||||
0,
|
||||
@@ -117,12 +118,12 @@ labelsu = [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
@@ -149,11 +150,11 @@ labelsu = [
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
@@ -161,9 +162,9 @@ labelsu = [
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
@@ -181,7 +182,7 @@ labelsu = [
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
@@ -217,14 +218,14 @@ labelsu = [
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
@@ -393,12 +394,19 @@ labelsq = [
|
||||
2,
|
||||
2,
|
||||
]
|
||||
test(clf4u, data["sepallength"], labelsu, title="IrisUniform")
|
||||
test(clf4q, data["sepallength"], labelsq, title="IrisQuantile")
|
||||
# print("Labels")
|
||||
# print(labels)
|
||||
# print("Expected")
|
||||
# print(expected)
|
||||
# for i in range(len(labels)):
|
||||
# if labels[i] != expected[i]:
|
||||
# print(f"Error at {i} {labels[i]} != {expected[i]}")
|
||||
# test(clf4u, data["sepallength"], labelsu, title="IrisUniform")
|
||||
# test(clf4q, data["sepallength"], labelsq, title="IrisQuantile")
|
||||
sepallength = [[x] for x in data["sepallength"]]
|
||||
clf4u.fit(sepallength)
|
||||
clf4q.fit(sepallength)
|
||||
computedu = clf4u.transform(sepallength)
|
||||
computedq = clf4q.transform(sepallength)
|
||||
wrongu = 0
|
||||
wrongq = 0
|
||||
for i in range(len(labelsu)):
|
||||
if labelsu[i] != computedu[i]:
|
||||
wrongu += 1
|
||||
if labelsq[i] != computedq[i]:
|
||||
wrongq += 1
|
||||
print(f"Iris sepallength diff. between BinDisc & sklearn::KBins Uniform ={wrongu:3d}")
|
||||
print(f"Iris sepallength diff. between BinDisc & sklearn::KBins Quantile ={wrongq:3d}")
|
||||
|
Reference in New Issue
Block a user