Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

CoreMLMath

Multithreaded C++ backend for Machine Learning Math.

Thanks to pybind11 and OpenMP for existing in this world.

Financial Support

GitHub Sponsors

Donate via

Donate via PayPal

Build Instructions

  • Clone the repo locally:

    git clone https://github.com/novfensec/coremlmath -b master --single-branch --depth 1
    cd coremlmath
    
  • Linux:

    sudo apt update
    sudo apt install -y build-essential cmake
    
  • Windows (Powershell):

    Install the necessary C++ build tools and CMake using Windows Package Manager (winget):

    This has to be done only once.

    winget install -e --id Microsoft.VisualStudio.BuildTools --override "--passive --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended" --source winget
    winget install -e --id Kitware.CMake --source winget
    
  • Install pybind11:

    pip install "pybind11[global]" uv
    
  • Build and install using standard pip:

    pip install .
    

    Or using uv for isolated, fast builds:

    uv pip install .
    
  • Build an installable wheel:

    uv build --wheel
    

Usage

The package expects 2D and 1D NumPy arrays of integers for maximum memory efficiency.

import numpy as np
import cmlmath
import time

print("Generating massive dataset (1,000,000 rows, 500 features)...")
X_raw = np.random.randint(0, 2, size=(1000000, 500), dtype=np.int32)
y_raw = np.random.randint(0, 16, size=(1000000,), dtype=np.int32)

# Enforce C-contiguous (Row-Major) layout in memory. 
# (np.random generates C-contiguous arrays by default, but this guarantees 
# safety if you ever swap the data source out for a Pandas DataFrame or transposed array).
X = np.ascontiguousarray(X_raw, dtype=np.int32)
y = np.ascontiguousarray(y_raw, dtype=np.int32)

print(f"Starting multithreaded C++ calculation using {cmlmath.get_cpu_cores()} cores...")
start = time.time()

info_gains = cmlmath.information_gain(X, y)
gini_gains = cmlmath.gini_gain(X, y)

calc_time = time.time() - start

print(f"Calculated 500 Information and Gini Gains in {calc_time:.4f} seconds.")
print(f"Best feature index to split on (Information Gain): {np.argmax(info_gains)}")
print(f"Best feature index to split on (Gini Gain): {np.argmax(gini_gains)}")

Metadata

Release files for coremlmath 0.1.0.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for coremlmath 0.1.0.dev0
File Size Uploaded Provenance Actions
coremlmath-0.1.0.dev0.tar.gz 8.5 kB Without provenance Details for coremlmath-0.1.0.dev0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for coremlmath 0.1.0.dev0
File Interpreter ABI Platform Actions
coremlmath-0.1.0.dev0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for coremlmath-0.1.0.dev0-cp313-cp313-win_amd64.whl

Total release size: 94.2 kB

Release files / coremlmath-0.1.0.dev0.tar.gz

Download URL coremlmath-0.1.0.dev0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
949f40be48cd360cf0703fd9dfb0016b5761f0a2d5126fe3b29f2a258238985b
BLAKE2b-256 checksum
How to use checksums
555448b8ff91edbeea25a1f99eb3112610a6038e8fcb455693c1037ffaec188e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / coremlmath-0.1.0.dev0-cp313-cp313-win_amd64.whl

Download URL coremlmath-0.1.0.dev0-cp313-cp313-win_amd64.whl
Size 85.7 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
4d8020ee98e56ea5774532c24757badbde4d6e8a1fb7719d1f712db11f777035
BLAKE2b-256 checksum
How to use checksums
00919aa35b4f0c93380b019d67ca9c028153bf61c6741cf30423ae1dff81d9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for coremlmath 0.1.0.dev0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page