From 83e370539c8ed98b6d07a563c6cf5a6dd446f2a7 Mon Sep 17 00:00:00 2001 From: Ajda Date: Fri, 2 Feb 2024 11:04:31 +0100 Subject: [PATCH 1/2] Stack: new table instead of transform --- Orange/ensembles/stack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Orange/ensembles/stack.py b/Orange/ensembles/stack.py index 17e22362c78..37cb94b610b 100644 --- a/Orange/ensembles/stack.py +++ b/Orange/ensembles/stack.py @@ -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 From 3bb991d95ea267a497f232e9cede1683b12c91b2 Mon Sep 17 00:00:00 2001 From: Ajda Date: Fri, 23 Feb 2024 10:20:49 +0100 Subject: [PATCH 2/2] Stack: test aggregation --- Orange/tests/test_stack.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Orange/tests/test_stack.py b/Orange/tests/test_stack.py index c52ff229d21..48ccdcbc1ed 100644 --- a/Orange/tests/test_stack.py +++ b/Orange/tests/test_stack.py @@ -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 @@ -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)