# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Trainers.FieldAwareFactorizationMachineBinaryClassifier
"""

import numbers

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


def trainers_fieldawarefactorizationmachinebinaryclassifier(
        training_data,
        predictor_model=None,
        learning_rate=0.1,
        iters=5,
        feature_column='Features',
        latent_dim=20,
        label_column='Label',
        lambda_linear=0.0001,
        lambda_latent=0.0001,
        normalize_features='Auto',
        norm=True,
        caching='Auto',
        shuffle=True,
        verbose=True,
        radius=0.5,
        **params):
    """
    **Description**
        Train a field-aware factorization machine for binary classification

    :param learning_rate: Initial learning rate (inputs).
    :param training_data: The data to be used for training (inputs).
    :param iters: Number of training iterations (inputs).
    :param feature_column: Column to use for features (inputs).
    :param latent_dim: Latent space dimension (inputs).
    :param label_column: Column to use for labels (inputs).
    :param lambda_linear: Regularization coefficient of linear
        weights (inputs).
    :param lambda_latent: Regularization coefficient of latent
        weights (inputs).
    :param normalize_features: Normalize option for the feature
        column (inputs).
    :param norm: Whether to normalize the input vectors so that the
        concatenation of all fields' feature vectors is unit-length
        (inputs).
    :param caching: Whether learner should cache input training data
        (inputs).
    :param shuffle: Whether to shuffle for each training iteration
        (inputs).
    :param verbose: Report traning progress or not (inputs).
    :param radius: Radius of initial latent factors (inputs).
    :param predictor_model: The trained model (outputs).
    """

    entrypoint_name = 'Trainers.FieldAwareFactorizationMachineBinaryClassifier'
    inputs = {}
    outputs = {}

    if learning_rate is not None:
        inputs['LearningRate'] = try_set(
            obj=learning_rate,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if training_data is not None:
        inputs['TrainingData'] = try_set(
            obj=training_data,
            none_acceptable=False,
            is_of_type=str)
    if iters is not None:
        inputs['Iters'] = try_set(
            obj=iters,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if feature_column is not None:
        inputs['FeatureColumn'] = try_set(
            obj=feature_column,
            none_acceptable=True,
            is_of_type=str,
            is_column=True)
    if latent_dim is not None:
        inputs['LatentDim'] = try_set(
            obj=latent_dim,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if label_column is not None:
        inputs['LabelColumn'] = try_set(
            obj=label_column,
            none_acceptable=True,
            is_of_type=str,
            is_column=True)
    if lambda_linear is not None:
        inputs['LambdaLinear'] = try_set(
            obj=lambda_linear,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if lambda_latent is not None:
        inputs['LambdaLatent'] = try_set(
            obj=lambda_latent,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if normalize_features is not None:
        inputs['NormalizeFeatures'] = try_set(
            obj=normalize_features,
            none_acceptable=True,
            is_of_type=str,
            values=[
                'No',
                'Warn',
                'Auto',
                'Yes'])
    if norm is not None:
        inputs['Norm'] = try_set(
            obj=norm,
            none_acceptable=True,
            is_of_type=bool)
    if caching is not None:
        inputs['Caching'] = try_set(
            obj=caching,
            none_acceptable=True,
            is_of_type=str,
            values=[
                'Auto',
                'Memory',
                'Disk',
                'None'])
    if shuffle is not None:
        inputs['Shuffle'] = try_set(
            obj=shuffle,
            none_acceptable=True,
            is_of_type=bool)
    if verbose is not None:
        inputs['Verbose'] = try_set(
            obj=verbose,
            none_acceptable=True,
            is_of_type=bool)
    if radius is not None:
        inputs['Radius'] = try_set(
            obj=radius,
            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=str)

    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
