o
    }o™iZ  ã                   @  sT   d dl mZ d dlmZ d dlmZ er d dlmZ d dlm	Z	 G dd„ deƒZ
dS )	é    )Úannotations)ÚTYPE_CHECKING)Ú
BasePruner)ÚStudy)ÚFrozenTrialc                   @  s   e Zd ZdZddd	„Zd
S )Ú	NopPrunera  Pruner which never prunes trials.

    Example:

        .. testcode::

            import numpy as np
            from sklearn.datasets import load_iris
            from sklearn.linear_model import SGDClassifier
            from sklearn.model_selection import train_test_split

            import optuna

            X, y = load_iris(return_X_y=True)
            X_train, X_valid, y_train, y_valid = train_test_split(X, y)
            classes = np.unique(y)


            def objective(trial):
                alpha = trial.suggest_float("alpha", 0.0, 1.0)
                clf = SGDClassifier(alpha=alpha)
                n_train_iter = 100

                for step in range(n_train_iter):
                    clf.partial_fit(X_train, y_train, classes=classes)

                    intermediate_value = clf.score(X_valid, y_valid)
                    trial.report(intermediate_value, step)

                    if trial.should_prune():
                        assert False, "should_prune() should always return False with this pruner."
                        raise optuna.TrialPruned()

                return clf.score(X_valid, y_valid)


            study = optuna.create_study(direction="maximize", pruner=optuna.pruners.NopPruner())
            study.optimize(objective, n_trials=20)
    Ústudyr   Útrialr   ÚreturnÚboolc                 C  s   dS )NF© )Úselfr   r	   r   r   úG/home/ubuntu/.local/lib/python3.10/site-packages/optuna/pruners/_nop.pyÚprune6   s   zNopPruner.pruneN)r   r   r	   r   r
   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    (r   N)Ú
__future__r   Útypingr   Úoptuna.prunersr   Úoptuna.studyr   Úoptuna.trialr   r   r   r   r   r   Ú<module>   s    