Skip to content

Commit 3769d62

Browse files
committed
FreeViz Script: add preprocessor and transform test
1 parent 0352057 commit 3769d62

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Orange/tests/test_freeviz.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import numpy as np
66

77
from Orange.data import Table
8+
from Orange.preprocess import Continuize
89
from Orange.projection import FreeViz
910

1011

@@ -72,3 +73,29 @@ def test_initial(self):
7273
FreeViz.init_radial(2)
7374
FreeViz.init_radial(3)
7475
FreeViz.init_random(2, 4, 5)
76+
77+
def test_transform_changed_domain(self):
78+
"""
79+
1. Open data, apply some preprocessor, splits the data into two parts,
80+
use FreeViz on the first part, and then transform the second part.
81+
82+
2. Open data, split into two parts, apply the same preprocessor and
83+
FreeViz only on the first part, and then transform the second part.
84+
85+
The transformed second part in (1) and (2) has to be the same.
86+
"""
87+
data = Table("titanic")[::10]
88+
normalize = Continuize()
89+
freeviz = FreeViz(maxiter=40)
90+
91+
# normalize all
92+
ndata = normalize(data)
93+
model = freeviz(ndata[:100])
94+
result_1 = model(ndata[100:])
95+
96+
# normalize only the "training" part
97+
ndata = normalize(data[:100])
98+
model = freeviz(ndata)
99+
result_2 = model(data[100:])
100+
101+
np.testing.assert_almost_equal(result_1.X, result_2.X)

0 commit comments

Comments
 (0)