ocelastic: Elastic Net One-Class Classifier for Anomaly Detection
ocelastic is a Python package for one-class classification and anomaly detection.
It leverages Elastic Net and convex hull optimization to identify anomalies in data.
Designed for flexibility, it supports various kernel methods and is compatible with
scikit-learn tools like GridSearchCV and Pipeline.
Key Features
- Elastic Net Regularization: Combines L1 and L2 penalties for robust optimization.
- Kernel Support: Includes
rbf,linear,poly, andsigmoidkernels. - Custom Threshold: Automatically find the best decision boundary using
ThresholdFinder. - Scikit-learn Compatibility: Fully compatible with scikit-learn tools like
PipelineandGridSearchCV. - Anomaly Detection: Designed specifically for one-class classification tasks.
Installation
Install the package using pip:
pip install oneclass-elasticnet
Quick Start
from ocelastic import EnetConvexHull, ThresholdFinder
import numpy as np
# Generate synthetic data
X = np.random.rand(100, 2) # 100 samples, 2 features
# Initialize and fit the model
model = EnetConvexHull(landa1=0.5, metric='rbf', solver='cvxopt')
model.fit(X)
# Use ThresholdFinder to calculate the optimal threshold
finder = ThresholdFinder(model=model, X=X)
z_values, max_z = finder.find()
# Make predictions
predictions = model.predict(X)
Parameters
- landa1: The weight for L1 regularization (default: 0.5).
- metric: Kernel function for pairwise similarity (
rbf,linear,poly,sigmoid). - thr: Decision threshold for anomaly detection (default: 1.0).
- kernel_params: Additional kernel parameters like
gamma,degree, andcoef0. - solver: Quadratic programming solver (e.g.,
cvxopt).
Results
Below is an example of the decision boundary generated by the model:
Requirements
- Python >= 3.8
- scikit-learn
- numpy
- matplotlib
- tqdm
- qpsolvers
Contributing
We welcome contributions! To get started:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name). - Commit your changes (
git commit -m 'Add a new feature'). - Push to the branch (
git push origin feature/your-feature-name). - Create a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contact
For questions or feedback, please email [yousof.ghalenoei2017@gmail.com] or open an issue in the repository.
Metadata
Release files for oneclass-elasticnet 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| oneclass_elasticnet-0.0.1.tar.gz | 12.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oneclass_elasticnet-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.3 kB
Release files / oneclass_elasticnet-0.0.1.tar.gz
| Download URL | oneclass_elasticnet-0.0.1.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45d4ddb5aa7c50e4bc9466c62af4a19953b5b5caf818a921836a7f08eb945a32
|
|
BLAKE2b-256 checksum How to use checksums |
7ac8cf238c570f6ecac307d455890b6cffa0f2ea2fe09489443e6cff9546ccc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.1
|
Release files / oneclass_elasticnet-0.0.1-py3-none-any.whl
| Download URL | oneclass_elasticnet-0.0.1-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81428e1d168a918027182081d867d20378c9e5897883f073bbc10c4f031413e9
|
|
BLAKE2b-256 checksum How to use checksums |
bdd7cd37544d80044c04d66cc9cd8c5b5f0135c0d7746662f920180a11af3581
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.1
|
Security for oneclass-elasticnet 0.0.1
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.