示例#1
0
def get_projects(ctx, credential):  # shared options
    max_len = [32, 24, 10, 20, 16]
    projects = dr.Project.list()
    columns = [
        'name',
        'project_id',
        'stage',
        'description',
        'partition',
    ]

    data = []
    for project in projects:
        status = project.get_status()
        partition = project.partition
        partitioning = "None"
        if partition != {}:
            if 'cv_method' not in partition:
                cv_method = 'random'
            else:
                cv_method = partition['cv_method']
            partitioning = cv_method
            partitioning += f": {partition['validation_type']}"

        values = [
            project.project_name, project.id, status['stage'],
            status['stage_description'], partitioning
        ]
        data.append(values)
    Utils.prettyprint_table(columns, data, max_len)
示例#2
0
def get_project(
        ctx,
        credential,  # shared options
        project_id,
        verbose):
    # FIXME: awful
    project = Project(project_id=project_id)
    metric = project.metric

    click.echo("### params")
    for k, v in yaml.load(project.to_yml()).items():
        click.echo(f"{k} : {v}")

    click.echo("\n### feature list")
    for featurelist in project.dr_project.get_featurelists():
        click.echo(f"* {featurelist.name}")
        if verbose:
            data = []
            for feature, attr in project.get_features(
                    featurelist.name).items():
                d = [feature]
                for k, v in attr.items():
                    d.append(v)
                data.append(d)
            else:
                columns = ['name'] + list(attr.keys())
            Utils.prettyprint_table(columns, data, [24])
        click.echo()

    click.echo(f"### top 10 models with {project.metric}")
    sort_key = Utils.get_appropriate_dataset(project.cv_method,
                                             project.validation_type,
                                             project.validation_params)

    models = project.search_models(featurelist_name=None,
                                   sort_key=sort_key)[:10]
    data = [(model.model_type, model.id, model.is_frozen,
             model.metrics[project.metric][sort_key], model.featurelist_name)
            for model in models]

    columns = ['type', 'id', 'is_frozen', f"{sort_key}", 'featurelist_name']
    Utils.prettyprint_table(columns, data, max_len=[16, 24, 9, 16, 16])

    click.echo()
    if verbose:
        click.echo(f"### frozen models")
        models = project.search_models(featurelist_name=None,
                                       is_frozen=True,
                                       sort_key=sort_key)
        data = [(model.model_type, model.id, model.is_frozen,
                 model.metrics[project.metric][sort_key]) for model in models]

        columns = ['type', 'id', 'is_frozen', f"{sort_key} : {project.metric}"]
        Utils.prettyprint_table(columns, data, max_len=[16, 24, 9, 24])