Coverage for credoai/artifacts/model/regression_model.py: 64%
11 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-13 21:56 +0000
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-13 21:56 +0000
1"""Model artifact wrapping any regression model"""
2from .base_model import Model
5class RegressionModel(Model):
6 """Class wrapper around classification model to be assessed
8 RegressionModel serves as an adapter between arbitrary regression models and the
9 evaluations in Lens. Evaluations depend on
10 RegressionModel instantiating `predict`
12 Parameters
13 ----------
14 name : str
15 Label of the model
16 model_like : model_like
17 A continuous output regression model or pipeline. It must have a
18 `predict` function that returns array containing the predicted outcomes for each sample.
19 """
21 def __init__(self, name: str, model_like=None, tags=None):
22 super().__init__("REGRESSION", ["predict"], ["predict"], name, model_like, tags)
25class DummyRegression:
26 """Class wrapper around regression model predictions
28 This class can be used when a regression model is not available but its outputs are.
29 The output include the array containing the predicted class labels and/or the array
30 containing the class labels probabilities.
31 Wrap the outputs with this class into a dummy classifier and pass it as
32 the model to `RegressionModel`.
34 Parameters
35 ----------
36 predict_output : array
37 Array containing the output of a model's "predict" method
38 """
40 def __init__(self, name: str, predict_output=None, tags=None):
41 self.predict_output = predict_output
42 self.name = name
43 self.tags = tags
45 def predict(self, X=None):
46 return self.predict_output