8000 EXA Better joblib caching in plot_compare_reduction.py (#14113) · scikit-learn/scikit-learn@faa9406 · GitHub
[go: up one dir, main page]

Skip to content

Commit faa9406

Browse files
kirilldolmatovrth
authored andcommitted
EXA Better joblib caching in plot_compare_reduction.py (#14113)
1 parent f3eb9d2 commit faa9406

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/compose/plot_compare_reduction.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,12 @@
102102
# cache. Hence, use the ``memory`` constructor parameter when the fitting
103103
# of a transformer is costly.
104104

105-
from tempfile import mkdtemp
106-
from shutil import rmtree
107105
from joblib import Memory
106+
from shutil import rmtree
108107

109108
# Create a temporary folder to store the transformers of the pipeline
110-
cachedir = mkdtemp()
111-
memory = Memory(location=cachedir, verbose=10)
109+
location = 'cachedir'
110+
memory = Memory(location=location, verbose=10)
112111
cached_pipe = Pipeline([('reduce_dim', PCA()),
113112
('classify', LinearSVC(dual=False, max_iter=10000))],
114113
memory=memory)
@@ -119,7 +118,8 @@
119118
grid.fit(digits.data, digits.target)
120119

121120
# Delete the temporary cache before exiting
122-
rmtree(cachedir)
121+
memory.clear(warn=False)
122+
rmtree(location)
123123

124124
###############################################################################
125125
# The ``PCA`` fitting is only computed at the evaluation of the first

0 commit comments

Comments
 (0)
0