Note
Go to the end to download the full example code.
Cache mechanism#
This example shows how EstimatorReport and
CrossValidationReport use caching to speed up computations.
Generating some data#
In this toy example, we create a large synthetic classification dataset that will let us see speed improvements easily.
import pandas as pd
from sklearn.datasets import make_classification
X, y = make_classification(n_samples=150_000, return_X_y=True)
X = pd.DataFrame(X, columns=[str(i) for i in range(X.shape[1])])
Here is what the training data looks like:
from skrub import TableReport
TableReport(X)
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | -1.10 | -0.213 | 0.108 | -0.249 | 0.0899 | 1.09 | -0.579 | -0.0326 | -0.851 | 1.03 | -0.377 | 0.0677 | 1.01 | 0.598 | -1.68 | 0.183 | 0.703 | 0.470 | 0.614 | 0.450 |
| 1 | 1.54 | -2.19 | -0.570 | -0.479 | -1.37 | 1.05 | 1.55 | 1.27 | -0.0900 | -0.557 | -0.410 | -1.49 | -1.39 | 0.114 | -0.440 | -1.27 | -0.0721 | -0.314 | -1.32 | 0.622 |
| 2 | 0.932 | 1.59 | -0.998 | -0.683 | 1.30 | 1.96 | 0.565 | 0.326 | 0.422 | -1.16 | -0.728 | -0.743 | -0.829 | 1.63 | -0.708 | -0.490 | 0.545 | 1.95 | 0.803 | 0.859 |
| 3 | -2.25 | 1.18 | -0.673 | -0.0432 | -0.978 | 1.21 | 0.895 | -0.606 | 0.801 | -0.935 | -0.374 | 1.89 | 0.402 | 0.937 | -1.09 | 2.70 | 1.51 | 0.103 | 0.818 | 1.30 |
| 4 | -0.337 | 0.875 | -0.503 | -0.535 | 1.10 | 1.31 | 0.00636 | 0.410 | -1.53 | 0.398 | -0.502 | 1.06 | 0.197 | -1.50 | 0.627 | 0.0458 | 0.117 | -0.358 | 1.01 | -0.714 |
| 149,995 | -1.22 | 0.614 | -0.905 | -0.604 | -1.37 | 1.71 | 2.63 | 0.396 | -0.404 | -1.18 | -0.634 | 0.309 | -0.0939 | 0.236 | -0.500 | -1.09 | 0.438 | -0.0422 | 1.04 | 0.197 |
| 149,996 | -0.812 | -0.218 | -0.0514 | 0.0279 | -1.60 | -0.553 | 0.881 | -2.06 | 0.390 | -1.28 | 0.173 | 0.455 | -0.469 | 1.17 | 1.13 | -0.915 | -0.669 | -0.155 | -0.405 | -0.241 |
| 149,997 | -0.757 | -1.99 | -0.0593 | 1.29 | 1.18 | -1.21 | -0.719 | 0.223 | -0.342 | -0.535 | 0.617 | 0.753 | 0.610 | 0.0123 | -1.52 | -1.39 | 2.39 | -1.36 | -0.130 | 0.340 |
| 149,998 | 0.160 | -0.273 | 0.989 | 0.239 | -0.517 | -1.58 | -0.741 | 1.07 | -0.447 | 0.598 | 0.524 | -0.731 | -0.0836 | 0.247 | 1.09 | 1.21 | -1.41 | 0.245 | -0.0245 | -0.395 |
| 149,999 | -2.20 | 0.802 | -0.252 | -0.963 | 0.000954 | 1.49 | 0.919 | -0.355 | -1.89 | 0.466 | -0.638 | 1.64 | 1.77 | 0.00257 | 1.33 | 0.917 | -0.979 | -0.698 | 0.736 | -0.542 |
0
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.000938 ± 1.00
- Median ± IQR
- 0.00424 ± 1.35
- Min | Max
- -4.20 | 4.32
1
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00186 ± 1.00
- Median ± IQR
- 0.00142 ± 1.35
- Min | Max
- -4.70 | 4.26
2
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00128 ± 1.00
- Median ± IQR
- 0.000512 ± 1.36
- Min | Max
- -4.21 | 4.25
3
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00215 ± 0.690
- Median ± IQR
- 0.0124 ± 1.01
- Min | Max
- -2.59 | 2.87
4
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00196 ± 1.00
- Median ± IQR
- 0.00121 ± 1.35
- Min | Max
- -4.20 | 4.38
5
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00260 ± 1.27
- Median ± IQR
- -0.0154 ± 2.02
- Min | Max
- -4.29 | 4.82
6
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00192 ± 1.00
- Median ± IQR
- -0.00405 ± 1.35
- Min | Max
- -4.79 | 4.42
7
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00144 ± 1.00
- Median ± IQR
- 0.00497 ± 1.35
- Min | Max
- -4.26 | 4.41
8
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00343 ± 1.00
- Median ± IQR
- 0.00392 ± 1.35
- Min | Max
- -4.28 | 4.14
9
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.000993 ± 1.00
- Median ± IQR
- -0.000703 ± 1.35
- Min | Max
- -4.36 | 4.65
10
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00120 ± 0.495
- Median ± IQR
- 0.0121 ± 0.793
- Min | Max
- -1.88 | 1.83
11
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00196 ± 0.998
- Median ± IQR
- 0.00264 ± 1.35
- Min | Max
- -4.08 | 4.34
12
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00248 ± 1.01
- Median ± IQR
- -0.000998 ± 1.36
- Min | Max
- -4.11 | 4.69
13
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00161 ± 1.00
- Median ± IQR
- -0.00247 ± 1.35
- Min | Max
- -4.27 | 4.24
14
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.000537 ± 0.999
- Median ± IQR
- 0.00181 ± 1.35
- Min | Max
- -4.71 | 4.21
15
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -3.73e-05 ± 1.00
- Median ± IQR
- -0.000103 ± 1.36
- Min | Max
- -4.59 | 4.36
16
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00317 ± 1.36
- Median ± IQR
- -0.198 ± 2.07
- Min | Max
- -5.42 | 5.24
17
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.000367 ± 0.996
- Median ± IQR
- -0.00302 ± 1.34
- Min | Max
- -4.02 | 4.21
18
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00290 ± 0.998
- Median ± IQR
- -0.00265 ± 1.34
- Min | Max
- -4.14 | 4.87
19
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00314 ± 1.00
- Median ± IQR
- 0.00309 ± 1.35
- Min | Max
- -4.38 | 4.19
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.000938 | 1.00 | -4.20 | 0.00424 | 4.32 |
| 1 | 1 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00186 | 1.00 | -4.70 | 0.00142 | 4.26 |
| 2 | 2 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00128 | 1.00 | -4.21 | 0.000512 | 4.25 |
| 3 | 3 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00215 | 0.690 | -2.59 | 0.0124 | 2.87 |
| 4 | 4 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00196 | 1.00 | -4.20 | 0.00121 | 4.38 |
| 5 | 5 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00260 | 1.27 | -4.29 | -0.0154 | 4.82 |
| 6 | 6 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00192 | 1.00 | -4.79 | -0.00405 | 4.42 |
| 7 | 7 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00144 | 1.00 | -4.26 | 0.00497 | 4.41 |
| 8 | 8 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00343 | 1.00 | -4.28 | 0.00392 | 4.14 |
| 9 | 9 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.000993 | 1.00 | -4.36 | -0.000703 | 4.65 |
| 10 | 10 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00120 | 0.495 | -1.88 | 0.0121 | 1.83 |
| 11 | 11 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00196 | 0.998 | -4.08 | 0.00264 | 4.34 |
| 12 | 12 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00248 | 1.01 | -4.11 | -0.000998 | 4.69 |
| 13 | 13 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00161 | 1.00 | -4.27 | -0.00247 | 4.24 |
| 14 | 14 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.000537 | 0.999 | -4.71 | 0.00181 | 4.21 |
| 15 | 15 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -3.73e-05 | 1.00 | -4.59 | -0.000103 | 4.36 |
| 16 | 16 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00317 | 1.36 | -5.42 | -0.198 | 5.24 |
| 17 | 17 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.000367 | 0.996 | -4.02 | -0.00302 | 4.21 |
| 18 | 18 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | -0.00290 | 0.998 | -4.14 | -0.00265 | 4.87 |
| 19 | 19 | Float64DType | False | 0 (0.0%) | 150000 (100.0%) | 0.00314 | 1.00 | -4.38 | 0.00309 | 4.19 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
0
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.000938 ± 1.00
- Median ± IQR
- 0.00424 ± 1.35
- Min | Max
- -4.20 | 4.32
1
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00186 ± 1.00
- Median ± IQR
- 0.00142 ± 1.35
- Min | Max
- -4.70 | 4.26
2
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00128 ± 1.00
- Median ± IQR
- 0.000512 ± 1.36
- Min | Max
- -4.21 | 4.25
3
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00215 ± 0.690
- Median ± IQR
- 0.0124 ± 1.01
- Min | Max
- -2.59 | 2.87
4
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00196 ± 1.00
- Median ± IQR
- 0.00121 ± 1.35
- Min | Max
- -4.20 | 4.38
5
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00260 ± 1.27
- Median ± IQR
- -0.0154 ± 2.02
- Min | Max
- -4.29 | 4.82
6
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00192 ± 1.00
- Median ± IQR
- -0.00405 ± 1.35
- Min | Max
- -4.79 | 4.42
7
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00144 ± 1.00
- Median ± IQR
- 0.00497 ± 1.35
- Min | Max
- -4.26 | 4.41
8
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00343 ± 1.00
- Median ± IQR
- 0.00392 ± 1.35
- Min | Max
- -4.28 | 4.14
9
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.000993 ± 1.00
- Median ± IQR
- -0.000703 ± 1.35
- Min | Max
- -4.36 | 4.65
10
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00120 ± 0.495
- Median ± IQR
- 0.0121 ± 0.793
- Min | Max
- -1.88 | 1.83
11
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00196 ± 0.998
- Median ± IQR
- 0.00264 ± 1.35
- Min | Max
- -4.08 | 4.34
12
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00248 ± 1.01
- Median ± IQR
- -0.000998 ± 1.36
- Min | Max
- -4.11 | 4.69
13
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00161 ± 1.00
- Median ± IQR
- -0.00247 ± 1.35
- Min | Max
- -4.27 | 4.24
14
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.000537 ± 0.999
- Median ± IQR
- 0.00181 ± 1.35
- Min | Max
- -4.71 | 4.21
15
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -3.73e-05 ± 1.00
- Median ± IQR
- -0.000103 ± 1.36
- Min | Max
- -4.59 | 4.36
16
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00317 ± 1.36
- Median ± IQR
- -0.198 ± 2.07
- Min | Max
- -5.42 | 5.24
17
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.000367 ± 0.996
- Median ± IQR
- -0.00302 ± 1.34
- Min | Max
- -4.02 | 4.21
18
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- -0.00290 ± 0.998
- Median ± IQR
- -0.00265 ± 1.34
- Min | Max
- -4.14 | 4.87
19
Float64DType- Null values
- 0 (0.0%)
- Unique values
-
150,000 (100.0%)
This column has a high cardinality (> 40).
- Mean ± Std
- 0.00314 ± 1.00
- Median ± IQR
- 0.00309 ± 1.35
- Min | Max
- -4.38 | 4.19
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
| Column 1 | Column 2 | Cramér's V | Pearson's Correlation |
|---|---|---|---|
| 5 | 10 | 0.724 | -0.986 |
| 3 | 10 | 0.526 | 0.880 |
| 3 | 5 | 0.391 | -0.787 |
| 3 | 16 | 0.273 | 0.614 |
| 10 | 16 | 0.143 | 0.165 |
| 5 | 16 | 0.126 | 0.00364 |
| 7 | 14 | 0.105 | 0.0308 |
| 7 | 15 | 0.0750 | -0.0252 |
| 14 | 19 | 0.0721 | -0.0133 |
| 16 | 19 | 0.0720 | -0.00821 |
| 6 | 18 | 0.0663 | 0.000230 |
| 15 | 19 | 0.0654 | 0.0211 |
| 0 | 13 | 0.0648 | -0.00531 |
| 7 | 17 | 0.0646 | -0.0120 |
| 9 | 17 | 0.0645 | -0.0103 |
| 13 | 17 | 0.0645 | 0.0122 |
| 5 | 12 | 0.0635 | -0.0266 |
| 8 | 13 | 0.0633 | -0.00955 |
| 16 | 18 | 0.0632 | -0.000409 |
| 1 | 14 | 0.0625 | -0.0140 |
| 3 | 18 | 0.0618 | 0.00124 |
| 9 | 19 | 0.0606 | 0.0115 |
| 10 | 19 | 0.0595 | -0.00457 |
| 2 | 3 | 0.0595 | -0.00572 |
| 9 | 18 | 0.0590 | -0.0191 |
| 7 | 16 | 0.0590 | -0.00632 |
| 1 | 5 | 0.0587 | 0.000417 |
| 18 | 19 | 0.0584 | -0.0441 |
| 0 | 19 | 0.0581 | 0.00238 |
| 4 | 7 | 0.0581 | -0.00619 |
| 2 | 16 | 0.0571 | 0.00134 |
| 11 | 12 | 0.0571 | 0.0317 |
| 2 | 5 | 0.0570 | 0.00829 |
| 0 | 4 | 0.0570 | 0.0211 |
| 12 | 18 | 0.0569 | 0.0190 |
| 3 | 19 | 0.0568 | -0.00761 |
| 5 | 6 | 0.0564 | -0.0124 |
| 0 | 3 | 0.0562 | -0.0299 |
| 1 | 6 | 0.0562 | -0.00541 |
| 3 | 15 | 0.0561 | -0.00311 |
| 6 | 10 | 0.0559 | 0.0153 |
| 6 | 14 | 0.0557 | -0.0159 |
| 6 | 13 | 0.0557 | -0.0456 |
| 5 | 19 | 0.0555 | 0.00323 |
| 6 | 15 | 0.0555 | -0.00337 |
| 2 | 19 | 0.0553 | 0.0106 |
| 0 | 11 | 0.0552 | 0.0170 |
| 12 | 19 | 0.0552 | 0.0128 |
| 0 | 5 | 0.0551 | 0.0277 |
| 4 | 13 | 0.0546 | 0.00109 |
| 0 | 10 | 0.0546 | -0.0295 |
| 6 | 19 | 0.0545 | -0.0123 |
| 8 | 16 | 0.0545 | -0.00144 |
| 5 | 8 | 0.0543 | 0.00810 |
| 2 | 18 | 0.0541 | 0.0108 |
| 15 | 16 | 0.0540 | 0.00469 |
| 9 | 11 | 0.0539 | -0.00130 |
| 5 | 11 | 0.0539 | -0.00111 |
| 0 | 2 | 0.0537 | -0.00484 |
| 15 | 17 | 0.0537 | 0.0245 |
| 2 | 9 | 0.0536 | 0.00634 |
| 12 | 13 | 0.0535 | -0.0168 |
| 10 | 12 | 0.0534 | 0.0279 |
| 4 | 5 | 0.0533 | -0.0165 |
| 6 | 11 | 0.0533 | 0.0160 |
| 1 | 16 | 0.0533 | -0.00482 |
| 17 | 19 | 0.0532 | -0.0600 |
| 12 | 17 | 0.0531 | 0.0488 |
| 0 | 14 | 0.0530 | -0.0286 |
| 4 | 19 | 0.0530 | 0.0257 |
| 10 | 13 | 0.0529 | 0.0161 |
| 0 | 7 | 0.0528 | -0.0204 |
| 11 | 19 | 0.0526 | 0.0463 |
| 3 | 7 | 0.0525 | -0.0180 |
| 4 | 18 | 0.0525 | -0.0220 |
| 2 | 4 | 0.0524 | -0.0229 |
| 8 | 11 | 0.0523 | 0.0427 |
| 5 | 14 | 0.0523 | -0.00421 |
| 2 | 7 | 0.0523 | 0.0105 |
| 9 | 10 | 0.0523 | 0.0294 |
| 1 | 12 | 0.0522 | 0.00313 |
| 2 | 10 | 0.0522 | -0.00795 |
| 5 | 15 | 0.0521 | 0.00760 |
| 14 | 18 | 0.0521 | 0.0120 |
| 2 | 8 | 0.0521 | 0.000876 |
| 6 | 12 | 0.0521 | -0.00897 |
| 14 | 15 | 0.0520 | 0.0467 |
| 11 | 13 | 0.0519 | -0.0131 |
| 3 | 13 | 0.0518 | 0.00481 |
| 10 | 14 | 0.0516 | 0.00721 |
| 7 | 11 | 0.0513 | -0.0173 |
| 1 | 15 | 0.0512 | -0.0128 |
| 3 | 9 | 0.0512 | 0.0109 |
| 8 | 12 | 0.0512 | -0.0133 |
| 10 | 11 | 0.0511 | -0.00158 |
| 7 | 10 | 0.0510 | -0.0187 |
| 3 | 6 | 0.0510 | 0.0208 |
| 11 | 15 | 0.0510 | 0.0210 |
| 12 | 14 | 0.0509 | 0.00432 |
| 4 | 12 | 0.0509 | 0.00147 |
| 2 | 12 | 0.0509 | -0.0199 |
| 1 | 9 | 0.0508 | 0.00781 |
| 0 | 1 | 0.0508 | 0.0233 |
| 0 | 9 | 0.0507 | -0.0169 |
| 2 | 14 | 0.0506 | -0.0130 |
| 8 | 15 | 0.0506 | -0.000536 |
| 13 | 14 | 0.0505 | -0.0227 |
| 2 | 17 | 0.0505 | 0.00850 |
| 13 | 16 | 0.0503 | -0.0168 |
| 11 | 16 | 0.0502 | -0.0159 |
| 1 | 11 | 0.0501 | -0.00720 |
| 4 | 10 | 0.0499 | 0.0131 |
| 7 | 8 | 0.0497 | -0.00450 |
| 3 | 11 | 0.0496 | -0.00893 |
| 2 | 13 | 0.0496 | 0.0393 |
| 1 | 10 | 0.0496 | -0.00122 |
| 10 | 15 | 0.0496 | -0.00671 |
| 13 | 19 | 0.0495 | -0.0189 |
| 6 | 9 | 0.0494 | 2.94e-05 |
| 10 | 18 | 0.0493 | 0.00180 |
| 1 | 4 | 0.0493 | 0.0240 |
| 6 | 8 | 0.0493 | -0.0222 |
| 8 | 14 | 0.0493 | 0.00245 |
| 14 | 16 | 0.0493 | 0.0182 |
| 11 | 14 | 0.0492 | -0.0357 |
| 16 | 17 | 0.0492 | 0.0109 |
| 3 | 14 | 0.0491 | 0.0146 |
| 2 | 6 | 0.0491 | 0.00254 |
| 6 | 7 | 0.0491 | 0.0195 |
| 8 | 19 | 0.0488 | 0.0115 |
| 9 | 14 | 0.0488 | -0.00638 |
| 1 | 7 | 0.0488 | -0.00132 |
| 2 | 11 | 0.0485 | -0.00532 |
| 3 | 12 | 0.0484 | 0.0270 |
| 1 | 19 | 0.0484 | 0.0137 |
| 7 | 12 | 0.0484 | 0.0236 |
| 3 | 17 | 0.0483 | 0.0131 |
| 1 | 18 | 0.0482 | -0.0112 |
| 4 | 15 | 0.0480 | -0.0212 |
| 0 | 17 | 0.0479 | -0.0121 |
| 7 | 13 | 0.0479 | -0.0224 |
| 5 | 9 | 0.0479 | -0.0343 |
| 8 | 18 | 0.0478 | -0.00769 |
| 13 | 15 | 0.0477 | -0.00860 |
| 15 | 18 | 0.0476 | -0.00718 |
| 1 | 8 | 0.0476 | 0.0333 |
| 0 | 12 | 0.0476 | 0.000482 |
| 5 | 7 | 0.0476 | 0.0179 |
| 17 | 18 | 0.0471 | 4.41e-06 |
| 9 | 16 | 0.0469 | -0.0262 |
| 6 | 16 | 0.0469 | 0.0179 |
| 1 | 3 | 0.0467 | -0.00330 |
| 13 | 18 | 0.0467 | -0.00804 |
| 7 | 9 | 0.0466 | -0.00290 |
| 9 | 13 | 0.0465 | -0.0426 |
| 10 | 17 | 0.0465 | 0.00978 |
| 11 | 18 | 0.0464 | -0.0288 |
| 6 | 17 | 0.0464 | -0.0552 |
| 12 | 16 | 0.0463 | 0.00969 |
| 4 | 6 | 0.0462 | 0.00522 |
| 8 | 17 | 0.0461 | -0.0209 |
| 9 | 15 | 0.0460 | -0.00818 |
| 3 | 8 | 0.0460 | -0.00728 |
| 14 | 17 | 0.0460 | -0.00560 |
| 4 | 17 | 0.0459 | -0.0162 |
| 0 | 16 | 0.0459 | -0.0130 |
| 9 | 12 | 0.0458 | 0.0176 |
| 1 | 2 | 0.0458 | 0.00408 |
| 5 | 18 | 0.0457 | -0.00189 |
| 7 | 18 | 0.0454 | -0.00776 |
| 4 | 16 | 0.0452 | -0.0187 |
| 8 | 9 | 0.0451 | 0.00543 |
| 0 | 18 | 0.0449 | 0.0303 |
| 5 | 17 | 0.0448 | -0.00806 |
| 0 | 6 | 0.0445 | 0.000870 |
| 4 | 14 | 0.0443 | -0.0104 |
| 2 | 15 | 0.0443 | -0.0117 |
| 1 | 13 | 0.0438 | -0.0178 |
| 7 | 19 | 0.0434 | -0.00853 |
| 8 | 10 | 0.0428 | -0.00823 |
| 5 | 13 | 0.0428 | -0.0192 |
| 0 | 15 | 0.0427 | -0.00656 |
| 4 | 9 | 0.0427 | 0.000825 |
| 3 | 4 | 0.0426 | 0.00148 |
| 0 | 8 | 0.0425 | 0.0121 |
| 4 | 8 | 0.0424 | 0.0156 |
| 12 | 15 | 0.0419 | -0.0217 |
| 4 | 11 | 0.0409 | -0.0165 |
| 11 | 17 | 0.0408 | 0.00193 |
| 1 | 17 | 0.0391 | -0.0246 |
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
And the target training data:
| 0 | |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 149,995 | 1 |
| 149,996 | 0 |
| 149,997 | 0 |
| 149,998 | 0 |
| 149,999 | 1 |
0
Int64DType- Null values
- 0 (0.0%)
- Unique values
- 2 (< 0.1%)
- Mean ± Std
- 0.500 ± 0.500
- Median ± IQR
- 0 ± 1
- Min | Max
- 0 | 1
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
|
Column
|
Column name
|
dtype
|
Is sorted
|
Null values
|
Unique values
|
Mean
|
Std
|
Min
|
Median
|
Max
|
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | Int64DType | False | 0 (0.0%) | 2 (< 0.1%) | 0.500 | 0.500 | 0 | 0 | 1 |
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
0
Int64DType- Null values
- 0 (0.0%)
- Unique values
- 2 (< 0.1%)
- Mean ± Std
- 0.500 ± 0.500
- Median ± IQR
- 0 ± 1
- Min | Max
- 0 | 1
No columns match the selected filter: . You can change the column filter in the dropdown menu above.
Please enable javascript
The skrub table reports need javascript to display correctly. If you are displaying a report in a Jupyter notebook and you see this message, you may need to re-execute the cell or to trust the notebook (button on the top right or "File > Trust notebook").
We build a model using skrub.tabular_pipeline(): it is a simple predictive
model that also performs basic feature engineering.
from skrub import tabular_pipeline
model = tabular_pipeline("classifier")
model
Pipeline(steps=[('tablevectorizer',
TableVectorizer(low_cardinality=ToCategorical())),
('histgradientboostingclassifier',
HistGradientBoostingClassifier())])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
Parameters
Parameters
| low_cardinality | ToCategorical() | |
| high_cardinality | StringEncoder() | |
| numeric | PassThrough() | |
| datetime | DatetimeEncoder() | |
| cardinality_threshold | 40 | |
| specific_transformers | () | |
| drop_null_fraction | 1.0 | |
| drop_if_constant | False | |
| drop_if_unique | False | |
| datetime_format | None | |
| null_strings | None | |
| n_jobs | None |
Parameters
Parameters
| resolution | 'hour' | |
| add_weekday | False | |
| add_total_seconds | True | |
| add_day_of_year | False | |
| periodic_encoding | None |
Parameters
Parameters
| n_components | 30 | |
| vectorizer | 'tfidf' | |
| ngram_range | (3, ...) | |
| analyzer | 'char_wb' | |
| stop_words | None | |
| random_state | None | |
| vocabulary | None |
Parameters
Caching the predictions for fast metric computation#
Let’s explore how EstimatorReport uses caching to speed up
predictions.
We compute the accuracy on our test set and measure how long it takes:
Time taken: 0.003 seconds
For comparison, here’s how scikit-learn computes the same accuracy score:
from sklearn.metrics import accuracy_score
start = time.time()
accuracy_score(report.y_test, report.estimator_.predict(report.X_test))
end = time.time()
print(f"Time taken: {end - start:.2f} seconds")
Time taken: 0.19 seconds
skore outputs the result much faster than scikit-learn. How can this be? The answer lies in the EstimatorReport’s state. When the EstimatorReport is created, it computes the model predictions, and caches them:
{('report', 'test', 'decision_function', None): array([[ 2.79048995, -2.79048995],
[-3.63911726, 3.63911726],
[ 2.22828539, -2.22828539],
...,
[-4.42554321, 4.42554321],
[-1.37352128, 1.37352128],
[-4.92460487, 4.92460487]], shape=(30000, 2)), ('report', 'test', 'predict', None): array([0, 1, 0, ..., 1, 1, 1], shape=(30000,)), ('report', 'test', 'predict_proba', None): array([[0.94215975, 0.05784025],
[0.0256028 , 0.9743972 ],
[0.90276095, 0.09723905],
...,
[0.01182618, 0.98817382],
[0.20205153, 0.79794847],
[0.00721319, 0.99278681]], shape=(30000, 2)), ('report', 'test', 'predict_log_proba', None): array([[-0.05958043, -2.85007038],
[-3.66505352, -0.02593626],
[-0.10229749, -2.33058288],
...,
[-4.43743987, -0.01189666],
[-1.59923253, -0.22571125],
[-4.9318442 , -0.00723933]], shape=(30000, 2)), ('metrics', 'test', 'accuracy', ('mapping', ())): 0.9215666666666666}
The cache stores predictions by type and data source. This means that computing metrics that use the same type of predictions will be faster.
Caching with CrossValidationReport#
Here we will demonstrate that CrossValidationReport also benefits
from caching.
A CrossValidationReport is essentially a list of
EstimatorReport, one for each split, so caching on the splits
makes the calculation on the CrossValidationReport faster as well.
Time taken: 0.14 seconds
The subsequent calls are even faster because the metrics themselves are cached:
Time taken: 0.03 seconds
By keeping the estimator together with the data, we are able to trade off some memory space for faster operations.
Total running time of the script: (0 minutes 13.738 seconds)