semvec/pypi-packages huggingface dataset:
litepipe 2.0.1b1
Lightweight Python library for data pipelines
Requires Python: >=3.9

## Litepipe
Lightweight Python module for building modules using syntax similar to Apache Beam.

Pipelines can be created using two classes provided in this package - `Pipeline` and `Transform`.

A `Pipeline` is a one or more `Transforms` which are essentially functions cast as a `Transform` class so that they
can be easily chained together.

Once a `Pipeline` is defined, inputs can be passed through using the `run` functionality.
The output of the final step in the pipeline is returned from the `run` function.

As mentioned above `Transform` is basically a wrapper class for a function with an overloaded `__rshift__` method.
This allows `Transforms` to be chained together using a syntax like

```commandline
transform_one >> transform_two
```

This package was born from my curiosity to how packages like [Apache Beam](https://beam.apache.org/) and
[Apache Airflow](https://airflow.apache.org/) use the greater than operator to chain functions.

### Installation Instructions
```python
pip install litepipe
```

### Example Pipeline

#### Creating Transforms

Transforms can be easily created using multiple syntax

By first defining a function and passing it as a parameter to the Transform class

```
def add_two(x: int):
  return x + 2

add_two_transfrom = Transform(add_two)
```

By passing a lambda function as a parameter

```
add_transform = Transform(lambda x: x + 2)
```

Wrapping the function with a decorator function that can be imported from the Transform module

```
@t
def print_and_divide(input, divider=4):
    print(f"Input: {input} will be divided by {divider}")
    return input / divider
```

### Example Pipeline

```
add_transform = Transform(lambda x: x + 2)
hello_int = Transform(lambda x: f'Hello, {x}')

pipeline = Pipeline(add_transform >> hello_int)

pval = pipeline.run(5)
print(pval.result)
# 'Hello, 7'
```

Pipelines return a [Pval](https://github.com/tunnelWithAC/litepipe/blob/master/litepipe/pval.py) object which can be
chained directly to transforms to create new pipelines.

```commandline
add_transform = Transform(lambda x: x + 2)
pipeline = Pipeline(add_transform >> add_transform)

pval = pipeline.run(2)
# pval.result - 6

second_pval = pval >> add_transform
# second_pval.result - 8
```
clustanom 0.1.0
ClustAnom is a Scikit-Learn compatible, clustering based anomaly detection library.
Requires Python: >=3.10

# ClustAnom - Clustering Based Anomaly Detection

ClustAnom is a scikit-learn compatible anomaly detection framework that utilizes user-defined clustering algorithms. It determines anomalies based on the distance of data points from their assigned cluster centers. This flexible approach allows integration with various clustering methods to detect outliers effectively.

## 🔍 Features

- Supports user-defined clustering models.
- Measures anomaly scores based on distance from cluster centroids.
- Fully compatible with scikit-learn pipelines.
- Easy integration with existing machine learning workflows.

## 🚀 Supported Clustering Algorithms
ClustAnom supports clustering models that implement `fit`, `predict` or `fit_predict` methods:

- `AffinityPropagation`
- `AgglomerativeClustering`
- `Birch`
- `DBSCAN`
- `KMeans`
- `MiniBatchKMeans`
- `MeanShift`
- `OPTICS`
- `SpectralClustering`
- `GaussianMixture`
- `BayesianGaussianMixture`

### ❌ Unsupported Clustering Algorithms
Explicitly unsupported clustering algorithms include, but are not limited to:

- `FeatureAgglomeration`
- `SpectralBiclustering`
- `SpectralCoclustering`

### ⚠️ Warnings
Clusterers which return anomaly labels (e.g. `DBSCAN`) will cause a discrepancy between `fit` and `score_samples` where in `score_samples` the anomaly score for already anomalous samples will be `np.inf` or `self.scaler_.data_max_` based on `self.scale_scores`. Additionally, clusterers with no `predict` require double fitting in both `fit` and `score_samples` or `predict` which may cause additional discrepancies.

## 📦 Installation
You can install ClustAnom via PyPI:

```bash
pip install clustanom
```

## 🛠️ Usage Example

```python
from clustanom.detector import ClusterAnomalyDetector
from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs

# Sample data
X, _ = make_blobs(n_samples=1000, centers=3, random_state=42)

# Define clusterer
clusterer = KMeans(n_clusters=3, random_state=42)

# Initialize cluster anomaly detector
anomaly_detector = ClusterAnomalyDetector(clusterer)

# Fit, predict and score
anomaly_detector.fit(X)
predictions = anomaly_detector.predict(X)
anomaly_scores = anomaly_detector.score_samples(X)
print("Anomaly Scores:", anomaly_scores)
```

## ⚙️ Parameters 

- **`clusterer`**: Any scikit-learn compatible clustering model (e.g., KMeans, Birch, Gaussian Mixture Model).
- **`contamination`**: The proportion of anomalies in the dataset, which determines the threshold for anomaly classification.
- **`scale_scores`**: Whether to scale the distances using MinMax scaling for better interpretability (limits anomaly scores to `[0, 1]`).


## ⚙️ Methods

- **`fit(X)`**: Fits the clustering model and computes the anomaly detection threshold.
- **`score_samples(X)`**: Computes anomaly scores for each sample based on its distance to the nearest cluster centroid.
- **`predict(X)`**: Predicts whether each sample is an anomaly (`-1`) or normal (`1`) in accordance with scikit-learn conventions.

## 📜 License

This project is licensed under the MIT License.