Ejemplo n.º 1
0
def _log_plot_objective(results, experiment, name='diagnostics'):
    try:
        fig = plt.figure(figsize=(16, 12))
        fig = axes2fig(sk_plots.plot_objective(results), fig=fig)
        experiment.log_image(name, fig)
    except Exception as e:
        print('Could not create the objective chart due to error: {}'.format(e))
Ejemplo n.º 2
0
def send_plot_objective(results, experiment=None, channel_name='objective'):
    """Logs skopt plot_objective figure to neptune.

    Image channel `objective` is created and the output of the
    plot_objective function is first covented to `neptune.Image` and
    then sent to neptune.

    Args:
        results('scipy.optimize.OptimizeResult'): Results object that is typically an
            output of the function like `skopt.forest_minimize(...)`
        experiment(`neptune.experiments.Experiment`): Neptune experiment. Default is None.

    Examples:
        Run skopt training::

            ...
            results = skopt.forest_minimize(objective, space,
                                            base_estimator='ET', n_calls=100, n_random_starts=10)

        Send skopt plot_objective figure to neptune::

            import neptune
            import neptunecontrib.monitoring.skopt as sk_utils

            neptune.init(project_qualified_name='USER_NAME/PROJECT_NAME')

            sk_monitor.send_plot_objective(results)

    """

    _exp = experiment if experiment else neptune
    fig = plt.figure(figsize=(16, 12))

    try:
        fig = axes2fig(sk_plots.plot_objective(results), fig=fig)
        with tempfile.NamedTemporaryFile(suffix='.png') as f:
            fig.savefig(f.name)
            _exp.send_image(channel_name, f.name)
    except Exception as e:
        print(
            'Could not create ans objective chart due to error: {}'.format(e))
Ejemplo n.º 3
0
def _log_plot_evaluations(results, experiment, name='diagnostics'):
    expect_not_a_run(experiment)
    fig = plt.figure(figsize=(16, 12))
    fig = axes2fig(sk_plots.plot_evaluations(results, bins=10), fig=fig)
    experiment.log_image(name, fig)
Ejemplo n.º 4
0
        best_params = results.x

        neptune.send_metric('valid_auc', best_auc)
        neptune.set_property('best_params', str(to_named_params(best_params)))

        # log results
        skopt.dump(results, os.path.join(REPORTS_DIRPATH, 'skopt_results.pkl'))
        neptune.send_artifact(
            os.path.join(REPORTS_DIRPATH, 'skopt_results.pkl'))

        # log diagnostic plots
        fig, ax = plt.subplots(figsize=(16, 12))
        skopt.plots.plot_convergence(results, ax=ax)
        fig.savefig(os.path.join(REPORTS_DIRPATH, 'convergence.png'))
        neptune.send_image('diagnostics',
                           os.path.join(REPORTS_DIRPATH, 'convergence.png'))

        axes = skopt.plots.plot_evaluations(results)
        fig = plt.figure(figsize=(16, 12))
        fig = axes2fig(axes, fig)
        fig.savefig(os.path.join(REPORTS_DIRPATH, 'evaluations.png'))
        neptune.send_image('diagnostics',
                           os.path.join(REPORTS_DIRPATH, 'evaluations.png'))

        axes = skopt.plots.plot_objective(results)
        fig = plt.figure(figsize=(16, 12))
        fig = axes2fig(axes, fig)
        fig.savefig(os.path.join(REPORTS_DIRPATH, 'objective.png'))
        neptune.send_image('diagnostics',
                           os.path.join(REPORTS_DIRPATH, 'objective.png'))