Metadata-Version: 2.2
Name: oneclass-elasticnet
Version: 0.0.1
Summary: A package for anomaly detection using Elastic Net and Convex Hull.
Home-page: https://github.com/YousofLHC/flexi_datareader
Author: Yousof Ghalenoei
Author-email: yousof.ghalenoei2017@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: scikit-learn>=1.6.1
Requires-Dist: numpy>=1.26.4
Requires-Dist: qpsolvers>=4.3.1
Requires-Dist: tqdm>=4.66.2
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# 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`, and `sigmoid` kernels.
- **Custom Threshold**: Automatically find the best decision boundary using `ThresholdFinder`.
- **Scikit-learn Compatibility**: Fully compatible with scikit-learn tools like `Pipeline` and `GridSearchCV`.
- **Anomaly Detection**: Designed specifically for one-class classification tasks.
## Installation
Install the package using pip:
```bash
pip install oneclass-elasticnet
```
---
## Quick Start
```python
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`, and `coef0`.
- **solver**: Quadratic programming solver (e.g., `cvxopt`).
## Results
Below is an example of the decision boundary generated by the model:

![Decision Boundary](./path-to-decision-boundary.png)
## Requirements
- Python >= 3.8
- scikit-learn
- numpy
- matplotlib
- tqdm
- qpsolvers
## Contributing
We welcome contributions! To get started:
1. Fork the repository.
2. Create a new branch (`git checkout -b feature/your-feature-name`).
3. Commit your changes (`git commit -m 'Add a new feature'`).
4. Push to the branch (`git push origin feature/your-feature-name`).
5. 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.
