Esempio n. 1
0
def test_drift_adaptation_hatc():
    rng = random.Random(42)
    dataset = iter(synth.Sine(seed=8, classification_function=0, has_noise=True))

    model = tree.HoeffdingAdaptiveTreeClassifier(
        leaf_prediction="mc",
        grace_period=10,
        adwin_confidence=0.1,
        split_confidence=0.1,
        drift_window_threshold=2,
        seed=42,
        max_depth=3,
    )

    for i in range(1000):
        if i % 200 == 0 and i > 0:
            dataset = iter(
                synth.Sine(
                    seed=8, classification_function=rng.randint(0, 3), has_noise=False
                )
            )

        x, y = next(dataset)
        model.learn_one(x, y)

    assert model._n_switch_alternate_trees > 0
Esempio n. 2
0
from river import preprocessing
from river import evaluate
from river import metrics
from river import datasets
from river import tree
from river import compose
from river import optim

X_y = synth.PredictionInfluenceStream(stream=[
    synth.RandomRBF(seed_model=42,
                    seed_sample=42,
                    n_classes=2,
                    n_features=4,
                    n_centroids=20),
    synth.RandomRBF(seed_model=41,
                    seed_sample=49,
                    n_classes=2,
                    n_features=4,
                    n_centroids=20)
])

model = preprocessing.StandardScaler()
model |= tree.HoeffdingAdaptiveTreeClassifier(grace_period=100,
                                              split_confidence=1e-5,
                                              leaf_prediction='nb',
                                              nb_threshold=10,
                                              seed=0)

metric = metrics.Accuracy()

evaluate.evaluate_influential(X_y, model, metric, print_every=100)
Esempio n. 3
0
                                         param_grid=CLASSIFICATION_PARAM_GRID,
                                         sampling_rate=SAMPLING_RATE)),
    ('EvoAutoML Bagging Best',
     EvolutionaryBaggingClassifier(population_size=POPULATION_SIZE,
                                   model=AUTOML_CLASSIFICATION_PIPELINE,
                                   param_grid=CLASSIFICATION_PARAM_GRID,
                                   sampling_rate=SAMPLING_RATE)),
    ('ARF', ensemble.AdaptiveRandomForestClassifier()),
    ('Leveraging Bagging',
     ensemble.LeveragingBaggingClassifier(model=ENSEMBLE_CLASSIFIER())),
    ('Bagging',
     ensemble.BaggingClassifier(model=ENSEMBLE_CLASSIFIER(), n_models=10)),
    ('SRPC', ensemble.SRPClassifier(n_models=10)),
    ('Hoeffding Tree', tree.HoeffdingTreeClassifier()),
    ('Logistic Regression', linear_model.LogisticRegression()),
    ('HAT', tree.HoeffdingAdaptiveTreeClassifier()),
    ('GaussianNB', naive_bayes.GaussianNB()),
    ('KNN', neighbors.KNNClassifier()),
]

if __name__ == '__main__':

    RESULT_PATH.mkdir(parents=True, exist_ok=True)
    #output = evaluate_ensemble(CLASSIFICATION_TRACKS[1], ENSEMBLE_EVALUATION_MODELS[2])

    pool = Pool(60)  # Create a multiprocessing Pool
    output = pool.starmap(
        evaluate_ensemble,
        list(
            itertools.product(CLASSIFICATION_TRACKS,
                              ENSEMBLE_EVALUATION_MODELS)))
Esempio n. 4
0
     (
         get_classification_data(),
         tree.HoeffdingTreeClassifier(
             leaf_prediction="mc",
             max_size=0.025,
             grace_period=50,
             memory_estimate_period=50,
             splitter=tree.splitter.ExhaustiveSplitter(),
         ),
     ),
     (
         get_classification_data(),
         tree.HoeffdingAdaptiveTreeClassifier(
             leaf_prediction="mc",
             max_size=0.025,
             grace_period=50,
             memory_estimate_period=50,
             splitter=tree.splitter.ExhaustiveSplitter(),
         ),
     ),
     (
         get_classification_data(),
         tree.ExtremelyFastDecisionTreeClassifier(
             leaf_prediction="mc",
             max_size=0.025,
             grace_period=50,
             memory_estimate_period=50,
             splitter=tree.splitter.ExhaustiveSplitter(),
         ),
     ),
 ],