Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scikit-learn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ian Johnson
scikit-learn
Commits
df27e261
Commit
df27e261
authored
11 years ago
by
Raul Garreta
Committed by
Ignacio Rossi
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
model persistence doc, added improvements from ogrisel comments
parent
8489c330
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/model_persistence.rst
+15
-2
15 additions, 2 deletions
doc/model_persistence.rst
doc/tutorial/basic/tutorial.rst
+16
-4
16 additions, 4 deletions
doc/tutorial/basic/tutorial.rst
with
31 additions
and
6 deletions
doc/model_persistence.rst
+
15
−
2
View file @
df27e261
...
@@ -36,12 +36,25 @@ persistence model, namely `pickle <http://docs.python.org/library/pickle.html>`_
...
@@ -36,12 +36,25 @@ persistence model, namely `pickle <http://docs.python.org/library/pickle.html>`_
In the specific case of the scikit, it may be more interesting to use
In the specific case of the scikit, it may be more interesting to use
joblib's replacement of pickle (``joblib.dump`` & ``joblib.load``),
joblib's replacement of pickle (``joblib.dump`` & ``joblib.load``),
which is more efficient on big data, but can only pickle to the disk
which is more efficient on objects that carry large numpy arrays internally as
and not to a string::
is often the case for fitted scikit-learn estimators, but can only pickle to the
disk and not to a string::
>>> from sklearn.externals import joblib
>>> from sklearn.externals import joblib
>>> joblib.dump(clf, 'filename.pkl') # doctest: +SKIP
>>> joblib.dump(clf, 'filename.pkl') # doctest: +SKIP
Later you can load back the pickled model (possibly in another Python process)
with::
>>> clf = joblib.load('filename.pkl') # doctest:+SKIP
.. note::
joblib.dump returns a list of filenames. Each individual numpy array
contained in the `clf` object is serialized as a separate file on the
filesystem. All files are required in the same folder when reloading the
model with joblib.load.
Security & maintainability limitations
Security & maintainability limitations
--------------------------------------
--------------------------------------
...
...
This diff is collapsed.
Click to expand it.
doc/tutorial/basic/tutorial.rst
+
16
−
4
View file @
df27e261
...
@@ -234,7 +234,19 @@ and not to a string::
...
@@ -234,7 +234,19 @@ and not to a string::
>>> from sklearn.externals import joblib
>>> from sklearn.externals import joblib
>>> joblib.dump(clf, 'filename.pkl') # doctest: +SKIP
>>> joblib.dump(clf, 'filename.pkl') # doctest: +SKIP
It's important for you to know that pickle has some security and maintainability
Later you can load back the pickled model (possibly in another Python process)
issues. Please refer to section :ref:`model_persistence` for more detailed
with::
information about model persistence with scikit-learn.
>>> clf = joblib.load('filename.pkl') # doctest:+SKIP
.. note::
joblib.dump returns a list of filenames. Each individual numpy array
contained in the `clf` object is serialized as a separate file on the
filesystem. All files are required in the same folder when reloading the
model with joblib.load.
Note that pickle has some security and maintainability issues. Please refer to
section :ref:`model_persistence` for more detailed information about model
persistence with scikit-learn.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment