Skip to content

Commit

Permalink
Merge pull request #31 from mwydmuch/thesis_mw
Browse files Browse the repository at this point in the history
Python wrapper/bindings update
  • Loading branch information
mwydmuch authored Jan 20, 2025
2 parents 0863d95 + 1d46707 commit 848f9fa
Show file tree
Hide file tree
Showing 29 changed files with 301 additions and 133 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,48 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-11, windows-2019]
os: [ ubuntu-22.04, macos-12, macos-14, windows-2022 ]

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Report OS
run: |
echo ${{ matrix.os }}
echo ${{ runner.os }}
uname -p
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/[email protected]
- name: Build manylinux wheels
if: matrix.os == 'ubuntu-22.04'
uses: pypa/[email protected]
env:
# Configure cibuildwheel to build native archs, and some emulated ones
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_BUILD_VERBOSITY: 1

- name: Build macOS Intel wheels
if: matrix.os == 'macos-12' || matrix.os == 'macos-13'
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: x86_64
MACOSX_DEPLOYMENT_TARGET: 10.15
CIBW_ARCHS_WINDOWS: AMD64
CIBW_BUILD_VERBOSITY: 3
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
auditwheel show {wheel} && auditwheel repair -w {dest_dir} {wheel}
CIBW_ENVIRONMENT_MACOS: HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 MACOSX_DEPLOYMENT_TARGET=12.0
CIBW_BUILD_VERBOSITY: 1

- name: Build macOS Apple Silicon wheels
if: matrix.os == 'macos-14'
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: arm64
CIBW_ENVIRONMENT_MACOS: HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 MACOSX_DEPLOYMENT_TARGET=14.0
CIBW_BUILD_VERBOSITY: 1

- name: Report built wheels
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpp-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ ubuntu-22.04, macos-12, macos-14, windows-2022 ]

name: Build C++ core on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/python-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
os: [ ubuntu-22.04, macos-12, macos-14, windows-2022 ]
#python-version: [ '3.9', '3.10', '3.11', '3.12' ]
python-version: [ '3.9', '3.12' ] # Test only on 3.9 and 3.12 (the oldest and newest) to save time and resources

name: Build Pyhton binding on ${{ matrix.os }} for Python ${{ matrix.python-version }}
name: Build Python binding on ${{ matrix.os }} for Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -42,7 +43,7 @@ jobs:
- name: Upgrade pip and install pytest
run: |
python -m pip install --upgrade pip
pip install pytest scikit-learn==1.2.2
pip install pytest scikit-learn
- name: Pip install
run: pip install .
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cmake_minimum_required(VERSION 3.12)
project(napkinXC
VERSION 0.6.3
VERSION 0.7.0
DESCRIPTION "Extremely simple and fast extreme multi-class and multi-label classifiers"
HOMEPAGE_URL https://github.com/mwydmuch/napkinXC
LANGUAGES C CXX)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ A minimal example of usage:
```
from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k
from napkinxc.metrics import precision_at_k
X_train, Y_train = load_dataset("eurlex-4k", "train")
X_test, Y_test = load_dataset("eurlex-4k", "test")
Expand Down
2 changes: 1 addition & 1 deletion docs/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Minimal example of usage:
from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k
from napkinxc.metrics import precision_at_k
X_train, Y_train = load_dataset("eurlex-4k", "train")
X_test, Y_test = load_dataset("eurlex-4k", "test")
Expand Down
2 changes: 1 addition & 1 deletion experiments/calculate_Jain_et_al_inv_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.extend([file_dir, napkinxc_path])

from scripts_utils import *
from napkinxc.measures import Jain_et_al_inverse_propensity
from napkinxc.metrics import Jain_et_al_inverse_propensity


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion experiments/calculate_inv_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.extend([file_dir, napkinxc_path])

from scripts_utils import *
from napkinxc.measures import inverse_labels_priors
from napkinxc.metrics import inverse_labels_priors


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion experiments/calculate_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.extend([file_dir, napkinxc_path])

from scripts_utils import *
from napkinxc.measures import labels_priors
from napkinxc.metrics import labels_priors


if __name__ == "__main__":
Expand Down
6 changes: 3 additions & 3 deletions experiments/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sys.path.extend([file_dir, napkinxc_path])

from scripts_utils import *
from napkinxc.measures import *
from napkinxc.metrics import *


if __name__ == "__main__":
Expand All @@ -26,7 +26,7 @@
precision = 6
max_k = 5

measures = {
metrics = {
#"HL": {"func": hamming_loss, "needs_weights": False},
"P": {"func": precision_at_k, "needs_weights": False},
"R": {"func": recall_at_k, "needs_weights": False},
Expand All @@ -39,7 +39,7 @@
"C": {"func": coverage_at_k, "needs_weights": False},
}

for m, v in measures.items():
for m, v in metrics.items():
r = None
if v["needs_weights"]:
if labels_weights is not None:
Expand Down
2 changes: 1 addition & 1 deletion experiments/misc/all_vs_head_labels_perfromance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import numpy as np
from napkinxc.datasets import *
from napkinxc.measures import *
from napkinxc.metrics import *
from napkinxc.models import PLT


Expand Down
2 changes: 1 addition & 1 deletion pybind11
Submodule pybind11 updated 193 files
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ requires = ["cmake>=3.13.0", "cmaketools", "setuptools", "wheel"]

[tool.cibuildwheel]
# We need to build for the following Python versions:
build = "cp{38,39,310,311,312}-*"
build = "cp{39,310,311,312}-*"

[tool.cibuildwheel.linux]
# Only manylinux is supported (no musl)
build = "cp{38,39,310,311,312}-manylinux*"
build = "cp{39,310,311,312}-manylinux*"

# For manylinux2014 we need to install the following dependencies using yum:
before-all = "yum install -y cmake"
Expand Down
2 changes: 1 addition & 1 deletion python/examples/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k
from napkinxc.metrics import precision_at_k

# Use load_dataset function to load one of the benchmark datasets
# from XML Repository (http://manikvarma.org/downloads/XC/XMLRepository.html).
Expand Down
2 changes: 1 addition & 1 deletion python/examples/online_f-measure_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import f1_measure
from napkinxc.metrics import f1_measure
from sklearn.model_selection import train_test_split

# Use load_dataset function to load one of the benchmark datasets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k, psprecision_at_k, Jain_et_al_inverse_propensity
from napkinxc.metrics import precision_at_k, psprecision_at_k, Jain_et_al_inverse_propensity

# The beginning is the same as in the basic.py example.

Expand Down
2 changes: 1 addition & 1 deletion python/examples/train_predict_on_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from napkinxc.datasets import download_dataset, load_dataset, save_libsvm_file
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k
from napkinxc.metrics import precision_at_k

# Use download_dataset to download data
# from XML Repository (http://manikvarma.org/downloads/XC/XMLRepository.html).
Expand Down
2 changes: 1 addition & 1 deletion python/examples/train_store_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from napkinxc.datasets import load_dataset
from napkinxc.models import PLT
from napkinxc.measures import precision_at_k
from napkinxc.metrics import precision_at_k

# The beginning is the same as in the basic.py example.

Expand Down
Loading

0 comments on commit 848f9fa

Please sign in to comment.