Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sdpython/mlinsights into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Mar 17, 2021
2 parents 46f4587 + 77af9c7 commit f2a3cfd
Show file tree
Hide file tree
Showing 50 changed files with 1,080 additions and 305 deletions.
96 changes: 57 additions & 39 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/python:3.7.5
- image: circleci/python:3.9.1

working_directory: ~/repo

Expand All @@ -11,15 +11,15 @@ jobs:

- restore_cache:
keys:
- v3-dependencies-{{ checksum "requirements.txt" }}
- v3-dependencies-
- v2-dependencies-{{ checksum "requirements.txt" }}
- v2-dependencies-

- run:
name: Install pandoc
command: |
sudo apt-get update
wget https://github.com/jgm/pandoc/releases/download/2.2.1/pandoc-2.2.1-1-amd64.deb
sudo dpkg -i pandoc-2.2.1-1-amd64.deb
wget https://github.com/jgm/pandoc/releases/download/2.11.3.2/pandoc-2.11.3.2-1-amd64.deb
sudo dpkg -i pandoc-2.11.3.2-1-amd64.deb
- run:
name: Install tex
Expand All @@ -43,53 +43,71 @@ jobs:
command: |
sudo apt-get install -y graphviz
# statsmodels setup.py requires it
- run:
name: install numpy
name: Install libproj
command: |
python3 -m venv venv
sudo apt-get install -y libgeos-dev libproj-dev proj-data graphviz
- run:
name: Install llvmlite
command: |
sudo apt-get install lsb-release wget software-properties-common
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 10
ls /usr/bin/llvm*
- run:
name: Install standard libraries
command: |
python -m venv venv
. venv/bin/activate
pip install numpy
pip install scipy matplotlib numpy cython pandas
- run:
name: Install cython
name: Install pyproj, shapely, cartopy
command: |
python3 -m venv venv
python -m venv venv
. venv/bin/activate
pip install cython
pip install pyproj
pip uninstall -y shapely
pip install --no-binary shapely shapely
pip install cartopy
- run:
name: Install geos, proj for cartopy
name: Install numba, llvmlite
command: |
sudo apt-get -qq update
sudo apt-get install -y libproj-dev proj-bin proj-data
sudo apt-get install -y python-pyproj
sudo apt-get install -y libc6
sudo apt-get install libgeos-dev
sudo apt-get install python-gdal gdal-bin
wget http://es.archive.ubuntu.com/ubuntu/pool/universe/p/proj/libproj9_4.9.2-2_amd64.deb
sudo dpkg -i libproj9_4.9.2-2_amd64.deb
wget http://es.archive.ubuntu.com/ubuntu/pool/universe/p/proj/libproj-dev_4.9.2-2_amd64.deb
sudo dpkg -i libproj-dev_4.9.2-2_amd64.deb
python -m venv venv
. venv/bin/activate
# export LLVM_CONFIG=/usr/local/opt/llvm/bin/llvm-config
sudo ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config
pip install llvmlite numba
- run:
name: install dependencies
command: |
python3 -m venv venv
python -m venv venv
. venv/bin/activate
pip install scipy
pip install -r requirements.txt
- save_cache:
paths:
- ./venv
key: v3-dependencies-{{ checksum "requirements.txt" }}
key: v2-dependencies-{{ checksum "requirements.txt" }}

- run:
name: check list of dependencies
command: |
python -m venv venv
. venv/bin/activate
pip freeze
apt list --installed
- run:
name: compile and build
command: |
. venv/bin/activate
python -u setup.py build_ext --inplace --verbose
python setup.py build_ext --inplace
- run:
name: run tests
Expand All @@ -101,23 +119,23 @@ jobs:
name: wheel
command: |
. venv/bin/activate
python ./setup.py bdist_wheel
python setup.py bdist_wheel
mkdir -p test-reports/dist
cp dist/*.whl test-reports/dist
mkdir -p test-reports
cp -r mlinsights test-reports
- run:
name: documentation
command: |
. venv/bin/activate
python setup.py build_sphinx
- run:
name: copy documentation
command: |
mkdir -p test-reports/doc
zip -r -9 test-reports/doc/documentation_html.zip _doc/sphinxdoc/build/html
# - run:
# name: documentation
# command: |
# . venv/bin/activate
# python setup.py build_sphinx
#
# - run:
# name: copy documentation
# command: |
# mkdir -p test-reports/doc
# zip -r -9 test-reports/doc/documentation_html.zip _doc/sphinxdoc/build/html

- store_artifacts:
path: test-reports
Expand Down
5 changes: 2 additions & 3 deletions .local.jenkins.lin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
language: python

python:
- { PATH: "{{Python37}}", VERSION: 3.7, DIST: std, PYINT: python3.7 }
- { PATH: "{{Python38}}", VERSION: 3.8, DIST: std, PYINT: python3.8 }
- { PATH: "{{Python39}}", VERSION: 3.9, DIST: std, PYINT: python3.9 }

virtualenv:
- path: {{ospathjoin(root_path, pickname("$NAME_JENKINS", project_name + "_$VERSION_$DIST_$NAME"), "_venv")}}
Expand All @@ -12,8 +11,8 @@ install:
- $PYINT -m pip install --upgrade pip
- $PYINT -m pip install --upgrade --no-cache-dir --no-deps --index http://localhost:8067/simple/ jyquickhelper pyquickhelper cpyquickhelper pandas_streaming --extra-index-url=https://pypi.python.org/simple/
- $PYINT -m pip install --upgrade --no-cache-dir --no-deps --index http://localhost:8067/simple/ scikit-learn>=0.22 --extra-index-url=https://pypi.python.org/simple/
- $PYINT -m pip install -r requirements-win.txt
- $PYINT -m pip install -r requirements.txt
- $PYINT -m pip install -r requirements-ext.txt
- $PYINT --version
- $PYINT -m pip freeze

Expand Down
6 changes: 2 additions & 4 deletions .local.jenkins.win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
language: python

python:
- { PATH: "{{replace(Python37, '\\', '\\\\')}}", VERSION: 3.7, DIST: std }
- { PATH: "{{replace(Python39, '\\', '\\\\')}}", VERSION: 3.9, DIST: std }

virtualenv:
- path: {{ospathjoin(root_path, pickname("%NAME_JENKINS%", project_name + "_%VERSION%_%DIST%_%NAME%"), "_venv")}}

install:
- pip install --upgrade pip
- pip install --no-cache-dir --no-deps --index http://localhost:8067/simple/ jyquickhelper --extra-index-url=https://pypi.python.org/simple/
- pip install --no-cache-dir --no-deps --index http://localhost:8067/simple/ pyquickhelper --extra-index-url=https://pypi.python.org/simple/
- pip install --no-cache-dir --no-deps --index http://localhost:8067/simple/ cpyquickhelper --extra-index-url=https://pypi.python.org/simple/
- pip install --no-cache-dir --no-deps --index http://localhost:8067/simple/ jyquickhelper pyquickhelper cpyquickhelper --extra-index-url=https://pypi.python.org/simple/
- pip install -r requirements.txt
- pip freeze
- pip freeze > pip_freeze.txt
Expand Down
40 changes: 25 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
dist: bionic
dist: focal
sudo: true
language: python

matrix:
include:
- python: 3.7
name: "Py37-skl022"
env: sklearnc="==0.22.2"
- python: 3.9
name: "Py39-024+"
env:
- sklver=">=0.24.0"
- jlver=">=1.0"
- python: 3.8
name: "Py38-skl023"
env: sklearnc=">=0.23"
name: "Py38-023"
env:
- sklver="==0.23.2"
- jlver="==0.17.0"

before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
- sudo apt-get install graphviz
- gcc --version
- sudo apt-get install libgeos-dev libproj-dev proj-data graphviz libblas-dev liblapack-dev
- wget https://apt.llvm.org/llvm.sh
- chmod +x llvm.sh
- sudo ./llvm.sh 10
- ls /usr/bin/llvm*
- export LLVM_CONFIG=/usr/bin/llvm-config
# - sudo ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config
- sudo apt-get -y install graphviz

install:
- pip install pyquickhelper cython scipy
- pip install -r requirements.txt
- pip install -r requirements-ext.txt
- pip install scikit-learn$sklearnc
- python -c "import sklearn;print(sklearn.__version__)"
- pip install "scikit-learn$sklver"
- pip install "joblib$jlver"

before_script:
- python -u setup.py build_ext --inplace --verbose
- python setup.py build_ext --inplace

script:
- python setup.py unittests
27 changes: 25 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,34 @@
History
=======

current - 2020-08-06 - 0.00Mb
current - 2021-01-09 - 0.00Mb
=============================

* `81`: Make mlinsights work with scikit-learn 0.22 and 0.23 (2020-08-06)
* `93`: Include build wheel for all platforms in CI (2021-01-09)

0.3.543 - 2021-01-03 - 0.67Mb
=============================

* `89`: Install fails: ModuleNotFoundError: No module named 'sklearn' (2021-01-03)
* `92`: QuantileMLPRegressor does not work with scikit-learn 0.24 (2021-01-01)
* `91`: Fixes regression criterion for scikit-learn 0.24 (2021-01-01)
* `90`: Fixes PipelineCache for scikit-learn 0.24 (2021-01-01)

0.2.508 - 2020-09-02 - 0.43Mb
=============================

* `88`: Change for scikit-learn 0.24 (2020-09-02)
* `87`: Set up CI with Azure Pipelines (2020-09-02)
* `86`: Update CI, use python 3.8 (2020-09-02)
* `71`: update kmeans l1 to the latest kmeans (signatures changed) (2020-08-31)
* `84`: style (2020-08-30)

0.2.491 - 2020-08-06 - 0.83Mb
=============================

* `83`: Upgrade version (2020-08-06)
* `82`: Fixes #81, skl 0.22, 0.23 together (2020-08-06)
* `81`: Make mlinsights work with scikit-learn 0.22 and 0.23 (2020-08-06)
* `79`: pipeline2dot fails with 'passthrough' (2020-07-16)

0.2.463 - 2020-06-29 - 0.83Mb
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017-2020, Xavier Dupré
Copyright (c) 2017-2021, Xavier Dupré

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mlinsights - extensions to scikit-learn
.. image:: https://circleci.com/gh/sdpython/mlinsights/tree/master.svg?style=svg
:target: https://circleci.com/gh/sdpython/mlinsights/tree/master

.. image:: https://dev.azure.com/xavierdupre3/mlinsights/_apis/build/status/sdpython.mlinsights
.. image:: https://dev.azure.com/xavierdupre3/mlinsights/_apis/build/status/sdpython.mlinsights%20(2)
:target: https://dev.azure.com/xavierdupre3/mlinsights/

.. image:: https://badge.fury.io/py/mlinsights.svg
Expand Down
12 changes: 7 additions & 5 deletions _doc/examples/plot_constraint_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@
====
"""
from collections import Counter
import numpy
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
from sklearn.cluster import KMeans
from mlinsights.mlmodel import ConstraintKMeans


n_samples = 100
data = make_blobs(n_samples=n_samples, n_features=2, centers=2, cluster_std=1.0,
center_box=(-10.0, 0.0), shuffle=True, random_state=2)
data = make_blobs(
n_samples=n_samples, n_features=2, centers=2, cluster_std=1.0,
center_box=(-10.0, 0.0), shuffle=True, random_state=2)
X1 = data[0]
data = make_blobs(n_samples=n_samples // 2, n_features=2, centers=2, cluster_std=1.0,
center_box=(0.0, 10.0), shuffle=True, random_state=2)
data = make_blobs(
n_samples=n_samples // 2, n_features=2, centers=2, cluster_std=1.0,
center_box=(0.0, 10.0), shuffle=True, random_state=2)
X2 = data[0]

import numpy
X = numpy.vstack([X1, X2])
X.shape

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
`QuantReg <http://www.statsmodels.org/dev/generated/statsmodels.regression.quantile_regression.QuantReg.html>`_
but I wanted to try something I did for my teachings
`Régression Quantile
<http://www.xavierdupre.fr/app/ensae_teaching_cs/helpsphinx3/notebooks/td_note_2017_2.html?highlight=mediane>`_
<http://www.xavierdupre.fr/app/ensae_teaching_cs/helpsphinx/notebooks/td_note_2017_2.html?highlight=mediane>`_
based on `Iteratively reweighted least squares
<https://en.wikipedia.org/wiki/Iteratively_reweighted_least_squares>`_.
I thought it was a good case study to turn a simple algorithm into
Expand Down
22 changes: 22 additions & 0 deletions _doc/sphinxdoc/source/blog/2020/2020-09-02_api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

.. blogpost::
:title: scikit-learn internal API
:keywords: API
:date: 2020-09-02
:categories: scikit-learn
:lid: blog-internal-api-impurity-improvement

The signature of method `impurity_improvement
<https://github.com/scikit-learn/scikit-learn/blob/master/
sklearn/tree/_criterion.pxd#L65>`_ will change for version
0.24. That's usually easy to handle two versions of scikit-learn
even overloaded in a class except that method is implemented
in :epkg:`cython`. The method must be overloaded the same way
with the same signature. The way it was handled is implemented
in PR `88 <https://github.com/sdpython/mlinsights/pull/88>`_.

The best would be to include both of them but only one of
them can compile. I did not find any good solution to that.
It compiles whatever scikit-learn's version but the compiled
module only works with the installed version of
:epkg:`scikti-learn`.
15 changes: 15 additions & 0 deletions _doc/sphinxdoc/source/blog/2021/2021-01-03_skl.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

.. blogpost::
:title: scikit-learn 0.23
:keywords: scikit-learn, 0.23, 0.24
:date: 2021-01-03
:categories: scikit-learn

The unit test are run against
:epkg:`scikit-learn` 0.23, 0.24.
Some unit tests are failing with version 0.23.
They were disabled instead of looking into a cause
which does not appear with the latest version.
It affects all classes inheriting from :class:`SkBase
<mlinsights.sklapi.sklearn_base.SkBase>` where a model
using it is trained. The issue happens in :epkg:`joblib`.
2 changes: 1 addition & 1 deletion _doc/sphinxdoc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
local_template = os.path.join(os.path.abspath(
os.path.dirname(__file__)), "phdoc_templates")

set_sphinx_variables(__file__, "mlinsights", "Xavier Dupré", 2020,
set_sphinx_variables(__file__, "mlinsights", "Xavier Dupré", 2021,
"alabaster", alabaster.get_path(),
locals(), extlinks=dict(
issue=('https://github.com/sdpython/mlinsights/issues/%s', 'issue')),
Expand Down
Loading

0 comments on commit f2a3cfd

Please sign in to comment.