Skip to content

Commit

Permalink
Merge pull request #6723 from ajdapretnar/stack-error
Browse files Browse the repository at this point in the history
Stack: new table instead of transform
  • Loading branch information
janezd committed Feb 23, 2024
2 parents c17d656 + 3bb991d commit 194572b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Orange/ensembles/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def fit_storage(self, data):
dom = Domain([ContinuousVariable('f{}'.format(i + 1))
for i in range(X.shape[1])],
data.domain.class_var)
stacked_data = data.transform(dom).copy()
stacked_data = Table.from_table(dom, data)
with stacked_data.unlocked_reference():
stacked_data.X = X
stacked_data.Y = res.actual
Expand Down
15 changes: 14 additions & 1 deletion Orange/tests/test_stack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from Orange.data import Table
from Orange.ensembles.stack import StackedFitter
from Orange.ensembles.stack import StackedFitter, StackedLearner
from Orange.evaluation import CA, CrossValidation, MSE
from Orange.modelling import KNNLearner, TreeLearner

Expand All @@ -26,3 +26,16 @@ def test_regression(self):
mse = MSE()(results)
self.assertLess(mse[0], mse[1])
self.assertLess(mse[0], mse[2])

def test_timeseries(self):
def aggregate(data):
assert type(data) is Table

class CustomTable(Table):
pass

sl = StackedLearner([TreeLearner(), KNNLearner()],
aggregate=aggregate)

data = CustomTable(self.iris)
sl(data)

0 comments on commit 194572b

Please sign in to comment.