5fe98231a26e08d81f9684a681af43bc2fb2b847,pyinterpret/model/model.py,Model,check_output_signature,#Model#Any#,38

Before Change


                // the prediction is yield groups as strings, as in a classification model
                self.model_type = StaticTypes.model_types.classifier
                self.probability = False
                self.n_classes = len(np.unique(outputs))

            elif self.output_var_type == StaticTypes.output_types.int:
                // the prediction is yield groups as integers, as in a classification model
                self.model_type = StaticTypes.model_types.classifier

After Change


            about the types of outputs the function generally makes.

        
        if not examples.any():
            err_msg = "Examples have not been provided. Cannot check outputs"
            raise exceptions.ModelError(err_msg)

        outputs = self(examples)
        self.input_shape = examples.shape
        self.output_shape = outputs.shape
        if len(self.output_shape) == 1:
            // the predict function is either a continuous prediction,
            // or a most-likely classification
            example_output = outputs[0]
            self.output_var_type = return_data_type(example_output)
            if self.output_var_type in (StaticTypes.output_types.string,
                                        StaticTypes.output_types.int):
                // the prediction is yield groups as strings or ints,
                // as in a classification model
                self.model_type = StaticTypes.model_types.classifier
                self.probability = False
                self.n_classes = len(np.unique(outputs))

            elif self.output_var_type == StaticTypes.output_types.float:
                // the prediction returning 1D continuous values
                // this is not a stable method
                // technically, you could classify things as
                // something like 0.0 and 1.0
                // perhaps it would be better if counted unique values?
                self.model_type = StaticTypes.model_types.regressor
                self.n_classes = 1
                self.probability = StaticTypes.not_applicable
                self.logger.warn("Inferring model type to be a regressor"
                                 "due to 1D array of floats")
            else:
                pass  // default unknowns will take care of this
        elif len(self.output_shape) == 2:
            self.model_type = StaticTypes.model_types.classifier
            self.n_classes = self.output_shape[1]
            example_output = outputs[0][0]
            self.output_var_type = return_data_type(example_output)
            self.probability = (self.output_var_type == StaticTypes.output_types.float)
        else:
            raise ValueError("Unsupported model type, output dim = 3")

        self.formatter = self.return_transformer_func()

        reports = self.model_report(examples)
        for report in reports:
            self.logger.debug(report)

    @staticmethod
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 6

Instances


Project Name: datascienceinc/Skater
Commit Name: 5fe98231a26e08d81f9684a681af43bc2fb2b847
Time: 2017-03-16
Author: aikramer2@gmail.com
File Name: pyinterpret/model/model.py
Class Name: Model
Method Name: check_output_signature


Project Name: automl/auto-sklearn
Commit Name: 9d0ed839dc9df4c9afc5966c1e3276c478a58d53
Time: 2020-09-16
Author: feurerm@informatik.uni-freiburg.de
File Name: scripts/update_metadata_util.py
Class Name:
Method Name: load_task


Project Name: has2k1/plotnine
Commit Name: 8afc45fa9c6d70f74ce140ef1d1347a33099b8d6
Time: 2016-07-20
Author: has2k1@gmail.com
File Name: ggplotx/positions/position_jitterdodge.py
Class Name: position_jitterdodge
Method Name: setup_params


Project Name: J535D165/recordlinkage
Commit Name: f0abbde5a393b8781919a2c33474757c07cfee8f
Time: 2016-01-02
Author: jonathandebruinhome@gmail.com
File Name: recordlinkage/indexing.py
Class Name:
Method Name: _sortedneighbourhood