MCPcopy Create free account
hub / github.com/modAL-python/modAL / test_on_transformed

Method test_on_transformed

tests/core_tests.py:1568–1607  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1566 )
1567
1568 def test_on_transformed(self):
1569 n_samples = 10
1570 n_features = 5
1571 query_strategies = [
1572 # TODO remove, added just to make sure on_transformed doesn't break anything
1573 # but it has no influence on this strategy, nothing special tested here
1574 mock.MockFunction(return_val=[np.random.randint(0, n_samples)])
1575
1576 # add further strategies which work with instance representations
1577 # no further ones as of 25.09.2020
1578 ]
1579 X_pool = np.random.rand(n_samples, n_features)
1580
1581 # use pandas data frame as X_pool, which will be transformed back to numpy with sklearn pipeline
1582 X_pool = pd.DataFrame(X_pool)
1583
1584 y_pool = np.random.rand(n_samples)
1585 train_idx = np.random.choice(range(n_samples), size=2, replace=False)
1586
1587 learner_list = [modAL.models.learners.ActiveLearner(
1588 estimator=make_pipeline(
1589 FunctionTransformer(func=pd.DataFrame.to_numpy),
1590 GaussianProcessRegressor()
1591 ),
1592 # committee learners can contain different amounts of
1593 # different instances
1594 X_training=X_pool.iloc[train_idx[(
1595 np.arange(i + 1) + i) % len(train_idx)]],
1596 y_training=y_pool[train_idx[(
1597 np.arange(i + 1) + i) % len(train_idx)]],
1598 ) for i in range(3)]
1599
1600 for query_strategy in query_strategies:
1601 committee = modAL.models.learners.CommitteeRegressor(
1602 learner_list=learner_list,
1603 query_strategy=query_strategy,
1604 on_transformed=True
1605 )
1606 query_idx, query_inst = committee.query(X_pool)
1607 committee.teach(X_pool.iloc[query_idx], y_pool[query_idx])
1608
1609
1610class TestMultilabel(unittest.TestCase):

Callers

nothing calls this directly

Calls 2

queryMethod · 0.45
teachMethod · 0.45

Tested by

no test coverage detected