Dummy¶
sklego.dummy.RandomRegressor
¶
Bases: BaseEstimator
, RegressorMixin
A RandomRegressor
makes random predictions only based on the y
value that is seen.
The goal is that such a regressor can be used for benchmarking. It should be easily beatable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strategy
|
Literal[uniform, normal]
|
How we want to select random values, either "uniform" or "normal" |
"uniform"
|
random_state
|
int | None
|
The seed value used for the random number generator. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
min_ |
float
|
The minimum value of |
max_ |
float
|
The maximum value of |
mu_ |
float
|
The mean value of |
sigma_ |
float
|
The standard deviation of |
n_features_in_ |
int
|
The number of features seen during |
dim_ |
int
|
Deprecated, please use |
Examples:
from sklego.dummy import RandomRegressor
from sklearn.datasets import make_regression
X, y = make_regression(n_samples=10, n_features=2, random_state=42)
RandomRegressor(strategy="uniform", random_state=123).fit(X, y).predict(X).round(2)
# array([ 57.63, -66.05, -83.92, 13.88, 64.56, -24.77, 143.33, 54.12,
# -7.34, -34.11])
RandomRegressor(strategy="normal", random_state=123).fit(X, y).predict(X).round(2)
# array([-128.45, 78.05, 7.23, -170.15, -78.18, 142.9 , -261.39,
# -63.34, 104.68, -106.75])
Source code in sklego/dummy.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
fit(X, y)
¶
Fit the model using X, y as training data.
:param X: array-like, shape=(n_columns, n_samples,) training data. :param y: array-like, shape=(n_samples,) training data. :return: Returns an instance of self.
Source code in sklego/dummy.py
predict(X)
¶
Predict new data by generating random guesses following the given strategy
based on the y
statistics seen
during fit
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array-like of shape (n_samples, n_features)
|
The data to predict. |
required |
Returns:
Type | Description |
---|---|
array-like of shape (n_samples,)
|
The predicted data. |