Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone knoes how to get the best params ? #14

Open
Abhranta opened this issue Jan 11, 2022 · 1 comment
Open

Anyone knoes how to get the best params ? #14

Abhranta opened this issue Jan 11, 2022 · 1 comment

Comments

@Abhranta
Copy link

Hi, I want to see the parameters of the trained model after the training is complete. Can anyone help me out with it ?

@fedikadri
Copy link

fedikadri commented Jan 13, 2022

Since params are stored in database you can get the best using this method:

import logging
import optuna
import os
from  typing import Optional

logger = logging.getLogger(__name__)


def get_best_params(output: str) -> Optional[dict]:
    """
    Args:
        output (str): the output directory given to Autoxgb 

    Returns:
        Optional[dict]: best params if exist else None
    """
    
    params_path = os.path.join(output, "params.db")
    if not os.path.exists(params_path):
        logger.error(f"params doesn't exist. Invalid path: {params_path}")
        return None 

    best_params: Optional[dict] = None
    try:
        study = optuna.load_study(study_name="autoxgb", storage=f"sqlite:///{params_path}")
    except Exception as exc:
        logger.error("Error while loading optuna study from database", exc_info=exc)
    else:
        best_params = study.best_params
    finally:
        return best_params

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants