r2
Computes the Coefficient of Determination, which is the proportion of variance in the dependent variable that is predictable from the independent variable(s), where the best value is 1 and the worst value goes towards -Infinity.
Attention: Available only with Twin Activate commercial edition.
Syntax
Score = r2(targets,predictions)
Inputs
- targets
- Actual label for each observation.
- predictions
- Predicted value for each observation.
Outputs
- Score
- Coefficient of determination of the regression model.
Example
Usage of r2
targets = [3, -0.5, 2, 7];
predictions = [2.5, 0.0, 2, 8];
score = r2(targets, predictions);
> score
score = 0.948608137