vastorbit.VastFrame.score¶
- VastFrame.score(y_true: str, y_score: str, metric: Literal['aic', 'bic', 'accuracy', 'acc', 'balanced_accuracy', 'ba', 'auc', 'roc_auc', 'prc_auc', 'best_cutoff', 'best_threshold', 'false_discovery_rate', 'fdr', 'false_omission_rate', 'for', 'false_negative_rate', 'fnr', 'false_positive_rate', 'fpr', 'recall', 'tpr', 'precision', 'ppv', 'specificity', 'tnr', 'negative_predictive_value', 'npv', 'negative_likelihood_ratio', 'lr-', 'positive_likelihood_ratio', 'lr+', 'diagnostic_odds_ratio', 'dor', 'log_loss', 'logloss', 'f1', 'f1_score', 'mcc', 'bm', 'informedness', 'mk', 'markedness', 'ts', 'csi', 'critical_success_index', 'fowlkes_mallows_index', 'fm', 'prevalence_threshold', 'pm', 'confusion_matrix', 'classification_report', 'r2', 'rsquared', 'mae', 'mean_absolute_error', 'mse', 'mean_squared_error', 'msle', 'mean_squared_log_error', 'max', 'max_error', 'median', 'median_absolute_error', 'var', 'explained_variance']) float¶
Computes the score using the input columns and the input metric.
- Parameters:
y_true (str) – Response column.
y_score (str) – Prediction.
metric (str) –
The metric used to compute the score.
For Classification
- accuracy:
Accuracy.
\[Accuracy = \frac{TP + TN}{TP + TN + FP + FN}\]
- auc:
Area Under the Curve (ROC).
\[AUC = \int_{0}^{1} TPR(FPR) \, dFPR\]
- ba:
Balanced Accuracy.
\[BA = \frac{TPR + TNR}{2}\]
- best_cutoff:
Cutoff which optimised the ROC Curve prediction.
- bm:
Informedness.
\[BA = TPR + TNR - 1\]
- csi:
Critical Success Index.
\[index = \frac{TP}{TP + FN + FP}\]
- f1:
F1 Score
\[F_1 Score = 2 \times \frac{Precision \times Recall}{Precision + Recall}\]
- fdr:
False Discovery Rate.
\[FDR = 1 - PPV\]
- fm:
Fowlkes-Mallows index.
\[FM = \sqrt{PPV * TPR}\]
- fnr:
False Negative Rate.
\[FNR = \frac{FN}{FN + TP}\]
- for:
False Omission Rate.
\[FOR = 1 - NPV\]
- fpr:
False Positive Rate.
\[\frac{FP}{FP + TN}\]
- logloss:
Log Loss.
\[Loss = -\frac{1}{N} \sum_{i=1}^{N} \left( y_i \log(p_i) + (1 - y_i) \log(1 - p_i) \right)\]
- lr+:
Positive Likelihood Ratio.
\[LR+ = \frac{TPR}{FPR}\]
- lr-:
Negative Likelihood Ratio.
\[LR- = \frac{FNR}{TNR}\]
- dor:
Diagnostic Odds Ratio.
\[DOR = \frac{TP \times TN}{FP \times FN}\]
- mcc:
Matthews Correlation Coefficient.
\[MCC = \frac{TP \times TN - FP \times FN}{\sqrt{(TP + FP)(TP + FN)(TN + FP)(TN + FN)}}\]
- mk:
Markedness.
\[MK = PPV + NPV - 1\]
- npv:
Negative Predictive Value.
\[NPV = \frac{TN}{TN + FN}\]
- prc_auc:
Area Under the Curve (PRC).
\[AUC = \int_{0}^{1} Precision(Recall) \, dRecall\]
- precision:
Precision.
\[Precision = TP / (TP + FP)\]
- pt:
Prevalence Threshold.
\[threshold = \frac{\sqrt{FPR}}{\sqrt{TPR} + \sqrt{FPR}}\]
- recall:
Recall.
\[Recall = \frac{TP}{TP + FN}\]
- specificity:
Specificity.
\[Specificity = \frac{TN}{TN + FP}\]
For Regression
- max:
Max Error.
\[ME = \max_{i=1}^{n} \left| y_i - \hat{y}_i \right|\]
- mae:
Mean Absolute Error.
\[MAE = \frac{1}{n} \sum_{i=1}^{n} \left| y_i - \hat{y}_i \right|\]
- median:
Median Absolute Error.
\[MedAE = \text{median}_{i=1}^{n} \left| y_i - \hat{y}_i \right|\]
- mse:
Mean Squared Error.
\[MSE = \frac{1}{n} \sum_{i=1}^{n} \left( y_i - \hat{y}_i \right)^2\]
- msle:
Mean Squared Log Error.
\[MSLE = \frac{1}{n} \sum_{i=1}^{n} (\log(1 + y_i) - \log(1 + \hat{y}_i))^2\]
- r2:
R squared coefficient.
\[R^2 = 1 - \frac{\sum_{i=1}^{n} (y_i - \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i - \bar{y})^2}\]
- var:
Explained Variance.
\[\text{Explained Variance} = 1 - \frac{Var(y - \hat{y})}{Var(y)}\]
- Returns:
score.
- Return type:
float
Examples
Let us build a quick ML model and calculate the score of its predictions.
Load data for machine learning¶
For this example, we will use the winequality dataset.
import vastorbit.datasets as vod data = vod.load_winequality()
123fixed_acidityDecimal(6, 3)123volatile_acidityDecimal(7, 4)123citric_acidDecimal(6, 3)123residual_sugarDecimal(7, 3)123chloridesDouble123free_sulfur_dioxideDecimal(7, 2)123total_sulfur_dioxideDecimal(7, 2)123densityDouble123phDecimal(6, 3)123sulphatesDecimal(6, 3)123alcoholDouble123qualityInteger123goodIntegerAbccolorVarchar(20)1 6.3 0.67 0.48 12.6 0.052 57.0 222.0 0.9979 3.17 0.52 9.3 6 0 white 2 7.4 0.4 0.29 5.4 0.044 31.0 122.0 0.994 3.3 0.5 11.1 8 1 white 3 7.1 0.26 0.31 2.2 0.044 29.0 128.0 0.9937 3.34 0.64 10.9 8 1 white 4 9.0 0.31 0.48 6.6 0.043 11.0 73.0 0.9938 2.9 0.38 11.6 5 0 white 5 6.3 0.39 0.24 6.9 0.069 9.0 117.0 0.9942 3.15 0.35 10.2 4 0 white 6 8.2 0.22 0.36 6.8 0.034 12.0 90.0 0.9944 3.01 0.38 10.5 8 1 white 7 7.1 0.19 0.28 3.6 0.033 16.0 78.0 0.993 2.91 0.78 11.4 6 0 white 8 7.3 0.25 0.36 13.1 0.05 35.0 200.0 0.9986 3.04 0.46 8.9 7 1 white 9 7.9 0.2 0.34 1.2 0.04 29.0 118.0 0.9932 3.14 0.41 10.6 6 0 white 10 7.1 0.26 0.32 5.9 0.037 39.0 97.0 0.9934 3.31 0.4 11.6 6 0 white 11 7.0 0.2 0.34 5.7 0.035 32.0 83.0 0.9928 3.19 0.46 11.5 6 0 white 12 6.9 0.3 0.33 4.1 0.035 26.0 155.0 0.9925 3.25 0.79 12.3 8 1 white 13 8.1 0.29 0.49 7.1 0.042 22.0 124.0 0.9944 3.14 0.41 10.8 6 0 white 14 5.8 0.17 0.3 1.4 0.037 55.0 130.0 0.9909 3.29 0.38 11.3 6 0 white 15 5.9 0.415 0.02 0.8 0.038 22.0 63.0 0.9932 3.36 0.36 9.3 5 0 white 16 6.6 0.23 0.26 1.3 0.045 16.0 128.0 0.9934 3.36 0.6 10.0 6 0 white 17 8.6 0.55 0.35 15.55 0.057 35.5 366.5 1.0001 3.04 0.63 11.0 3 0 white 18 6.9 0.35 0.74 1.0 0.044 18.0 132.0 0.992 3.13 0.55 10.2 5 0 white 19 7.6 0.14 0.74 1.6 0.04 27.0 103.0 0.9916 3.07 0.4 10.8 7 1 white 20 9.2 0.28 0.49 11.8 0.042 29.0 137.0 0.998 3.1 0.34 10.1 4 0 white 21 6.2 0.18 0.49 4.5 0.047 17.0 90.0 0.9919 3.27 0.37 11.6 6 0 white 22 5.3 0.165 0.24 1.1 0.051 25.0 105.0 0.9925 3.32 0.47 9.1 5 0 white 23 9.8 0.25 0.74 10.0 0.056 36.0 225.0 0.9977 3.06 0.43 10.0 4 0 white 24 8.1 0.29 0.49 7.1 0.042 22.0 124.0 0.9944 3.14 0.41 10.8 6 0 white 25 6.8 0.22 0.49 0.9 0.052 26.0 128.0 0.991 3.25 0.35 11.4 6 0 white 26 7.2 0.22 0.49 1.0 0.045 34.0 140.0 0.99 3.05 0.34 12.7 6 0 white 27 7.4 0.25 0.49 1.1 0.042 35.0 156.0 0.9917 3.13 0.55 11.3 5 0 white 28 8.2 0.18 0.49 1.1 0.033 28.0 81.0 0.9923 3.0 0.68 10.4 7 1 white 29 6.1 0.22 0.49 1.5 0.051 18.0 87.0 0.9928 3.3 0.46 9.6 5 0 white 30 7.0 0.39 0.24 1.0 0.048 8.0 119.0 0.9923 3.0 0.31 10.1 4 0 white 31 6.1 0.22 0.49 1.5 0.051 18.0 87.0 0.9928 3.3 0.46 9.6 5 0 white 32 6.5 0.36 0.49 2.9 0.03 16.0 94.0 0.9902 3.1 0.49 12.1 7 1 white 33 7.1 0.29 0.49 1.2 0.031 32.0 99.0 0.9893 3.07 0.33 12.2 6 0 white 34 7.4 0.25 0.49 1.1 0.042 35.0 156.0 0.9917 3.13 0.55 11.3 5 0 white 35 6.9 0.23 0.24 14.2 0.053 19.0 94.0 0.9982 3.17 0.5 9.6 5 0 white 36 8.5 0.56 0.74 17.85 0.051 51.0 243.0 1.0005 2.99 0.7 9.2 5 0 white 37 8.2 0.18 0.49 1.1 0.033 28.0 81.0 0.9923 3.0 0.68 10.4 7 1 white 38 6.3 0.23 0.49 7.1 0.05 67.0 210.0 0.9951 3.23 0.34 9.5 5 0 white 39 6.1 0.25 0.49 7.6 0.052 67.0 226.0 0.9956 3.16 0.47 8.9 5 0 white 40 7.2 0.26 0.74 13.6 0.05 56.0 162.0 0.998 3.03 0.44 8.8 5 0 white 41 7.2 0.31 0.24 1.4 0.057 17.0 117.0 0.9928 3.16 0.35 10.5 5 0 white 42 8.0 0.25 0.49 1.2 0.061 27.0 117.0 0.9938 3.08 0.34 9.4 5 0 white 43 7.0 0.18 0.49 5.3 0.04 34.0 125.0 0.9914 3.24 0.4 12.2 6 0 white 44 7.8 0.43 0.49 13.0 0.033 37.0 158.0 0.9955 3.14 0.35 11.3 6 0 white 45 8.3 0.2 0.74 4.45 0.044 33.0 130.0 0.9924 3.25 0.42 12.2 6 0 white 46 6.3 0.27 0.49 1.2 0.063 35.0 92.0 0.9911 3.38 0.42 12.2 6 0 white 47 7.4 0.16 0.49 1.2 0.055 18.0 150.0 0.9917 3.23 0.47 11.2 6 0 white 48 7.4 0.16 0.49 1.2 0.055 18.0 150.0 0.9917 3.23 0.47 11.2 6 0 white 49 6.9 0.19 0.49 6.6 0.036 49.0 172.0 0.9932 3.2 0.27 11.5 6 0 white 50 7.8 0.43 0.49 13.0 0.033 37.0 158.0 0.9955 3.14 0.35 11.3 6 0 white 51 7.2 0.4 0.49 1.1 0.048 11.0 138.0 0.9929 3.01 0.42 9.3 5 0 white 52 7.8 0.43 0.49 13.0 0.033 37.0 158.0 0.9955 3.14 0.35 11.3 6 0 white 53 7.6 0.52 0.49 14.0 0.034 37.0 156.0 0.9958 3.14 0.38 11.8 7 1 white 54 8.3 0.21 0.49 19.8 0.054 50.0 231.0 1.0012 2.99 0.54 9.2 5 0 white 55 6.9 0.34 0.74 11.2 0.069 44.0 150.0 0.9968 3.0 0.81 9.2 5 0 white 56 6.3 0.27 0.49 1.2 0.063 35.0 92.0 0.9911 3.38 0.42 12.2 6 0 white 57 8.3 0.2 0.74 4.45 0.044 33.0 130.0 0.9924 3.25 0.42 12.2 6 0 white 58 7.1 0.22 0.74 2.7 0.044 42.0 144.0 0.991 3.31 0.41 12.2 6 0 white 59 7.9 0.11 0.49 4.5 0.048 27.0 133.0 0.9946 3.24 0.42 10.6 6 0 white 60 8.5 0.17 0.74 3.6 0.05 29.0 128.0 0.9928 3.28 0.4 12.4 6 0 white 61 6.4 0.145 0.49 5.4 0.048 54.0 164.0 0.9946 3.56 0.44 10.8 6 0 white 62 7.4 0.16 0.49 1.2 0.055 18.0 150.0 0.9917 3.23 0.47 11.2 6 0 white 63 8.3 0.19 0.49 1.2 0.051 11.0 137.0 0.9918 3.06 0.46 11.0 6 0 white 64 8.0 0.44 0.49 9.1 0.031 46.0 151.0 0.9926 3.16 0.27 12.7 8 1 white 65 7.0 0.2 0.74 0.8 0.044 19.0 163.0 0.9931 3.46 0.53 10.2 5 0 white 66 6.9 0.19 0.49 6.6 0.036 49.0 172.0 0.9932 3.2 0.27 11.5 6 0 white 67 7.1 0.25 0.49 3.0 0.03 30.0 96.0 0.9903 3.13 0.39 12.3 7 1 white 68 6.5 0.24 0.24 1.6 0.046 15.0 60.0 0.9928 3.19 0.39 9.8 5 0 white 69 7.2 0.4 0.49 1.1 0.048 11.0 138.0 0.9929 3.01 0.42 9.3 5 0 white 70 7.6 0.52 0.49 14.0 0.034 37.0 156.0 0.9958 3.14 0.38 11.8 7 1 white 71 7.8 0.43 0.49 13.0 0.033 37.0 158.0 0.9955 3.14 0.35 11.3 6 0 white 72 7.8 0.21 0.49 1.35 0.052 6.0 48.0 0.9911 3.15 0.28 11.4 5 0 white 73 7.0 0.2 0.49 5.9 0.038 39.0 128.0 0.9938 3.21 0.48 10.8 6 0 white 74 6.9 0.25 0.24 3.6 0.057 13.0 85.0 0.9942 2.99 0.48 9.5 4 0 white 75 7.2 0.08 0.49 1.3 0.05 18.0 148.0 0.9945 3.46 0.44 10.2 6 0 white 76 7.1 0.85 0.49 8.7 0.028 40.0 184.0 0.9962 3.22 0.36 10.7 5 0 white 77 7.6 0.51 0.24 1.2 0.04 10.0 104.0 0.992 3.05 0.29 10.8 6 0 white 78 7.9 0.22 0.24 4.6 0.044 39.0 159.0 0.9927 2.99 0.28 11.5 6 0 white 79 7.7 0.16 0.49 2.0 0.056 20.0 124.0 0.9948 3.32 0.49 10.7 6 0 white 80 7.2 0.08 0.49 1.3 0.05 18.0 148.0 0.9945 3.46 0.44 10.2 6 0 white 81 6.6 0.25 0.24 1.7 0.048 26.0 124.0 0.9942 3.37 0.6 10.1 6 0 white 82 6.7 0.16 0.49 2.4 0.046 57.0 187.0 0.9952 3.62 0.81 10.4 6 0 white 83 6.9 0.25 0.24 3.6 0.057 13.0 85.0 0.9942 2.99 0.48 9.5 4 0 white 84 7.5 0.32 0.24 4.6 0.053 8.0 134.0 0.9958 3.14 0.5 9.1 3 0 white 85 7.4 0.28 0.49 1.5 0.034 20.0 126.0 0.9918 2.98 0.39 10.6 6 0 white 86 6.2 0.15 0.49 0.9 0.033 17.0 51.0 0.9932 3.3 0.7 9.4 6 0 white 87 6.7 0.25 0.74 19.4 0.054 44.0 169.0 1.0004 3.51 0.45 9.8 6 0 white 88 6.5 0.26 0.74 13.3 0.044 68.0 224.0 0.9972 3.18 0.54 9.5 6 0 white 89 7.9 0.16 0.74 17.85 0.037 52.0 187.0 0.9998 2.99 0.41 9.3 5 0 white 90 5.6 0.185 0.49 1.1 0.03 28.0 117.0 0.9918 3.55 0.45 10.3 6 0 white 91 7.5 0.2 0.49 1.3 0.031 8.0 97.0 0.9918 3.06 0.62 11.1 5 0 white 92 8.0 0.3 0.49 9.4 0.046 47.0 188.0 0.9964 3.14 0.48 10.0 5 0 white 93 8.0 0.34 0.49 9.0 0.033 39.0 180.0 0.9936 3.13 0.38 12.3 8 1 white 94 7.7 0.35 0.49 8.65 0.033 42.0 186.0 0.9931 3.14 0.38 12.4 8 1 white 95 7.6 0.29 0.49 9.6 0.03 45.0 197.0 0.9938 3.13 0.38 12.3 7 1 white 96 6.7 0.62 0.24 1.1 0.039 6.0 62.0 0.9934 3.41 0.32 10.4 5 0 white 97 6.8 0.27 0.49 1.2 0.044 35.0 126.0 0.99 3.13 0.48 12.1 7 1 white 98 7.7 0.27 0.49 1.8 0.041 23.0 86.0 0.9914 3.16 0.42 12.5 6 0 white 99 6.7 0.51 0.24 2.1 0.043 14.0 155.0 0.9904 3.22 0.6 13.0 6 0 white 100 7.4 0.19 0.49 9.3 0.03 26.0 132.0 0.994 2.99 0.32 11.0 7 1 white Rows: 1-100 | Columns: 14Note
vastorbit offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the vastorbit environment.
You can easily divide your dataset into training and testing subsets using the
VastFrame.train_test_split()method.data = vod.load_winequality() train, test = data.train_test_split(test_size = 0.2)
Model Initialization¶
First we import the
LinearRegressionmodel:from vastorbit.machine_learning.vast import LinearRegression
Then we can create the model:
model = LinearRegression( tol = 1e-6, fit_intercept = True, )
Model Training¶
We can now fit the model:
model.fit( train, [ "fixed_acidity", "volatile_acidity", "citric_acid", "residual_sugar", "chlorides", "density" ], "quality", test, )
Prediction¶
Prediction is straight-forward:
result = model.predict( test, [ "fixed_acidity", "volatile_acidity", "citric_acid", "residual_sugar", "chlorides", "density" ], "prediction", )
123fixed_acidityDecimal(6, 3)123volatile_acidityDecimal(7, 4)123citric_acidDecimal(6, 3)123residual_sugarDecimal(7, 3)123chloridesDouble123free_sulfur_dioxideDecimal(7, 2)123total_sulfur_dioxideDecimal(7, 2)123densityDouble123phDecimal(6, 3)123sulphatesDecimal(6, 3)123alcoholDouble123qualityInteger123goodIntegerAbccolorVarchar(20)123seedrandDecimal(26, 6)123predictionDouble1 7.4 0.7 0.0 1.9 0.076 11.0 34.0 0.9978 3.51 0.56 9.4 5 0 red 0.12 5.0160030375046745 2 7.8 0.76 0.04 2.3 0.092 15.0 54.0 0.997 3.26 0.65 9.8 5 0 red 0.11 5.154165628980678 3 7.4 0.66 0.0 1.8 0.075 13.0 40.0 0.9978 3.51 0.56 9.4 5 0 red 0.11 5.042160469606813 4 7.5 0.5 0.36 6.1 0.071 17.0 102.0 0.9978 3.35 0.8 10.5 5 0 red 0.18 5.321140644907786 5 8.5 0.49 0.11 2.3 0.084 9.0 67.0 0.9968 3.17 0.53 9.4 5 0 red 0.1 5.482509891283485 6 7.8 0.645 0.0 2.0 0.0819999999999999 8.0 16.0 0.9964 3.38 0.59 9.8 6 0 red 0.13 5.3193499127730774 7 6.9 0.605 0.12 10.7 0.073 40.0 83.0 0.9993 3.45 0.52 9.4 6 0 red 0.11 5.169084603365491 8 8.7 0.29 0.52 1.6 0.113 12.0 37.0 0.9969 3.25 0.58 9.5 5 0 red 0.11 5.567550140224029 9 6.4 0.4 0.23 1.6 0.066 5.0 12.0 0.9958 3.34 0.56 9.2 5 0 red 0.06 5.341099158553561 10 5.6 0.31 0.37 1.4 0.074 12.0 96.0 0.9954 3.32 0.58 9.2 5 0 red 0.07 5.322832083240257 11 7.5 0.63 0.12 5.1 0.111 50.0 110.0 0.9983 3.26 0.77 9.4 5 0 red 0.14 5.135049695149519 12 7.3 0.39 0.31 2.4 0.074 9.0 46.0 0.9962 3.41 0.54 9.4 6 0 red 0.07 5.448270388433826 13 7.5 0.52 0.16 1.9 0.085 12.0 35.0 0.9968 3.38 0.62 9.5 7 1 red 0.09 5.289546490791139 14 7.2 0.725 0.05 4.65 0.086 4.0 11.0 0.9962 3.41 0.39 10.9 5 0 red 0.04 5.307507777184554 15 9.3 0.32 0.57 2.0 0.074 27.0 65.0 0.9969 3.28 0.79 10.7 5 0 red 0.1 5.646053056178914 16 8.0 0.705 0.05 1.9 0.074 8.0 19.0 0.9962 3.34 0.95 10.5 6 0 red 0.08 5.321387905926201 17 7.7 0.69 0.22 1.9 0.084 18.0 94.0 0.9961 3.31 0.48 9.5 5 0 red 0.03 5.281616475657728 18 9.7 0.32 0.54 2.5 0.094 28.0 83.0 0.9984 3.28 0.82 9.6 5 0 red 0.17 5.515896944285089 19 8.3 0.625 0.2 1.5 0.08 27.0 119.0 0.9972 3.16 1.12 9.1 4 0 red 0.0 5.2481234461306485 20 6.2 0.45 0.2 1.6 0.069 3.0 15.0 0.9958 3.41 0.56 9.2 5 0 red 0.12 5.277245528785613 21 7.3 0.67 0.26 1.8 0.401 16.0 51.0 0.9969 3.16 1.14 9.4 5 0 red 0.04 5.097760906235635 22 8.6 0.49 0.28 1.9 0.11 20.0 136.0 0.9972 2.93 1.95 9.9 6 0 red 0.08 5.4007071371740665 23 7.0 0.62 0.08 1.8 0.076 8.0 24.0 0.9978 3.48 0.53 9.0 5 0 red 0.09 5.0040916109269915 24 8.6 0.49 0.28 1.9 0.11 20.0 136.0 0.9972 2.93 1.95 9.9 6 0 red 0.09 5.4007071371740665 25 4.7 0.6 0.17 2.3 0.0579999999999999 17.0 106.0 0.9932 3.85 0.6 12.9 6 0 red 0.17 5.347151597133632 26 8.0 0.33 0.53 2.5 0.091 18.0 80.0 0.9976 3.37 0.8 9.6 6 0 red 0.14 5.37409888945902 27 10.1 0.31 0.44 2.3 0.08 22.0 46.0 0.9988 3.32 0.67 9.7 6 0 red 0.14 5.529700086968404 28 7.8 0.56 0.12 2.0 0.0819999999999999 7.0 28.0 0.997 3.37 0.5 9.4 6 0 red 0.14 5.284089412034518 29 6.1 0.38 0.15 1.8 0.072 6.0 19.0 0.9955 3.42 0.57 9.4 5 0 red 0.14 5.373109138619384 30 7.2 0.415 0.36 2.0 0.081 13.0 45.0 0.9972 3.48 0.64 9.2 5 0 red 0.0 5.248678421520566 31 7.6 0.49 0.26 1.6 0.236 10.0 88.0 0.9968 3.11 0.8 9.3 5 0 red 0.09 5.2933875751626545 32 7.3 0.33 0.47 2.1 0.077 5.0 11.0 0.9958 3.33 0.53 10.3 6 0 red 0.12 5.517934714577137 33 7.1 0.43 0.42 5.5 0.07 29.0 129.0 0.9973 3.42 0.72 10.5 5 0 red 0.18 5.3534592107420735 34 6.8 0.6 0.18 1.9 0.079 18.0 86.0 0.9968 3.59 0.57 9.3 6 0 red 0.13 5.123930333905605 35 7.6 0.95 0.03 2.0 0.09 7.0 20.0 0.9959 3.2 0.56 9.6 5 0 red 0.16 5.1248240023767835 36 7.3 0.59 0.26 7.2 0.07 35.0 121.0 0.9981 3.37 0.49 9.4 5 0 red 0.04 5.240758743954018 37 7.2 0.73 0.02 2.5 0.076 16.0 42.0 0.9972 3.44 0.52 9.3 5 0 red 0.11 5.072646889188235 38 7.9 0.5 0.33 2.0 0.084 15.0 143.0 0.9968 3.2 0.55 9.5 5 0 red 0.19 5.346939180082984 39 7.8 0.59 0.33 2.0 0.074 24.0 120.0 0.9968 3.25 0.54 9.4 5 0 red 0.06 5.264345038505667 40 7.0 0.43 0.36 1.6 0.089 14.0 37.0 0.99615 3.34 0.56 9.2 6 0 red 0.11 5.339289262376383 41 7.8 0.44 0.28 2.7 0.1 18.0 95.0 0.9966 3.22 0.67 9.4 5 0 red 0.18 5.441956284457149 42 11.0 0.3 0.58 2.1 0.054 7.0 19.0 0.998 3.31 0.88 10.5 7 1 red 0.01 5.758462074287053 43 11.6 0.44 0.64 2.1 0.059 5.0 15.0 0.998 3.21 0.67 10.2 6 0 red 0.07 5.732241847565831 44 7.0 0.49 0.49 5.6 0.06 26.0 121.0 0.9974 3.34 0.76 10.5 5 0 red 0.06 5.275240156780228 45 6.8 0.61 0.04 1.5 0.057 5.0 10.0 0.99525 3.42 0.6 9.5 5 0 red 0.1 5.337521758380177 46 7.7 0.43 0.25 2.6 0.073 29.0 63.0 0.99615 3.37 0.58 10.5 6 0 red 0.15 5.499662096103606 47 8.2 1.0 0.09 2.3 0.065 7.0 37.0 0.99685 3.32 0.55 9.0 6 0 red 0.08 5.046833210997164 48 7.2 0.63 0.0 1.9 0.0969999999999999 14.0 38.0 0.99675 3.37 0.58 9.0 6 0 red 0.1 5.187927239087713 49 15.0 0.21 0.44 2.2 0.075 10.0 24.0 1.00005 3.07 0.84 9.2 7 1 red 0.16 6.142504562720916 50 9.0 0.31 0.48 6.6 0.043 11.0 73.0 0.9938 2.9 0.38 11.6 5 0 white 0.07 6.262277673240931 51 6.3 0.39 0.24 6.9 0.069 9.0 117.0 0.9942 3.15 0.35 10.2 4 0 white 0.05 5.789798179270804 52 8.2 0.22 0.36 6.8 0.034 12.0 90.0 0.9944 3.01 0.38 10.5 8 1 white 0.11 6.152166326034205 53 5.8 0.17 0.3 1.4 0.037 55.0 130.0 0.9909 3.29 0.38 11.3 6 0 white 0.16 6.108488144047726 54 5.3 0.165 0.24 1.1 0.051 25.0 105.0 0.9925 3.32 0.47 9.1 5 0 white 0.11 5.805312374789622 55 6.1 0.22 0.49 1.5 0.051 18.0 87.0 0.9928 3.3 0.46 9.6 5 0 white 0.19 5.824799592249121 56 6.1 0.25 0.49 7.6 0.052 67.0 226.0 0.9956 3.16 0.47 8.9 5 0 white 0.07 5.668798745054744 57 7.2 0.31 0.24 1.4 0.057 17.0 117.0 0.9928 3.16 0.35 10.5 5 0 white 0.01 5.943567170561323 58 8.3 0.2 0.74 4.45 0.044 33.0 130.0 0.9924 3.25 0.42 12.2 6 0 white 0.07 6.31701016384082 59 7.6 0.52 0.49 14.0 0.034 37.0 156.0 0.9958 3.14 0.38 11.8 7 1 white 0.03 5.933410044071763 60 6.9 0.34 0.74 11.2 0.069 44.0 150.0 0.9968 3.0 0.81 9.2 5 0 white 0.04 5.671675605966783 61 8.3 0.2 0.74 4.45 0.044 33.0 130.0 0.9924 3.25 0.42 12.2 6 0 white 0.19 6.31701016384082 62 6.4 0.145 0.49 5.4 0.048 54.0 164.0 0.9946 3.56 0.44 10.8 6 0 white 0.01 5.839514114120476 63 7.8 0.43 0.49 13.0 0.033 37.0 158.0 0.9955 3.14 0.35 11.3 6 0 white 0.07 6.030509331287192 64 7.2 0.08 0.49 1.3 0.05 18.0 148.0 0.9945 3.46 0.44 10.2 6 0 white 0.07 5.842511014648437 65 6.7 0.16 0.49 2.4 0.046 57.0 187.0 0.9952 3.62 0.81 10.4 6 0 white 0.14 5.6568435794747245 66 7.4 0.28 0.49 1.5 0.034 20.0 126.0 0.9918 2.98 0.39 10.6 6 0 white 0.09 6.11269027188132 67 7.7 0.27 0.49 1.8 0.041 23.0 86.0 0.9914 3.16 0.42 12.5 6 0 white 0.13 6.2337171194849645 68 8.1 0.2 0.49 8.1 0.051 51.0 205.0 0.9954 3.1 0.52 11.0 6 0 white 0.08 6.050185950292473 69 7.8 0.26 0.74 7.5 0.044 59.0 160.0 0.996 3.22 0.64 10.0 6 0 white 0.14 5.819017472263283 70 8.3 0.2 0.49 1.7 0.038 38.0 167.0 0.9939 3.05 0.37 10.1 6 0 white 0.07 6.015682142899465 71 6.6 0.3 0.24 1.2 0.034 17.0 121.0 0.9933 3.13 0.36 9.2 5 0 white 0.02 5.784802230256162 72 8.0 0.25 0.49 9.0 0.044 31.0 185.0 0.998 3.34 0.49 10.0 6 0 white 0.01 5.667609235351335 73 6.6 0.21 0.49 18.15 0.042 41.0 158.0 0.9997 3.28 0.39 8.7 6 0 white 0.02 5.648343348656454 74 7.9 0.28 0.49 7.7 0.045 48.0 195.0 0.9954 3.04 0.55 11.0 6 0 white 0.14 5.942970864378907 75 7.4 0.27 0.49 1.1 0.037 33.0 156.0 0.992 3.15 0.54 11.1 6 0 white 0.15 6.074376999092294 76 7.1 0.18 0.74 15.6 0.044 44.0 176.0 0.9996 3.38 0.67 9.0 6 0 white 0.02 5.6172850726999 77 6.0 0.17 0.49 1.0 0.034 26.0 106.0 0.992 3.21 0.42 9.8 6 0 white 0.07 5.941072781921491 78 7.2 0.16 0.49 1.3 0.037 27.0 104.0 0.9924 3.23 0.57 10.6 6 0 white 0.04 6.0806273399980455 79 7.3 0.14 0.49 1.1 0.038 28.0 99.0 0.9928 3.2 0.72 10.6 6 0 white 0.16 6.044961902634725 80 7.9 0.12 0.49 5.2 0.049 33.0 152.0 0.9952 3.18 0.47 10.6 6 0 white 0.01 5.984478138136694 81 8.5 0.15 0.49 1.5 0.031 17.0 122.0 0.9932 3.03 0.4 10.3 6 0 white 0.19 6.174188240804256 82 7.3 0.21 0.49 1.8 0.038 44.0 152.0 0.9912 3.32 0.44 12.6 7 1 white 0.05 6.249312066144881 83 7.9 0.18 0.49 5.2 0.051 36.0 157.0 0.9953 3.18 0.48 10.6 6 0 white 0.02 5.9245045492462225 84 7.8 0.3 0.74 1.8 0.033 33.0 156.0 0.991 3.29 0.52 12.8 6 0 white 0.13 6.252131640149116 85 7.8 0.3 0.74 1.8 0.033 33.0 156.0 0.991 3.29 0.52 12.8 6 0 white 0.03 6.252131640149116 86 6.7 0.3 0.74 5.0 0.038 35.0 157.0 0.9945 3.21 0.46 9.9 5 0 white 0.02 5.732274426181135 87 6.6 0.3 0.74 4.6 0.041 36.0 159.0 0.9946 3.21 0.45 9.9 5 0 white 0.1 5.685895451259711 88 6.8 0.17 0.74 2.4 0.053 61.0 182.0 0.9953 3.63 0.76 10.5 6 0 white 0.14 5.618628878766344 89 7.0 0.27 0.74 1.5 0.036 27.0 122.0 0.9926 3.35 0.48 11.2 6 0 white 0.13 5.917250325736319 90 6.9 0.27 0.49 23.5 0.057 59.0 235.0 1.0024 2.98 0.47 8.6 5 0 white 0.03 5.494388150204742 91 7.5 0.32 0.49 1.7 0.031 44.0 109.0 0.9906 3.07 0.46 12.5 6 0 white 0.02 6.2761941594745565 92 7.8 0.26 0.49 3.2 0.027 28.0 87.0 0.9919 3.03 0.32 11.3 7 1 white 0.06 6.246468465176122 93 8.9 0.32 0.49 1.6 0.05 17.0 131.0 0.9956 3.13 0.34 9.4 5 0 white 0.07 5.765857140803007 94 7.0 0.14 0.49 5.9 0.053 22.0 118.0 0.9954 3.36 0.36 9.4 6 0 white 0.11 5.839057104010095 95 7.8 0.15 0.24 7.7 0.047 21.0 98.0 0.9951 2.94 0.31 9.6 6 0 white 0.12 6.100412451506088 96 6.9 0.25 0.24 1.8 0.053 6.0 121.0 0.993 3.23 0.7 11.4 5 0 white 0.09 5.934412427243586 97 8.1 0.12 0.49 1.2 0.042 43.0 160.0 0.9934 3.13 0.48 9.7 6 0 white 0.1 6.096351271957161 98 7.3 0.19 0.49 15.55 0.058 50.0 134.0 0.9998 3.42 0.36 9.1 7 1 white 0.01 5.638315272647333 99 7.5 0.24 0.49 9.4 0.048 50.0 149.0 0.9962 3.17 0.59 10.5 7 1 white 0.11 5.874714492249041 100 6.9 0.26 0.49 1.6 0.058 39.0 166.0 0.9965 3.65 0.52 9.4 4 0 white 0.1 5.390052860592874 Rows: 1-100 | Columns: 16Score¶
Finally we can calculate the scores:
# R2 result.score("quality", "prediction", metric = "r2") # MSE result.score("quality", "prediction", metric = "mse") # Max Error result.score("quality", "prediction", metric = "max")
Note
If the prediction is already part of the dataset, there is no need to use a model to compute a prediction column. Use your column directly.
See also
LinearRegression: Linear Regression model.