Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

[WIP] FIX CDClassifier with n_jobs != 1 in py36 (#114) #117

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ sudo: false
language: python
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
install:
# We do this conditionally because it saves us some downloading if the
# version is the same.
Expand Down
20 changes: 6 additions & 14 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,21 @@ environment:
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\build_tools\\appveyor\\run_with_env.cmd"

matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.8"
- PYTHON_VERSION: "2.7.13"
PYTHON_ARCH: "32"
MINICONDA: "C:\\Miniconda"

- PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.8"
- PYTHON_VERSION: "2.7.13"
PYTHON_ARCH: "64"
MINICONDA: "C:\\Miniconda-x64"

- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.0"
- PYTHON_VERSION: "3.6.0"
PYTHON_ARCH: "32"
MINICONDA: "C:\\Miniconda35"
MINICONDA: "C:\\Miniconda36"

- PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5.0"
- PYTHON_VERSION: "3.6.0"
PYTHON_ARCH: "64"
MINICONDA: "C:\\Miniconda35-x64"

MINICONDA: "C:\\Miniconda36-x64"


install:
Expand All @@ -48,9 +43,6 @@ install:
# Update previous packages and install the build and runtime dependencies of the project.
- conda update --all --yes
- conda install --quiet --yes numpy scipy cython nose scikit-learn wheel"
# there seems to be a problem with conda-build 1.21.0 on python27 and win64, avoid this
# by using a previous version
- conda install --quiet --yes conda-build=1.21.0
- "%CMD_IN_ENV% python setup.py bdist_wheel bdist_wininst"

- ps: "ls dist"
Expand Down
6 changes: 6 additions & 0 deletions lightning/impl/primal_cd_fast.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ cdef class LossFunction:
cdef double beta
cdef int verbose

def __getstate__(self):
return self.max_steps, self.sigma, self.beta, self.verbose

def __setstate__(self, state):
self.max_steps, self.sigma, self.beta, self.verbose = state

# L2 regularization

cdef void solve_l2(self,
Expand Down
11 changes: 10 additions & 1 deletion lightning/impl/tests/test_primal_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def test_debiasing_l1l2():
multiclass=False,
debiasing=True,
warm_debiasing=warm_debiasing,
max_iter=20, C=0.01, random_state=0)
max_iter=20, C=0.01, random_state=0,
verbose=True)
clf.fit(mult_csc, mult_target)
assert_greater(clf.score(mult_csc, mult_target), 0.75)
assert_equal(clf.n_nonzero(percentage=True), 0.08)
Expand Down Expand Up @@ -421,3 +422,11 @@ def test_multiclass_classes():
clf = CDClassifier()
clf.fit(mult_dense, mult_target)
assert_equal(list(clf.classes_), [0, 1, 2])


def test_n_jobs_can_fit():
# Check that all loss cdef classes pickle (issue #114)
for loss in ('squared', 'smooth_hinge', 'squared_hinge', 'modified_huber',
'log'):
clf = CDClassifier(loss=loss, n_jobs=2)
clf.fit(mult_dense, mult_target)