Expand description
Python bindings for the sklears machine learning library
This crate provides PyO3-based Python bindings for sklears, enabling seamless integration with the Python ecosystem while maintaining Rust’s performance advantages.
§Features
- Drop-in replacement for scikit-learn’s most common algorithms
- 3-100x performance improvements over scikit-learn
- Full NumPy array compatibility
- Comprehensive error handling with Python exceptions
- Memory-safe operations with automatic reference counting
§Example
import sklears_python as skl
import numpy as np
# Create sample data
X = np.random.randn(100, 4)
y = np.random.randn(100)
# Train a linear regression model
model = skl.LinearRegression()
model.fit(X, y)
predictions = model.predict(X)Macros§
- wrap_
pyfunction - Wraps a Rust function annotated with
#[pyfunction].
Structs§
- Borrowed
- A borrowed equivalent to
Bound. - Bound
- A GIL-attached equivalent to
Py<T>. - Performance
Stats - Performance monitoring structure
- Py
- A GIL-independent reference to an object allocated on the Python heap.
- PyAny
- Represents any Python object.
- PyClass
Initializer - Initializer for our
#[pyclass]system. - PyErr
- Represents a Python exception.
- PyLasso
- Python wrapper for Lasso regression
- PyLinear
Regression - Ordinary least squares Linear Regression.
- PyLogistic
Regression - Logistic Regression (aka logit, MaxEnt) classifier.
- PyModule
- Represents a Python
moduleobject. - PyRef
- A wrapper type for an immutably borrowed value from a
Bound<'py, T>. - PyRef
Mut - A wrapper type for a mutably borrowed value from a
Bound<'py, T>. - PyRidge
- Python wrapper for Ridge regression
- PyValue
Error - Represents Python’s
ValueErrorexception. - Python
- A marker token that represents holding the GIL.
Enums§
- Sklears
Python Error - Enhanced error handling for sklears-python
Traits§
- From
PyObject - Extract a type from a Python object.
- Into
PyObject - Defines a conversion from a Rust type to a Python object, which may fail.
- PyAny
Methods - This trait represents the Python APIs which are usable on all Python objects.
- PyBool
Methods - Implementation of functionality for
PyBool. - PyByte
Array Methods - Implementation of functionality for
PyByteArray. - PyBytes
Methods - Implementation of functionality for
PyBytes. - PyCapsule
Methods - Implementation of functionality for
PyCapsule. - PyComplex
Methods - Implementation of functionality for
PyComplex. - PyDict
Methods - Implementation of functionality for
PyDict. - PyFloat
Methods - Implementation of functionality for
PyFloat. - PyFrozen
SetMethods - Implementation of functionality for
PyFrozenSet. - PyList
Methods - Implementation of functionality for
PyList. - PyMapping
Methods - Implementation of functionality for
PyMapping. - PyMapping
Proxy Methods - Implementation of functionality for
PyMappingProxy. - PyModule
Methods - Implementation of functionality for
PyModule. - PySequence
Methods - Implementation of functionality for
PySequence. - PySet
Methods - Implementation of functionality for
PySet. - PySlice
Methods - Implementation of functionality for
PySlice. - PyString
Methods - Implementation of functionality for
PyString. - PyTraceback
Methods - Implementation of functionality for
PyTraceback. - PyTuple
Methods - Implementation of functionality for
PyTuple. - PyType
Methods - Implementation of functionality for
PyType. - PyWeakref
Methods - Implementation of functionality for
PyWeakref.
Functions§
- benchmark_
basic_ operations - Performance testing utility
- calculate_
r2_ score - Calculate R² score with optimized array operations
- check_
memory_ usage - Check memory usage and warn if arrays are very large
- get_
available_ memory_ mb - Get system memory information for better memory management
- get_
build_ info - Get build information about sklears
- get_
config - Get current configuration
- get_
hardware_ info - Get hardware acceleration capabilities
- get_
memory_ info - Get memory usage information
- get_
version - Get the version of sklears
- has_
feature - Check if specific features are enabled
- ndarray1_
to_ numpy - Convert ndarray Array1
to NumPy array - ndarray_
to_ numpy - Convert ndarray Array2
to NumPy array - numpy_
to_ ndarray1 - Convert NumPy array to ndarray Array1
- simplified implementation - numpy_
to_ ndarray2 - Convert NumPy array to ndarray Array2
- simplified implementation - set_
config - Set global configuration options
- show_
versions - Print system information
- validate_
finite_ values - Validate that array contains only finite values
- validate_
finite_ values_ 1d - Validate that 1D array contains only finite values
- validate_
fit_ arrays - Validate input arrays for model fitting
- validate_
fit_ arrays_ enhanced - Enhanced validation functions with better error handling
- validate_
predict_ array - Validate input arrays for prediction
Type Aliases§
- Array1
- one-dimensional array
- Array2
- two-dimensional array
- Linear
Model Result - Common error type for linear model operations
- PyArray1
- One-dimensional array.
- PyArray2
- Two-dimensional array.
- PyObject
Deprecated - A commonly-used alias for
Py<PyAny>. - PyReadonly
Array1 - Read-only borrow of a one-dimensional array.
- PyReadonly
Array2 - Read-only borrow of a two-dimensional array.
- PyResult
- Represents the result of a Python call.
Attribute Macros§
- pyclass
- pyfunction
- A proc macro used to expose Rust functions to Python.
- pymethods
- A proc macro used to expose methods to Python.
- pymodule
- A proc macro used to implement Python modules.