// 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