Regressor
¶
A model for regression tasks.
Parent type: SupervisedModel
Inheritors:
AdaBoostRegressor
DecisionTreeRegressor
ElasticNetRegressor
GradientBoostingRegressor
KNearestNeighborsRegressor
LassoRegressor
LinearRegressor
RandomForestRegressor
RidgeRegressor
SupportVectorRegressor
Stub code in Regressor.sdsstub
10 11 12 13 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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
isFitted
¶
Whether the model is fitted.
Type: Boolean
coefficientOfDetermination
¶
Compute the coefficient of determination (R²) of the regressor on the given data.
The coefficient of determination compares the regressor's predictions to another model that always predicts the mean of the target values. It is a measure of how well the regressor explains the variance in the target values.
The higher the coefficient of determination, the better the regressor. Results range from negative infinity to 1.0. You can interpret the coefficient of determination as follows:
R² | Interpretation |
---|---|
1.0 | The model perfectly predicts the target values. Did you overfit? |
(0.0, 1.0) | The model is better than predicting the mean of the target values. You should be here. |
0.0 | The model is as good as predicting the mean of the target values. Try something else. |
(-∞, 0.0) | The model is worse than predicting the mean of the target values. Something is very wrong. |
Notes:
- The model must be fitted.
- Some other libraries call this metric
r2_score
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validationOrTestSet |
union<Table, TabularDataset> |
The validation or test set. | - |
Results:
Name | Type | Description |
---|---|---|
coefficientOfDetermination |
Float |
The coefficient of determination of the regressor. |
Stub code in Regressor.sdsstub
fit
¶
Create a copy of this model and fit it with the given training data.
Note: This model is not modified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trainingSet |
TabularDataset |
The training data containing the features and target. | - |
Results:
Name | Type | Description |
---|---|---|
fittedModel |
Regressor |
The fitted model. |
Stub code in Regressor.sdsstub
getFeatureNames
¶
Return the names of the feature columns.
Note: The model must be fitted.
Results:
Name | Type | Description |
---|---|---|
featureNames |
List<String> |
The names of the feature columns. |
Stub code in SupervisedModel.sdsstub
getFeaturesSchema
¶
Return the schema of the feature columns.
Note: The model must be fitted.
Results:
Name | Type | Description |
---|---|---|
featureSchema |
Schema |
The schema of the feature columns. |
Stub code in SupervisedModel.sdsstub
getTargetName
¶
Return the name of the target column.
Note: The model must be fitted.
Results:
Name | Type | Description |
---|---|---|
targetName |
String |
The name of the target column. |
Stub code in SupervisedModel.sdsstub
getTargetType
¶
Return the type of the target column.
Note: The model must be fitted.
Results:
Name | Type | Description |
---|---|---|
targetType |
DataType |
The type of the target column. |
Stub code in SupervisedModel.sdsstub
meanAbsoluteError
¶
Compute the mean absolute error (MAE) of the regressor on the given data.
The mean absolute error is the average of the absolute differences between the predicted and expected target values. The lower the mean absolute error, the better the regressor. Results range from 0.0 to positive infinity.
Note: The model must be fitted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validationOrTestSet |
union<Table, TabularDataset> |
The validation or test set. | - |
Results:
Name | Type | Description |
---|---|---|
meanAbsoluteError |
Float |
The mean absolute error of the regressor. |
Stub code in Regressor.sdsstub
meanDirectionalAccuracy
¶
Compute the mean directional accuracy (MDA) of the regressor on the given data.
This metric compares two consecutive target values and checks if the predicted direction (down/unchanged/up) matches the expected direction. The mean directional accuracy is the proportion of correctly predicted directions. The higher the mean directional accuracy, the better the regressor. Results range from 0.0 to 1.0.
This metric is useful for time series data, where the order of the target values has a meaning. It is not useful
for other types of data. Because of this, it is not included in the summarize_metrics
method.
Note: The model must be fitted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validationOrTestSet |
union<Table, TabularDataset> |
The validation or test set. | - |
Results:
Name | Type | Description |
---|---|---|
meanDirectionalAccuracy |
Float |
The mean directional accuracy of the regressor. |
Stub code in Regressor.sdsstub
meanSquaredError
¶
Compute the mean squared error (MSE) of the regressor on the given data.
The mean squared error is the average of the squared differences between the predicted and expected target values. The lower the mean squared error, the better the regressor. Results range from 0.0 to positive infinity.
Notes:
- The model must be fitted.
- To get the root mean squared error (RMSE), take the square root of the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validationOrTestSet |
union<Table, TabularDataset> |
The validation or test set. | - |
Results:
Name | Type | Description |
---|---|---|
meanSquaredError |
Float |
The mean squared error of the regressor. |
Stub code in Regressor.sdsstub
medianAbsoluteDeviation
¶
Compute the median absolute deviation (MAD) of the regressor on the given data.
The median absolute deviation is the median of the absolute differences between the predicted and expected target values. The lower the median absolute deviation, the better the regressor. Results range from 0.0 to positive infinity.
Note: The model must be fitted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validationOrTestSet |
union<Table, TabularDataset> |
The validation or test set. | - |
Results:
Name | Type | Description |
---|---|---|
medianAbsoluteDeviation |
Float |
The median absolute deviation of the regressor. |
Stub code in Regressor.sdsstub
predict
¶
Predict the target values on the given dataset.
Note: The model must be fitted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
union<Table, TabularDataset> |
The dataset containing at least the features. | - |
Results:
Name | Type | Description |
---|---|---|
prediction |
TabularDataset |
The given dataset with an additional column for the predicted target values. |
Stub code in SupervisedModel.sdsstub
summarizeMetrics
¶
Summarize the regressor's metrics on the given data.
Note: The model must be fitted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
validationOrTestSet |
union<Table, TabularDataset> |
The validation or test set. | - |
Results:
Name | Type | Description |
---|---|---|
metrics |
Table |
A table containing the regressor's metrics. |