You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CompStats/interface.py
+36-3Lines changed: 36 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -47,8 +47,12 @@ class Perf(object):
47
47
:type n_jobs: int
48
48
:param num_samples: Number of bootstrap samples, default=500.
49
49
:type num_samples: int
50
+
:param use_tqdm: Whether to use tqdm.tqdm to visualize the progress, default=True
51
+
:type use_tqdm: bool
52
+
50
53
51
54
>>> from sklearn.svm import LinearSVC
55
+
>>> from sklearn.linear_model import LogisticRegression
52
56
>>> from sklearn.ensemble import RandomForestClassifier
53
57
>>> from sklearn.datasets import load_iris
54
58
>>> from sklearn.model_selection import train_test_split
@@ -65,22 +69,36 @@ class Perf(object):
65
69
<Perf>
66
70
Prediction statistics with standard error
67
71
alg-1 = 1.000 (0.000)
68
-
forest = 0.978 (0.019)
72
+
forest = 0.946 (0.038)
73
+
74
+
If an algorithm's prediction is missing, this can be included by calling the instance, as can be seen in the following instruction. Note that the algorithm's name can also be given with the keyword :py:attr:`name.`
75
+
76
+
>>> lr = LogisticRegression().fit(X_train, y_train)
77
+
>>> perf(lr.predict(X_val), name='Log. Reg.')
78
+
<Perf>
79
+
Prediction statistics with standard error
80
+
alg-1 = 1.000 (0.000)
81
+
forest = 0.946 (0.038)
82
+
Log. Reg. = 0.946 (0.038)
83
+
84
+
The performance function used to compare the algorithms can be changed, and the same bootstrap samples would be used if the instance were cloned. Consequently, the values are computed using the same samples, as can be seen in the following example.
69
85
70
86
>>> perf_error = clone(perf)
71
87
>>> perf_error.error_func = lambda y, hy: (y != hy).mean()
0 commit comments