8000 Saving KernelDensity with sample_weight · Issue #13692 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
Saving KernelDensity with sample_weight #13692
Closed
@Dathiou

Description

@Dathiou

Description

Type Error when saving to file Kernel Density Estimation with sample weight

Steps/Code to Reproduce

Example:

import numpy as np
from sklearn.neighbors import KernelDensity
data = np.reshape([1., 2., 3., 1., 2., 3.], (-1, 2))
kde = KernelDensity(bandwidth=0.3)
kde.fit(data, sample_weight=[0.1,0.2,0.3])
from sklearn.externals import joblib
joblib.dump(kde, './test_kde.pkl')

Omitting sample_weight=[0.1,0.2,0.3] works.

Expected Results

No error is thrown.

Actual Results

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/externals/joblib/numpy_pickle.py in save(self, obj)
    290             return
    291 
--> 292         return Pickler.save(self, obj)
    293 
    294 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pickle.py in save(self, obj, save_persistent_id)
    494             reduce = getattr(obj, "__reduce_ex__", None)
    495             if reduce is not None:
--> 496                 rv = reduce(self.proto)
    497             else:
    498                 reduce = getattr(obj, "__reduce__", None)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/neighbors/kd_tree.cpython-36m-darwin.so in View.MemoryView._memoryviewslice.__reduce_cython__()

TypeError: no default __reduce__ due to non-trivial __cinit__

Versions

System:
python: 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
executable: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
machine: Darwin-15.6.0-x86_64-i386-64bit

BLAS:
macros: NO_ATLAS_INFO=3, HAVE_CBLAS=None
lib_dirs:
cblas_libs: cblas

Python deps:
pip: 9.0.1
setuptools: 28.8.0
sklearn: 0.20.3
numpy: 1.16.2
scipy: 1.2.1
Cython: None
pandas: 0.20.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggood first issueEasy with clear instructions to resolve

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0