Skip to main content

Python package that implements an adaptive classification and regression system using simplicial complexes. The package provides a novel approach to handling both binary and multi-class classification problems, as well as regression tasks, by adaptively creating a simplicial decomposition of the feature space.

Project description

NBCS (Non-Binary Classification System)

Version: 1.2
License: MIT License
Author: Eran Kaufman
Email: erankfmn@gmail.com

Overview

NBCS (Non-Binary Classification System) is a Python package that implements an adaptive classification and regression system using simplicial complexes. The package provides a novel approach to handling both binary and multi-class classification problems, as well as regression tasks, by adaptively creating a simplicial decomposition of the feature space.

The package extends scikit-learn's base estimator and transformer interfaces, making it compatible with scikit-learn's ecosystem while providing unique capabilities for handling complex classification boundaries and non-linear regression problems.

Features

  • Adaptive Classification: Automatically adjusts the complexity of the decision boundary based on the data
  • Simplicial Complex Construction: Creates an optimal decomposition of the feature space
  • Multiple Learning Modes:
    • Barry fitting mode for general purpose learning
    • Adaptive fitting mode for classification tasks
  • Regression Support: Handles complex regression problems with piece-wise linear approximations
  • Visualization Tools: Built-in functions for plotting decision boundaries and regression results
  • Scikit-learn Compatible: Implements scikit-learn's BaseEstimator and TransformerMixin interfaces

Installation

You can install the package directly from PyPI using pip:

pip install nbcs

Usage

Classification Example

import numpy as np
from nbcs import NBCS
from sklearn.svm import SVC

# Create and fit the NBCS model
model = NBCS(C=1000, k=4)
embedder = model.fit(X, y)

# Transform the data
points = embedder.transform(X)

# Use with any sklearn classifier
clf = SVC(kernel='linear')
clf.fit(points, y)

Regression Example

from nbcs import NBCS
from sklearn.linear_model import LinearRegression

# Create and fit the NBCS model
model = NBCS(k=3)
embedder = model.fit_barry(X)

# Transform the data
points = embedder.transform(X)

# Use with any sklearn regressor
reg = LinearRegression()
reg.fit(points, y)

Parameters

  • C: Regularization parameter (default=1)
  • k: Number of refinement steps (default=1)

Available Methods

  • fit(X, y): Fits the model using adaptive mode
  • fit_barry(X, y): Fits the model using barry mode
  • transform(X): Transforms input data using the fitted model
  • add_point(point): Adds a new point to the simplicial complex
  • find_point(pts): Finds which simplex a point belongs to

Visualization

The package includes several visualization tools:

from nbcs.utils import make_meshgrid, plot_contours

# Create mesh grid for visualization
xx, yy = make_meshgrid(X[:, 0], X[:, 1])

# Plot decision boundaries
plot_contours(ax, clf, xx, yy, xy)

Dependencies

  • numpy
  • scipy
  • scikit-learn
  • matplotlib

Examples

Classification with Regular Polytope

import numpy as np
from nbcs import NBCS
from sklearn.svm import SVC

# Generate synthetic data
N = 1000
D = 2  # dimension
X = np.random.normal(0, 1, (N, D))
y = np.ones(N)

# Create and fit model
model = NBCS(C=1000, k=4)
embedder = model.fit(X, y)

Regression with Multiple Lines

import numpy as np
from nbcs import NBCS
from sklearn.linear_model import LinearRegression

# Generate synthetic data
x = np.linspace(0, 30, 60).reshape(-1, 1)
y = np.sin(x/10) + np.random.normal(0, 0.1, x.shape)

# Create and fit model
model = NBCS(k=3)
embedder = model.fit_barry(x)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • scikit-learn for providing the foundational tools for machine learning in Python
  • numpy and scipy for numerical computations
  • matplotlib for data visualization

Contact

If you have any questions or suggestions, feel free to reach out at erankfmn@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NBCS-1.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

NBCS-1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file NBCS-1.2.tar.gz.

File metadata

  • Download URL: NBCS-1.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for NBCS-1.2.tar.gz
Algorithm Hash digest
SHA256 7a8fa347fb5962ed08e92319cca925ead0ead5a1f3a7953d41060c0dd1f5c4ae
MD5 e4a8c24e654be6108b87f02b27fe70b4
BLAKE2b-256 1487433d673a7e0e753453d60bb321f3b5a8e0d5373fb0528be91484f38bb9a2

See more details on using hashes here.

File details

Details for the file NBCS-1.2-py3-none-any.whl.

File metadata

  • Download URL: NBCS-1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for NBCS-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b44d1104bc97c66bc9be099e13bf8688b6a8df700f21b257cee3ada74639dba
MD5 990139e36bf67d0eb098c23ab8da8cf3
BLAKE2b-256 c33a0b79636bf84a64084f12a8f7d70ad1755ac007b8d84e9c97ee51d05ebadb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page