Skip to content

Commit 8d7c10e

Browse files
committed
update pacakges, NumPy > 2.0
1 parent 9ab8fb7 commit 8d7c10e

13 files changed

Lines changed: 88 additions & 39 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ on: [ push,pull_request ]
44

55
jobs:
66
build:
7-
87
runs-on: ${{ matrix.os }}
98
strategy:
9+
fail-fast: false
1010
matrix:
1111
os: [ ubuntu-latest ]
12-
python-version: [ '3.10']
13-
#os: [ ubuntu-latest, macos-latest, windows-latest ]
14-
#python-version: [ '3.8', '3.9', '3.10', '3.11' ]
12+
python-version: [ "3.9", "3.12" ]
1513

1614
steps:
1715
- name: Install OS Dependencies
@@ -29,21 +27,19 @@ jobs:
2927
if: matrix.os == 'windows-latest'
3028
run: |
3129
choco install graphviz
32-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v4
3331
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v2
32+
uses: actions/setup-python@v5
3533
with:
3634
python-version: ${{ matrix.python-version }}
3735
- name: Install Python Dependencies
3836
run: |
3937
python -m pip install --upgrade pip
40-
pip install --upgrade setuptools
38+
pip install --upgrade setuptools wheel
4139
pip install -U importlib-metadata>=1.7.0
4240
pip install -U -r requirements.txt
4341
pip install -U -r requirements_dev.txt
44-
pip install ipython
45-
python setup.py install
42+
pip install -e .
4643
- name: Test with pytest
4744
run: |
4845
pytest tests --cov=supervised/
49-
continue-on-error: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Smoke test PyPI install + train
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
smoke:
10+
name: Smoke (${{ matrix.python-version }}, ${{ matrix.os }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
16+
python-version: ["3.9", "3.12"]
17+
18+
steps:
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install Graphviz
25+
if: matrix.os == 'ubuntu-latest'
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get -y install graphviz
29+
30+
- name: Install Graphviz
31+
if: startsWith(matrix.os, 'macos')
32+
run: |
33+
brew install graphviz
34+
35+
- name: Install Graphviz
36+
if: matrix.os == 'windows-latest'
37+
run: |
38+
choco install graphviz
39+
40+
- name: Install package from PyPI
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install -U mljar-supervised
44+
45+
- name: Smoke train
46+
run: |
47+
python -c "from sklearn.datasets import make_classification; from supervised import AutoML; X,y=make_classification(n_samples=120,n_features=8,n_informative=4,random_state=42); automl=AutoML(mode='Explain',algorithms=['Baseline','Linear','Decision Tree'],train_ensemble=False,stack_models=False,explain_level=0,total_time_limit=30,results_path='automl_smoke'); automl.fit(X,y); preds=automl.predict(X[:5]); print(preds)"

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,10 @@ For details please check [mljar-supervised docs](https://supervised.mljar.com).
474474

475475
# Installation
476476

477+
Compatibility:
478+
- Python `>=3.9`
479+
- NumPy `>=2.0,<3`
480+
477481
From PyPi repository:
478482

479483
```
@@ -496,15 +500,15 @@ python setup.py install
496500
Installation for development
497501
```
498502
git clone https://github.com/mljar/mljar-supervised.git
499-
virtualenv venv --python=python3.6
503+
virtualenv venv --python=python3.9
500504
source venv/bin/activate
501505
pip install -r requirements.txt
502506
pip install -r requirements_dev.txt
503507
```
504508

505509
Running in the docker:
506510
```
507-
FROM python:3.7-slim-buster
511+
FROM python:3.9-slim-buster
508512
RUN apt-get update && apt-get -y update
509513
RUN apt-get install -y build-essential python3-pip python3-dev
510514
RUN pip3 -q install pip --upgrade

requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
numpy>=1.19.5,<2
2-
pandas>=2.0.0
3-
scipy>=1.6.1
1+
numpy>=2.0.0,<3.0.0
2+
pandas>=2.2.2
3+
scipy>=1.13.1
44
scikit-learn>=1.5.0
5-
xgboost>=2.0.0
6-
lightgbm>=3.0.0
7-
catboost>=0.24.4
5+
xgboost>=2.1.0
6+
lightgbm>=4.3.0
7+
catboost>=1.2.8
88
joblib>=1.0.1
99
tabulate>=0.8.7
10-
matplotlib>=3.2.2
10+
matplotlib>=3.8.4
1111
dtreeviz>=2.2.2
12-
shap>=0.42.1
13-
seaborn>=0.11.1
12+
shap>=0.46.0
13+
seaborn>=0.13.2
1414
optuna-integration>=3.6.0
1515
mljar-scikit-plot>=0.3.11
1616
markdown

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
2222
install_requires=open("requirements.txt").readlines(),
2323
include_package_data=True,
24-
python_requires='>=3.8',
24+
python_requires='>=3.9',
2525
classifiers=[
2626
"Programming Language :: Python",
27-
"Programming Language :: Python :: 3.8",
2827
"Programming Language :: Python :: 3.9",
2928
"Programming Language :: Python :: 3.10",
3029
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
3131
],
3232
keywords=[
3333
"automated machine learning",

supervised/algorithms/xgboost.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def __init__(self, params):
7878
self.early_stopping_rounds = additional.get("early_stopping_rounds", 50)
7979
self.learner_params = {
8080
"tree_method": "hist",
81+
"device": "cpu",
8182
"booster": "gbtree",
8283
"objective": self.params.get("objective"),
8384
"eval_metric": self.params.get("eval_metric"),
@@ -166,7 +167,7 @@ def fit(
166167
dtrain = xgb.DMatrix(
167168
X.values if isinstance(X, pd.DataFrame) else X,
168169
label=y,
169-
missing=np.NaN,
170+
missing=np.nan,
170171
weight=sample_weight,
171172
)
172173

@@ -176,7 +177,7 @@ def fit(
176177
if isinstance(X_validation, pd.DataFrame)
177178
else X_validation,
178179
label=y_validation,
179-
missing=np.NaN,
180+
missing=np.nan,
180181
weight=sample_weight_validation,
181182
)
182183
else:
@@ -264,7 +265,7 @@ def predict(self, X):
264265
raise XgbAlgorithmException("Xgboost model is None")
265266

266267
dtrain = xgb.DMatrix(
267-
X.values if isinstance(X, pd.DataFrame) else X, missing=np.NaN
268+
X.values if isinstance(X, pd.DataFrame) else X, missing=np.nan
268269
)
269270
# xgboost > 2.0.0 version
270271
if hasattr(self.model, "best_iteration"):

supervised/base_automl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ def _build_dataframe(self, X, y=None, sample_weight=None, sensitive_features=Non
805805
sensitive_features.reset_index(drop=True, inplace=True)
806806

807807
for col in sensitive_features.columns:
808-
if not sensitive_features[col].dtype.name in ["category", "object"]:
808+
if pd.api.types.is_numeric_dtype(sensitive_features[col].dtype):
809809
self.verbose_print("Sensitive features should be categorical")
810810
self.verbose_print(
811811
f"Apply automatic binarization for feature {col}"

supervised/preprocessing/preprocessing_categorical.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ def transform(self, X):
5858
lbl = LabelEncoder()
5959
lbl.from_json(lbl_params)
6060
transformed_values = lbl.transform(X.loc[:, column])
61+
col_dtype = X.loc[:, column].dtype
6162
# check for pandas FutureWarning: Setting an item
6263
# of incompatible dtype is deprecated and will raise
6364
# in a future error of pandas.
64-
if transformed_values.dtype != X.loc[:, column].dtype and \
65-
(X.loc[:, column].dtype == bool or X.loc[:, column].dtype == int):
65+
if transformed_values.dtype != col_dtype and \
66+
(col_dtype == bool or col_dtype == int):
6667
X = X.astype({column: transformed_values.dtype})
67-
if isinstance(X[column].dtype, pd.CategoricalDtype):
68+
# pandas string/categorical extension dtypes reject integer arrays.
69+
if isinstance(col_dtype, pd.CategoricalDtype) or pd.api.types.is_string_dtype(col_dtype):
6870
X[column] = X[column].astype('object')
6971
X.loc[:, column] = transformed_values
7072

supervised/utils/automl_plots.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import warnings
2424
import matplotlib.pyplot as plt
2525

26-
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
26+
warnings.filterwarnings("ignore", category=DeprecationWarning)
2727

2828
class AutoMLPlots:
2929
# Original filename definitions
@@ -366,4 +366,3 @@ def models_correlation(results_path, models):
366366
# Ensure plot is closed if error occurred during saving/closing
367367
plt.close("all")
368368

369-

supervised/utils/leaderboard_plots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import matplotlib.pyplot as plt
1616

17-
warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning)
17+
warnings.filterwarnings("ignore", category=DeprecationWarning)
1818

1919

2020
markers = {

0 commit comments

Comments
 (0)