src/sasctl/_services/model_repository.py
def create_model(cls, model, project,
                     description=None,
                     modeler=None,
                     function=None,
                     algorithm=None,
                     tool=None,
                     score_code_type=None,
                     training_table=None,
                     event_prob_variable=None,
                     event_target_value=None,
                     is_champion=False,
                     is_challenger=False,
                     location=None,
                     target_variable=None,
                     is_retrainable=False,
                     is_immutable=False,
                     properties=None,
                     input_variables=None,
                     output_variables=None):
        """Create a model in an existing project or folder.

        Parameters
        ----------
        model : str or dict
            The name or id of the model, or a dictionary representation of the
            model.
        project : str or dict
            The name or id of the model project, or a dictionary representation
            of the model project.
        description : str, optional
            The description of the model.
        modeler : str, optional
            Name of the user that created the model.  Current user name will be
            used if unspecified.
        function : str, optional
            The function of the model, valid values include: analytical,
            classification, cluster, forecasting, prediction, Text analytics,
            transformation.
        algorithm : str, optional
            The name of the model algorithm.
        tool : str, optional
            The name of the model tool, can be 'Python 2' or 'Python 3'.
        score_code_type : str, optional
            The score code type for the model.
        training_table : str, optional
            The train data table.
        event_prob_variable : str, optional
            The name of the event probability variable.  Used for
            classification models only.
        event_target_value : str, optional
            The target event value.  Used for classification models only.
        is_champion : bool, optional
            Indicates whether the model should be designated as the
            project's champion model.  Defaults to False.
        is_challenger : bool, optional
            Indicates whether the model should be designated as a
            challenger model in the project.  Defaults to False.
        location : str, optional,
            The location of this model.
        target_variable : str, optional
            The name of the target variable.
        is_retrainable : bool
            Indicates whether the model can be retrained or not.
        is_immutable : bool
            Indicates whether the model can be changed or not.
        properties : array_like, optional (custom properties)
            Custom model properties that can be set: name, value, type
        input_variables : array_like, optional
            Model input variables. By default, these are the same as the model
            project.
        output_variables : array_like, optional
            Model output variables. By default, these are the same as the model
             project.

        Returns
        -------
        str
            The model schema returned in JSON format.

        """
        properties = properties or {}

        if isinstance(model, str):
            model = {'name': model}

        p = cls.get_project(project)
        if p is None:
            raise ValueError("Unable to find project '%s'" % project)

        # Use any explicitly passed parameter value first.
        # Fall back to values in the model dict.
        model['projectId'] = p['id']
        model['modeler'] = \
            modeler or model.get('modeler') or current_session().username
        model['description'] = description or model.get('description')
        model['function'] = function or model.get('function')
        model['algorithm'] = algorithm or model.get('algorithm')
        model['tool'] = tool or model.get('tool')
        model['champion'] = is_champion or model.get('champion')

        if is_champion:
            model['role'] = 'champion'
        elif is_challenger:
            model['role'] = 'challenger'

        model.setdefault('properties', [{'name': k, 'value': v} for k, v in
                                        properties.items()])
        model['scoreCodeType'] = score_code_type or model.get('scoreCodeType')
        model['trainTable'] = training_table or model.get('trainTable')
        model['classificationEventProbabilityVariableName'] = \
            event_prob_variable \
            or model.get('classificationEventProbabilityVariableName')
        model['classificationTargetEventValue'] = \
            event_target_value or model.get('classificationTargetEventValue')
        model['location'] = location or model.get('location')
        model['targetVariable'] = \
            target_variable or model.get('targetVariable')
        model['retrainable'] = is_retrainable or model.get('retrainable')
        model['immutable'] = is_immutable or model.get('immutable')
        model['inputVariables'] = \
            input_variables or model.get('inputVariables', [])
        model['outputVariables'] = \
            output_variables or model.get('outputVariables', [])
        model['version'] = '2'

        return cls.post('/models', json=model, headers={
            'Content-Type': 'application/vnd.sas.models.model+json'})
Create a model in an existing project or folder.

        Parameters
        ----------
        model : str or dict
            The name or id of the model, or a dictionary representation of the
            model.
        project : str or dict
            The name or id of the model project, or a dictionary representation
            of the model project.
        description : str, optional
            The description of the model.
        modeler : str, optional
            Name of the user that created the model.  Current user name will be
            used if unspecified.
        function : str, optional
            The function of the model, valid values include: analytical,
            classification, cluster, forecasting, prediction, Text analytics,
            transformation.
        algorithm : str, optional
            The name of the model algorithm.
        tool : str, optional
            The name of the model tool, can be 'Python 2' or 'Python 3'.
        score_code_type : str, optional
            The score code type for the model.
        training_table : str, optional
            The train data table.
        event_prob_variable : str, optional
            The name of the event probability variable.  Used for
            classification models only.
        event_target_value : str, optional
            The target event value.  Used for classification models only.
        is_champion : bool, optional
            Indicates whether the model should be designated as the
            project's champion model.  Defaults to False.
        is_challenger : bool, optional
            Indicates whether the model should be designated as a
            challenger model in the project.  Defaults to False.
        location : str, optional,
            The location of this model.
        target_variable : str, optional
            The name of the target variable.
        is_retrainable : bool
            Indicates whether the model can be retrained or not.
        is_immutable : bool
            Indicates whether the model can be changed or not.
        properties : array_like, optional (custom properties)
            Custom model properties that can be set: name, value, type
        input_variables : array_like, optional
            Model input variables. By default, these are the same as the model
            project.
        output_variables : array_like, optional
            Model output variables. By default, these are the same as the model
             project.

        Returns
        -------
        str
            The model schema returned in JSON format.

        
Create a model in an existing project or folder.
Parameters

model : str or dict
The name or id of the model, or a dictionary representation of the
model.
project : str or dict
The name or id of the model project, or a dictionary representation
of the model project.
description : str, optional
The description of the model.
modeler : str, optional
Name of the user that created the model.  Current user name will be
used if unspecified.
function : str, optional
The function of the model, valid values include: analytical,
classification, cluster, forecasting, prediction, Text analytics,
transformation.
algorithm : str, optional
The name of the model algorithm.
tool : str, optional
The name of the model tool, can be 'Python 2' or 'Python 3'.
score_code_type : str, optional
The score code type for the model.
training_table : str, optional
The train data table.
event_prob_variable : str, optional
The name of the event probability variable.  Used for
classification models only.
event_target_value : str, optional
The target event value.  Used for classification models only.
is_champion : bool, optional
Indicates whether the model should be designated as the
project's champion model.  Defaults to False.
is_challenger : bool, optional
Indicates whether the model should be designated as a
challenger model in the project.  Defaults to False.
location : str, optional,
The location of this model.
target_variable : str, optional
The name of the target variable.
is_retrainable : bool
Indicates whether the model can be retrained or not.
is_immutable : bool
Indicates whether the model can be changed or not.
properties : array_like, optional (custom properties)
Custom model properties that can be set: name, value, type
input_variables : array_like, optional
Model input variables. By default, these are the same as the model
project.
output_variables : array_like, optional
Model output variables. By default, these are the same as the model
project.

Returns

str
The model schema returned in JSON format.
Create a model in an existing project or folder . Parameters model : str or dict The name or id of the model or a dictionary representation of the model . project : str or dict The name or id of the model project or a dictionary representation of the model project . description : str optional The description of the model . modeler : str optional Name of the user that created the model . Current user name will be used if unspecified . function : str optional The function of the model valid values include : analytical classification cluster forecasting prediction Text analytics transformation . algorithm : str optional The name of the model algorithm . tool : str optional The name of the model tool can be ' Python 2 ' or ' Python 3 ' . score_code_type : str optional The score code type for the model . training_table : str optional The train data table . event_prob_variable : str optional The name of the event probability variable . Used for classification models only . event_target_value : str optional The target event value . Used for classification models only . is_champion : bool optional Indicates whether the model should be designated as the project ' s champion model . Defaults to False . is_challenger : bool optional Indicates whether the model should be designated as a challenger model in the project . Defaults to False . location : str optional The location of this model . target_variable : str optional The name of the target variable . is_retrainable : bool Indicates whether the model can be retrained or not . is_immutable : bool Indicates whether the model can be changed or not . properties : array_like optional ( custom properties ) Custom model properties that can be set : name value type input_variables : array_like optional Model input variables . By default these are the same as the model project . output_variables : array_like optional Model output variables . By default these are the same as the model project . Returns str The model schema returned in JSON format .
def create_model(cls, model, project,
                     description=None,
                     modeler=None,
                     function=None,
                     algorithm=None,
                     tool=None,
                     score_code_type=None,
                     training_table=None,
                     event_prob_variable=None,
                     event_target_value=None,
                     is_champion=False,
                     is_challenger=False,
                     location=None,
                     target_variable=None,
                     is_retrainable=False,
                     is_immutable=False,
                     properties=None,
                     input_variables=None,
                     output_variables=None):
        properties = properties or {}
        if isinstance(model, str):
            model = {'name': model}
        p = cls.get_project(project)
        if p is None:
            raise ValueError("Unable to find project '%s'" % project)
        model['projectId'] = p['id']
        model['modeler'] = \
            modeler or model.get('modeler') or current_session().username
        model['description'] = description or model.get('description')
        model['function'] = function or model.get('function')
        model['algorithm'] = algorithm or model.get('algorithm')
        model['tool'] = tool or model.get('tool')
        model['champion'] = is_champion or model.get('champion')
        if is_champion:
            model['role'] = 'champion'
        elif is_challenger:
            model['role'] = 'challenger'
        model.setdefault('properties', [{'name': k, 'value': v} for k, v in
                                        properties.items()])
        model['scoreCodeType'] = score_code_type or model.get('scoreCodeType')
        model['trainTable'] = training_table or model.get('trainTable')
        model['classificationEventProbabilityVariableName'] = \
            event_prob_variable \
            or model.get('classificationEventProbabilityVariableName')
        model['classificationTargetEventValue'] = \
            event_target_value or model.get('classificationTargetEventValue')
        model['location'] = location or model.get('location')
        model['targetVariable'] = \
            target_variable or model.get('targetVariable')
        model['retrainable'] = is_retrainable or model.get('retrainable')
        model['immutable'] = is_immutable or model.get('immutable')
        model['inputVariables'] = \
            input_variables or model.get('inputVariables', [])
        model['outputVariables'] = \
            output_variables or model.get('outputVariables', [])
        model['version'] = '2'
        return cls.post('/models', json=model, headers={
            'Content-Type': 'application/vnd.sas.models.model+json'})
def create_model ( cls , model , project , description = None , modeler = None , function = None , algorithm = None , tool = None , score_code_type = None , training_table = None , event_prob_variable = None , event_target_value = None , is_champion = False , is_challenger = False , location = None , target_variable = None , is_retrainable = False , is_immutable = False , properties = None , input_variables = None , output_variables = None ) : properties = properties or { } if isinstance ( model , str ) : model = { 'name' : model } p = cls . get_project ( project ) if p is None : raise ValueError ( "Unable to find project '%s'" % project ) model [ 'projectId' ] = p [ 'id' ] model [ 'modeler' ] = modeler or model . get ( 'modeler' ) or current_session ( ) . username model [ 'description' ] = description or model . get ( 'description' ) model [ 'function' ] = function or model . get ( 'function' ) model [ 'algorithm' ] = algorithm or model . get ( 'algorithm' ) model [ 'tool' ] = tool or model . get ( 'tool' ) model [ 'champion' ] = is_champion or model . get ( 'champion' ) if is_champion : model [ 'role' ] = 'champion' elif is_challenger : model [ 'role' ] = 'challenger' model . setdefault ( 'properties' , [ { 'name' : k , 'value' : v } for k , v in properties . items ( ) ] ) model [ 'scoreCodeType' ] = score_code_type or model . get ( 'scoreCodeType' ) model [ 'trainTable' ] = training_table or model . get ( 'trainTable' ) model [ 'classificationEventProbabilityVariableName' ] = event_prob_variable or model . get ( 'classificationEventProbabilityVariableName' ) model [ 'classificationTargetEventValue' ] = event_target_value or model . get ( 'classificationTargetEventValue' ) model [ 'location' ] = location or model . get ( 'location' ) model [ 'targetVariable' ] = target_variable or model . get ( 'targetVariable' ) model [ 'retrainable' ] = is_retrainable or model . get ( 'retrainable' ) model [ 'immutable' ] = is_immutable or model . get ( 'immutable' ) model [ 'inputVariables' ] = input_variables or model . get ( 'inputVariables' , [ ] ) model [ 'outputVariables' ] = output_variables or model . get ( 'outputVariables' , [ ] ) model [ 'version' ] = '2' return cls . post ( '/models' , json = model , headers = { 'Content-Type' : 'application/vnd.sas.models.model+json' } )
Create a model in an existing project or folder.
Create a model in an existing project or folder .
"""Create a model in an existing project or folder.

        Parameters
        ----------
        model : str or dict
            The name or id of the model, or a dictionary representation of the
            model.
        project : str or dict
            The name or id of the model project, or a dictionary representation
            of the model project.
        description : str, optional
            The description of the model.
        modeler : str, optional
            Name of the user that created the model.  Current user name will be
            used if unspecified.
        function : str, optional
            The function of the model, valid values include: analytical,
            classification, cluster, forecasting, prediction, Text analytics,
            transformation.
        algorithm : str, optional
            The name of the model algorithm.
        tool : str, optional
            The name of the model tool, can be 'Python 2' or 'Python 3'.
        score_code_type : str, optional
            The score code type for the model.
        training_table : str, optional
            The train data table.
        event_prob_variable : str, optional
            The name of the event probability variable.  Used for
            classification models only.
        event_target_value : str, optional
            The target event value.  Used for classification models only.
        is_champion : bool, optional
            Indicates whether the model should be designated as the
            project's champion model.  Defaults to False.
        is_challenger : bool, optional
            Indicates whether the model should be designated as a
            challenger model in the project.  Defaults to False.
        location : str, optional,
            The location of this model.
        target_variable : str, optional
            The name of the target variable.
        is_retrainable : bool
            Indicates whether the model can be retrained or not.
        is_immutable : bool
            Indicates whether the model can be changed or not.
        properties : array_like, optional (custom properties)
            Custom model properties that can be set: name, value, type
        input_variables : array_like, optional
            Model input variables. By default, these are the same as the model
            project.
        output_variables : array_like, optional
            Model output variables. By default, these are the same as the model
             project.

        Returns
        -------
        str
            The model schema returned in JSON format.

        """ # Use any explicitly passed parameter value first. # Fall back to values in the model dict.
cls
model
project
description
modeler
function
algorithm
tool
score_code_type
training_table
event_prob_variable
event_target_value
is_champion
is_challenger
location
target_variable
is_retrainable
is_immutable
properties
input_variables
output_variables