Skip to main content

Crate sklears_python

Crate sklears_python 

Source
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
  • Pure Rust implementation with ongoing performance optimization
  • 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 Python thread-attached equivalent to Py<T>.
PerformanceStats
Performance monitoring structure
Py
A reference to an object allocated on the Python heap.
PyARDRegression
Bayesian ARD regression.
PyAdaBoostClassifier
Python wrapper for AdaBoost Classifier
PyAny
Represents any Python object.
PyBaggingClassifier
Python wrapper for Bagging Classifier
PyBayesianRidge
Bayesian ridge regression.
PyBernoulliNB
Python wrapper for Bernoulli Naive Bayes
PyClassInitializer
Initializer for our #[pyclass] system.
PyComplementNB
Python wrapper for Complement Naive Bayes
PyDBSCAN
Stub DBSCAN implementation for testing refactored structure
PyDecisionTreeClassifier
Python wrapper for Decision Tree Classifier
PyDecisionTreeRegressor
Python wrapper for Decision Tree Regressor
PyElasticNet
Linear regression with combined L1 and L2 priors as regularizer.
PyErr
Represents a Python exception.
PyGaussianNB
Python wrapper for Gaussian Naive Bayes
PyGradientBoostingClassifier
Python wrapper for GradientBoostingClassifier
PyGradientBoostingRegressor
Python wrapper for GradientBoostingRegressor
PyKFold
Stub KFold cross-validator implementation
PyKMeans
Stub KMeans implementation for testing refactored structure
PyLasso
Python wrapper for Lasso regression
PyLinearRegression
Ordinary least squares Linear Regression.
PyLogisticRegression
Logistic Regression (aka logit, MaxEnt) classifier.
PyMLPClassifier
Python wrapper for MLP Classifier
PyMLPRegressor
Python wrapper for MLP Regressor
PyModule
Represents a Python module object.
PyMultinomialNB
Python wrapper for Multinomial Naive Bayes
PyRandomForestClassifier
Python wrapper for Random Forest Classifier
PyRandomForestRegressor
Python wrapper for Random Forest Regressor
PyRef
A wrapper type for an immutably borrowed value from a Bound<'py, T>.
PyRefMut
A wrapper type for a mutably borrowed value from a Bound<'py, T>.
PyRidge
Python wrapper for Ridge regression
PyValueError
Represents Python’s ValueError exception.
PyVotingClassifier
Python wrapper for Voting Classifier
Python
A marker token that represents holding the GIL.

Enums§

SklearsPythonError
Enhanced error handling for sklears-python

Traits§

FromPyObject
Extract a type from a Python object.
FromPyObjectOwned
A data structure that can be extracted without borrowing any data from the input.
IntoPyObject
Defines a conversion from a Rust type to a Python object, which may fail.
PyAnyMethods
This trait represents the Python APIs which are usable on all Python objects.
PyBoolMethods
Implementation of functionality for PyBool.
PyByteArrayMethods
Implementation of functionality for PyByteArray.
PyBytesMethods
Implementation of functionality for PyBytes.
PyCapsuleMethods
Implementation of functionality for PyCapsule.
PyComplexMethods
Implementation of functionality for PyComplex.
PyDictMethods
Implementation of functionality for PyDict.
PyFloatMethods
Implementation of functionality for PyFloat.
PyFrozenSetMethods
Implementation of functionality for PyFrozenSet.
PyListMethods
Implementation of functionality for PyList.
PyMappingMethods
Implementation of functionality for PyMapping.
PyMappingProxyMethods
Implementation of functionality for PyMappingProxy.
PyModuleMethods
Implementation of functionality for PyModule.
PySequenceMethods
Implementation of functionality for PySequence.
PySetMethods
Implementation of functionality for PySet.
PySliceMethods
Implementation of functionality for PySlice.
PyStringMethods
Implementation of functionality for PyString.
PyTracebackMethods
Implementation of functionality for PyTraceback.
PyTupleMethods
Implementation of functionality for PyTuple.
PyTypeMethods
Implementation of functionality for PyType.
PyWeakrefMethods
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
core_array1_to_py
Convert an ndarray Array1 into a Python-owned NumPy array object
core_array2_to_py
Convert an ndarray Array2 into a Python-owned NumPy array object
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<f64> to NumPy array
ndarray_to_numpy
Convert ndarray Array2<f64> to NumPy array
numpy_to_ndarray1
Convert NumPy array to ndarray Array1<f64>
numpy_to_ndarray2
Convert NumPy array to ndarray Array2<f64>
pyarray_to_core_array1
Convert a read-only NumPy array view into an owned SciRS2 ndarray Array1
pyarray_to_core_array2
Convert a read-only NumPy array view into an owned SciRS2 ndarray Array2
set_config
Set global configuration options
show_versions
Print system information
train_test_split
Split arrays into random train and test subsets
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
LinearModelResult
Common error type for linear model operations
PyArray1
One-dimensional array.
PyArray2
Two-dimensional array.
PyObjectDeprecated
A commonly-used alias for Py<PyAny>.
PyReadonlyArray1
Read-only borrow of a one-dimensional array.
PyReadonlyArray2
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.

Derive Macros§

FromPyObject
IntoPyObject
IntoPyObjectRef