How to use the mlblocks.MLPipeline.from_dict function in mlblocks

To help you get started, we’ve selected a few mlblocks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDI-Project / MLPrimitives / mlprimitives / evaluation.py View on Github external
metric_args = validation.get('metric_args', dict())
    if metric:
        scorer = get_scorer(metric, metric_args)
    else:
        scorer = dataset.score
        metric = dataset.metric

    scores = list()
    splits = dataset.get_splits(n_splits)
    if n_splits == 1:
        splits = [splits]

    for split, (X_train, X_test, y_train, y_test) in enumerate(splits):
        LOGGER.info('Scoring split %s', split + 1)
        context = get_context(dataset, validation.get('context', dict()))
        pipeline = MLPipeline.from_dict(pipeline_metadata)
        pipeline.fit(X_train, y_train, **context)
        predictions = pipeline.predict(X_test, **context)

        score = scorer(y_test, predictions)
        LOGGER.info('Split %s %s: %s', split + 1, metric, score)

        scores.append(score)

    return np.mean(scores), np.std(scores)