# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Models.BinaryCrossValidator
"""

import numbers

from ..utils.entrypoints import EntryPoint
from ..utils.utils import try_set, unlist


def models_binarycrossvalidator(
        data,
        nodes,
        inputs_subgraph,
        outputs_subgraph,
        predictor_model,
        warnings,
        overall_metrics,
        per_instance_metrics,
        confusion_matrix,
        stratification_column=None,
        num_folds=2,
        **params):
    """
    **Description**
        Cross validation for binary classification

    :param data: The data set (inputs).
    :param nodes: The training subgraph (inputs).
    :param inputs_subgraph: The training subgraph inputs (inputs).
    :param outputs_subgraph: The training subgraph outputs (inputs).
    :param stratification_column: Column to use for stratification
        (inputs).
    :param num_folds: Number of folds in k-fold cross-validation
        (inputs).
    :param predictor_model: The trained model (outputs).
    :param warnings: Warning dataset (outputs).
    :param overall_metrics: Overall metrics dataset (outputs).
    :param per_instance_metrics: Per instance metrics dataset
        (outputs).
    :param confusion_matrix: Confusion matrix dataset (outputs).
    """

    entrypoint_name = 'Models.BinaryCrossValidator'
    inputs = {}
    outputs = {}

    if data is not None:
        inputs['Data'] = try_set(
            obj=data,
            none_acceptable=False,
            is_of_type=str)
    if nodes is not None:
        inputs['Nodes'] = try_set(
            obj=nodes,
            none_acceptable=False,
            is_of_type=list)
    if inputs_subgraph is not None:
        inputs['Inputs'] = try_set(
            obj=inputs_subgraph,
            none_acceptable=False,
            is_of_type=dict,
            field_names=['Data'])
    if outputs_subgraph is not None:
        inputs['Outputs'] = try_set(
            obj=outputs_subgraph,
            none_acceptable=False,
            is_of_type=dict,
            field_names=['Model'])
    if stratification_column is not None:
        inputs['StratificationColumn'] = try_set(
            obj=stratification_column,
            none_acceptable=True,
            is_of_type=str,
            is_column=True)
    if num_folds is not None:
        inputs['NumFolds'] = try_set(
            obj=num_folds,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if predictor_model is not None:
        outputs['PredictorModel'] = try_set(
            obj=predictor_model,
            none_acceptable=False,
            is_of_type=list)
    if warnings is not None:
        outputs['Warnings'] = try_set(
            obj=warnings,
            none_acceptable=False,
            is_of_type=list)
    if overall_metrics is not None:
        outputs['OverallMetrics'] = try_set(
            obj=overall_metrics,
            none_acceptable=False,
            is_of_type=list)
    if per_instance_metrics is not None:
        outputs['PerInstanceMetrics'] = try_set(
            obj=per_instance_metrics, none_acceptable=False, is_of_type=list)
    if confusion_matrix is not None:
        outputs['ConfusionMatrix'] = try_set(
            obj=confusion_matrix,
            none_acceptable=False,
            is_of_type=list)

    input_variables = {
        x for x in unlist(inputs.values())
        if isinstance(x, str) and x.startswith("$")}
    output_variables = {
        x for x in unlist(outputs.values())
        if isinstance(x, str) and x.startswith("$")}

    entrypoint = EntryPoint(
        name=entrypoint_name, inputs=inputs, outputs=outputs,
        input_variables=input_variables,
        output_variables=output_variables)
    return entrypoint
