Exemplo n.º 1
0
PROBA = True
PROCESSING = False
LEN = 6
WIDTH = 2
FOLDS = 3
MOD, r = divmod(LEN, FOLDS)
assert r == 0

lg = LayerGenerator()
data = Data('blend', PROBA, PROCESSING)

X, y = data.get_data((LEN, WIDTH), MOD)
(F, wf), (P, wp) = data.ground_truth(X, y)

layer = lg.get_layer('blend', PROBA, PROCESSING)
lc = lg.get_layer_container('blend', PROBA, PROCESSING)
lc_p = lg.get_layer_container('blend',
                              PROBA,
                              PROCESSING,
                              propagate_features=[1])

layer.indexer.fit(X)

cache = Cache(X, y, data)


def test_layer_fit():
    """[Parallel | Blend | No Prep | Proba] test layer fit."""
    layer_fit(layer, cache, F, wf)

Exemplo n.º 2
0
PROCESSING = True
LEN = 12
WIDTH = 2
FOLDS = 3
PARTITIONS = 2
MOD, r = divmod(LEN, FOLDS)
assert r == 0

lg = LayerGenerator()
data = Data('subset', PROBA, PROCESSING, PARTITIONS, FOLDS)

X, y = data.get_data((LEN, WIDTH), MOD)
(F, wf), (P, wp) = data.ground_truth(X, y, subsets=PARTITIONS)

layer = lg.get_layer('subset', PROBA, PROCESSING, PARTITIONS, FOLDS)
lc = lg.get_layer_container('subset', PROBA, PROCESSING, PARTITIONS, FOLDS)

layer.indexer.fit(X)

cache = Cache(X, y, data)


def test_layer_fit():
    """[Parallel | Subset | Prep | Proba] test layer fit."""
    layer_fit(layer, cache, F, wf)


def test_layer_predict():
    """[Parallel | Subset | Prep | Proba] test layer predict."""
    layer_predict(layer, cache, P, wp)
Exemplo n.º 3
0
LEN = 12
WIDTH = 2
FOLDS = 3
PARTITIONS = 2
MOD, r = divmod(LEN, FOLDS)
assert r == 0

lg = LayerGenerator()
data = Data('subset', PROBA, PROCESSING, PARTITIONS, FOLDS)

X, y = data.get_data((LEN, WIDTH), MOD)

(F, wf), (P, wp) = data.ground_truth(X, y, subsets=PARTITIONS)

layer = lg.get_layer('subset', PROBA, PROCESSING, PARTITIONS, FOLDS)
lc = lg.get_layer_container('subset', PROBA, PROCESSING, PARTITIONS, FOLDS)
lc_p = lg.get_layer_container('subset',
                              PROBA,
                              PROCESSING,
                              PARTITIONS,
                              FOLDS,
                              propagate_features=[1])

layer.indexer.fit(X)

cache = Cache(X, y, data)


def test_layer_fit():
    """[Parallel | Subset | No Prep | Proba] test layer fit."""
    layer_fit(layer, cache, F, wf)
Exemplo n.º 4
0
PROBA = False
PROCESSING = True
LEN = 6
WIDTH = 2
FOLDS = 3
MOD, r = divmod(LEN, FOLDS)
assert r == 0

lg = LayerGenerator()
data = Data('stack', PROBA, PROCESSING, FOLDS)

X, y = data.get_data((LEN, WIDTH), MOD)
(F, wf), (P, wp) = data.ground_truth(X, y)

layer = lg.get_layer('stack', PROBA, PROCESSING, FOLDS)
lc = lg.get_layer_container('stack', PROBA, PROCESSING, FOLDS)

layer.indexer.fit(X)

cache = Cache(X, y, data)


def test_layer_fit():
    """[Parallel | Stack | Prep] test layer fit."""
    layer_fit(layer, cache, F, wf)


def test_layer_predict():
    """[Parallel | Stack | Prep] test layer predict."""
    layer_predict(layer, cache, P, wp)
Exemplo n.º 5
0
PROBA = True
PROCESSING = False
LEN = 6
WIDTH = 2
FOLDS = 2
MOD, r = divmod(LEN, FOLDS)
assert r == 0

lg = LayerGenerator()
data = Data('stack', PROBA, PROCESSING, FOLDS)

X, y = data.get_data((LEN, WIDTH), MOD)
(F, wf), (P, wp) = data.ground_truth(X, y)

layer = lg.get_layer('stack', PROBA, PROCESSING, FOLDS)
lc = lg.get_layer_container('stack', PROBA, PROCESSING, FOLDS)
lc_p = lg.get_layer_container('stack',
                              PROBA,
                              PROCESSING,
                              FOLDS,
                              propagate_features=[1])

layer.indexer.fit(X)

cache = Cache(X, y, data)


def test_layer_fit():
    """[Parallel | Stack | No Prep | Proba ] test layer fit."""
    layer_fit(layer, cache, F, wf)
Exemplo n.º 6
0
PROBA = True
PROCESSING = False
LEN = 6
WIDTH = 2
FOLDS = 3
MOD, r = divmod(LEN, FOLDS)
assert r == 0

lg = LayerGenerator()
data = Data('blend', PROBA, PROCESSING)

X, y = data.get_data((LEN, WIDTH), MOD)
(F, wf), (P, wp) = data.ground_truth(X, y)

layer = lg.get_layer('blend', PROBA, PROCESSING)
lc = lg.get_layer_container('blend', PROBA, PROCESSING)

layer.indexer.fit(X)

cache = Cache(X, y, data)


def test_layer_fit():
    """[Parallel | Blend | No Prep | Proba] test layer fit."""
    layer_fit(layer, cache, F, wf)


def test_layer_predict():
    """[Parallel | Blend | No Prep | Proba] test layer predict."""
    layer_predict(layer, cache, P, wp)
Exemplo n.º 7
0
"""
import numpy as np

from mlens.externals.sklearn.base import clone
from mlens.utils.checks import check_ensemble_build, assert_valid_estimator, \
    check_is_fitted, assert_correct_format, check_initialized

from mlens.utils.dummy import LayerGenerator, OLS, Scale
from mlens.utils.exceptions import LayerSpecificationError, \
    LayerSpecificationWarning, NotFittedError, ParallelProcessingError, \
    ParallelProcessingWarning

lg = LayerGenerator()

LAYER = lg.get_layer('stack', False, True)
LAYER_CONTAINER = lg.get_layer_container('stack', False, True)


class Tmp(object):
    """Temporary class for mimicking ParallelProcessing status."""
    def __init__(self, lyr, __initialized__, __fitted__):
        self.__initialized__ = __initialized__
        self.__fitted__ = __fitted__
        self.layers = lyr


class Lyr(object):
    """Temporary layer class for storing raise on exception."""
    def __init__(self, raise_on_exception):
        self.raise_on_exception = raise_on_exception