Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
name: Install pandoc
command: |
sudo apt-get update
wget https://github.com/jgm/pandoc/releases/download/2.14.1/pandoc-2.14.1-1-amd64.deb
sudo dpkg -i pandoc-2.14.1-1-amd64.deb
wget https://github.com/jgm/pandoc/releases/download/2.18/pandoc-2.18-1-amd64.deb
sudo dpkg -i pandoc-2.18-1-amd64.deb

- run:
name: Install tex
Expand Down
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ matrix:
env:
- sklver=">=0.24.2"
- jlver=">=1.0"
- python: 3.8
name: "Py38-023"
env:
- sklver="==0.23.2"
- jlver="==0.17.0"

before_install:
- sudo apt-get install libgeos-dev libproj-dev proj-data graphviz libblas-dev liblapack-dev
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ Function ``pipeline2dot`` converts a pipeline into a graph:
from mlinsights.plotting import pipeline2dot
dot = pipeline2dot(clf, df)

.. image:: https://github.com/sdpython/mlinsights/raw/master/_doc/pipeline.png
.. image:: https://raw.githubusercontent.com/sdpython/mlinsights/master/_doc/sphinxdoc/source/pipeline.png
5 changes: 3 additions & 2 deletions _unittests/ut_mlmodel/test_kmeans_l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def test_kmeans_l2_iris(self):
self.assertEqual({0, 1, 2, 3}, cls)

def test_kmeans_l1_check(self):
X = numpy.array([[-10, 1, 2, 3, 4, 10],
[-10, 1, 2, 3, 4, 10]]).T
X = numpy.ascontiguousarray(
numpy.array([[-10, 1, 2, 3, 4, 10],
[-10, 1, 2, 3, 4, 10]]).T)
clr = KMeansL1L2(2, norm='L1')
clr.fit(X)
cls = set(clr.predict(X))
Expand Down
15 changes: 9 additions & 6 deletions _unittests/ut_mlmodel/test_piecewise_decision_tree_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_criterions(self):
X = numpy.array([[1., 2.]]).T
y = numpy.array([1., 2.])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterion(X)
c2 = SimpleRegressorCriterion(1, X.shape[0])
self.assertNotEmpty(c1)
self.assertNotEmpty(c2)
w = numpy.ones((y.shape[0],))
Expand All @@ -49,7 +49,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 3.]]).T
y = numpy.array([1., 2., 3.])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterion(X)
c2 = SimpleRegressorCriterion(1, X.shape[0])
w = numpy.ones((y.shape[0],))
ind = numpy.arange(y.shape[0]).astype(numpy.int64)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand All @@ -68,7 +68,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 10., 11.]]).T
y = numpy.array([0.9, 1.1, 1.9, 2.1])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterion(X)
c2 = SimpleRegressorCriterion(1, X.shape[0])
w = numpy.ones((y.shape[0],))
ind = numpy.arange(y.shape[0]).astype(numpy.int64)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 10., 11.]]).T
y = numpy.array([0.9, 1.1, 1.9, 2.1])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterion(X)
c2 = SimpleRegressorCriterion(1, X.shape[0])
w = numpy.ones((y.shape[0],))
ind = numpy.array([0, 3, 2, 1], dtype=ind.dtype)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand Down Expand Up @@ -166,7 +166,8 @@ def test_decision_tree_criterion(self):
clr1.fit(X, y)
p1 = clr1.predict(X)

crit = SimpleRegressorCriterion(X)
crit = SimpleRegressorCriterion(
1 if len(y.shape) <= 1 else y.shape[1], X.shape[0])
clr2 = DecisionTreeRegressor(criterion=crit, max_depth=1)
clr2.fit(X, y)
p2 = clr2.predict(X)
Expand All @@ -179,7 +180,9 @@ def test_decision_tree_criterion_iris(self):
clr1 = DecisionTreeRegressor()
clr1.fit(X, y)
p1 = clr1.predict(X)
clr2 = DecisionTreeRegressor(criterion=SimpleRegressorCriterion(X))
clr2 = DecisionTreeRegressor(
criterion=SimpleRegressorCriterion(
1 if len(y.shape) <= 1 else y.shape[1], X.shape[0]))
clr2.fit(X, y)
p2 = clr2.predict(X)
self.assertEqual(p1[:10], p2[:10])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_criterions(self):
X = numpy.array([[1., 2.]]).T
y = numpy.array([1., 2.])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterionFast(X)
c2 = SimpleRegressorCriterionFast(1, X.shape[0])
self.assertNotEmpty(c1)
self.assertNotEmpty(c2)
w = numpy.ones((y.shape[0],))
Expand All @@ -51,7 +51,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 3.]]).T
y = numpy.array([1., 2., 3.])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterionFast(X)
c2 = SimpleRegressorCriterionFast(1, X.shape[0])
w = numpy.ones((y.shape[0],))
ind = numpy.arange(y.shape[0]).astype(numpy.int64)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand All @@ -71,7 +71,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 10., 11.]]).T
y = numpy.array([0.9, 1.1, 1.9, 2.1])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterionFast(X)
c2 = SimpleRegressorCriterionFast(1, X.shape[0])
w = numpy.ones((y.shape[0],))
ind = numpy.arange(y.shape[0]).astype(numpy.int64)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 10., 11.]]).T
y = numpy.array([0.9, 1.1, 1.9, 2.1])
c1 = MSE(1, X.shape[0])
c2 = SimpleRegressorCriterionFast(X)
c2 = SimpleRegressorCriterionFast(1, X.shape[0])
w = numpy.ones((y.shape[0],))
ind = numpy.array([0, 3, 2, 1], dtype=ind.dtype)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_decision_tree_criterion(self):
clr1.fit(X, y)
p1 = clr1.predict(X)

crit = SimpleRegressorCriterionFast(X)
crit = SimpleRegressorCriterionFast(1, X.shape[0])
clr2 = DecisionTreeRegressor(criterion=crit, max_depth=1)
clr2.fit(X, y)
p2 = clr2.predict(X)
Expand All @@ -175,7 +175,7 @@ def test_decision_tree_criterion_iris(self):
clr1 = DecisionTreeRegressor()
clr1.fit(X, y)
p1 = clr1.predict(X)
clr2 = DecisionTreeRegressor(criterion=SimpleRegressorCriterionFast(X))
clr2 = DecisionTreeRegressor(criterion=SimpleRegressorCriterionFast(1, X.shape[0]))
clr2.fit(X, y)
p2 = clr2.predict(X)
self.assertEqual(p1[:10], p2[:10])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_criterions(self):
X = numpy.array([[10., 12., 13.]]).T
y = numpy.array([20., 22., 23.])
c1 = MSE(1, X.shape[0])
c2 = LinearRegressorCriterion(X)
c2 = LinearRegressorCriterion(1, X)
self.assertNotEmpty(c1)
self.assertNotEmpty(c2)
w = numpy.ones((y.shape[0],))
Expand All @@ -49,7 +49,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 3.]]).T
y = numpy.array([1., 2., 3.])
c1 = MSE(1, X.shape[0])
c2 = LinearRegressorCriterion(X)
c2 = LinearRegressorCriterion(1, X)
w = numpy.ones((y.shape[0],))
ind = numpy.arange(y.shape[0]).astype(numpy.int64)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand All @@ -68,7 +68,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 10., 11.]]).T
y = numpy.array([0.9, 1.1, 1.9, 2.1])
c1 = MSE(1, X.shape[0])
c2 = LinearRegressorCriterion(X)
c2 = LinearRegressorCriterion(1, X)
w = numpy.ones((y.shape[0],))
ind = numpy.arange(y.shape[0]).astype(numpy.int64)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand All @@ -87,7 +87,7 @@ def test_criterions(self):
X = numpy.array([[1., 2., 10., 11.]]).T
y = numpy.array([0.9, 1.1, 1.9, 2.1])
c1 = MSE(1, X.shape[0])
c2 = LinearRegressorCriterion(X)
c2 = LinearRegressorCriterion(1, X)
w = numpy.ones((y.shape[0],))
ind = numpy.array([0, 3, 2, 1], dtype=ind.dtype)
ys = y.astype(float).reshape((y.shape[0], 1))
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_decision_tree_criterion(self):
clr1.fit(X, y)
p1 = clr1.predict(X)

crit = LinearRegressorCriterion(X)
crit = LinearRegressorCriterion(1, X)
clr2 = DecisionTreeRegressor(criterion=crit, max_depth=1)
clr2.fit(X, y)
p2 = clr2.predict(X)
Expand All @@ -158,7 +158,7 @@ def test_decision_tree_criterion_iris(self):
clr1 = DecisionTreeRegressor()
clr1.fit(X, y)
p1 = clr1.predict(X)
clr2 = DecisionTreeRegressor(criterion=LinearRegressorCriterion(X))
clr2 = DecisionTreeRegressor(criterion=LinearRegressorCriterion(1, X))
clr2.fit(X, y)
p2 = clr2.predict(X)
self.assertEqual(p1.shape, p2.shape)
Expand Down
13 changes: 12 additions & 1 deletion _unittests/ut_timeseries/test_plot_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
import unittest
import datetime
import warnings
import sys
from pyquickhelper.pycode import ExtTestCase
from mlinsights.timeseries.datasets import artificial_data
from mlinsights.timeseries.agg import aggregate_timeseries
Expand All @@ -11,8 +13,17 @@

class TestPlotTimeSeries(ExtTestCase):

@unittest.skipIf(
sys.platform == "win32" and __name__ != "__main__",
reason="issue with matplotlib")
def test_plot_data(self):
import matplotlib.pyplot as plt # pylint: disable=C0415
try:
import matplotlib.pyplot as plt # pylint: disable=C0415
except Exception as e:
if 'generated new fontManager' in str(e):
warnings.warn(e)
return
raise e
dt1 = datetime.datetime(2019, 8, 1)
dt2 = datetime.datetime(2019, 8, 15)
data = artificial_data(dt1, dt2, minutes=15)
Expand Down
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ environment:
PYTHON_VERSION: "3.9.x"
PYTHON_ARCH: "64"
SKL: '==0.24.2'
- PYTHON: "C:\\Python38-x64"
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "64"
SKL: '==0.23.2'
init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"

Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
displayName: 'Install Inkscape'
- script: sudo apt-get install -y pandoc
displayName: 'Install Pandoc'
- script: sudo apt-get install -y texlive texlive-latex-extra texlive-xetex dvipng
displayName: 'Install Latex'
# - script: sudo apt-get install -y texlive texlive-latex-extra texlive-xetex dvipng
# displayName: 'Install Latex'
- script: sudo apt-get install -y libgeos-dev libproj-dev proj-data graphviz libblas-dev liblapack-dev
displayName: 'Install Geos packages'
- script: |
Expand All @@ -37,7 +37,7 @@ jobs:
displayName: 'Install tools'
- script: pip install numpy
displayName: 'Install numpy'
- script: pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
- script: pip install install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
displayName: 'Install pytorch'
- script: |
export LLVM_CONFIG=/usr/bin/llvm-config-10
Expand Down
6 changes: 3 additions & 3 deletions mlinsights/mlmodel/_kmeans_022.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _labels_inertia_precompute_dense(norm, X, sample_weight, centers, distances)

This will overwrite the 'distances' array in-place.

:param norm: 'l1' or 'l2'
:param norm: 'L1' or 'L2'
:param X: numpy array, shape (n_sample, n_features)
Input data.
:param sample_weight: array-like, shape (n_samples,)
Expand All @@ -37,10 +37,10 @@ def _labels_inertia_precompute_dense(norm, X, sample_weight, centers, distances)
cluster center.
"""
n_samples = X.shape[0]
if norm == 'l2':
if norm == 'L2':
labels, mindist = pairwise_distances_argmin_min(
X=X, Y=centers, metric='euclidean', metric_kwargs={'squared': True})
elif norm == 'l1':
elif norm == 'L1':
labels, mindist = pairwise_distances_argmin_min(
X=X, Y=centers, metric='manhattan')
else: # pragma no cover
Expand Down
2 changes: 0 additions & 2 deletions mlinsights/mlmodel/_piecewise_tree_regression_common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ from sklearn.tree._criterion cimport SIZE_t, DOUBLE_t

cdef class CommonRegressorCriterion(Criterion):

cdef const DOUBLE_t[:, ::1] sample_X

cdef void _update_weights(self, SIZE_t start, SIZE_t end,
SIZE_t old_pos, SIZE_t new_pos) nogil

Expand Down
Loading