Metadata-Version: 2.1
Name: hidden-outlier-generation
Version: 1.0.0
Summary: Python implementation of the bisect algorithm for hidden outlier generation.
Author-email: David Schulmeister <david.schulmeister@student.kit.edu>
License: The MIT License (MIT)
        Copyright © 2023 David
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://github.com/dschulmeist/hidden-outlier-generation
Keywords: hidden,bisect,outlier,generation
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.2
Requires-Dist: pyod>=0.9.4
Requires-Dist: scikit-learn>=1.2.0
Requires-Dist: tensorflow>=2.9.0
Requires-Dist: joblib>=1.3.0

# Hidden Outlier Generator with Bisection Algorithm

## Description

This repository hosts a Python-based hidden outlier generator leveraging the bisect algorithm. 


## Installation

To install, clone this repository:

\```bash
git clone https://github.com/dschulmeist/hidden-outlier-generation
\```

## Usage

Here's how to import and use the main function to generate synthetic hidden outliers:

\```python
from hog_bisect.bisect import BisectHOGen

# Initialize the generator
generator = BisectHOGen(data, outlier_detection_method=pyod.models.lof.LOF, seed=42)

# Generate hidden outliers
outliers = generator.fit_generate(gen_points=100)
\```

## Features

### Methods and Classes

#### `fit_generate()`

Generate synthetic hidden outliers using a bisection algorithm.

- **Args:**
    - `gen_points` (int): Number of synthetic points to generate.
    - `check_fast` (bool): Fast check flag.
    - `fixed_interval_length` (bool): Flag for fixed interval length.
    - `get_origin_type` (str): Method to determine the origin.
    - `verbose` (bool): Verbose flag.
    - `n_jobs` (int): Number of parallel jobs.

- **Returns:**
    - ndarray: An array containing generated hidden outliers.

#### `BisectHOGen`

A class for generating synthetic hidden outliers.

## Code Structure

### `BisectHOGen` Class

The `BisectHOGen` class initializes the generator and contains utility methods.

\```python
class BisectHOGen:
...
\```

### Function Definitions

Functions like `outlier_check`, `inference`, `interval_check`, and `bisect` are defined to perform various tasks in the outlier detection and generation process.

\```python
def outlier_check(...):
...
def inference(...):
...
def interval_check(...):
...
def bisect(...):
...
\```

# Hidden Outlier Generator with Bisection Algorithm

## Description

This repository hosts a Python-based hidden outlier generator leveraging the bisect algorithm.

## Utility Functions

### `random_unif_on_sphere(number, dimensions, r, random_state=5)`

Generates uniformly distributed random points on a sphere.

- **Args:**
  - `number` (int): Number of points to generate.
  - `dimensions` (int): The dimensions of the sphere.
  - `r` (float): Radius of the sphere.
  - `random_state` (int, optional): Random seed.

- **Returns:**
  - ndarray: An array containing the generated points on the sphere.

### `gen_powerset(dims)`

Generates the power set of dimensions, which are sets containing all possible combinations of dimensions.

- **Args:**
  - `dims` (int): Number of dimensions.

- **Returns:**
  - set: The power set of dimensions.

### `subspace_grab(indices, data)`

Grabs a subspace of the data based on the specified indices.

- **Args:**
  - `indices` (list or tuple): Indices of the attributes for the subspace.
  - `data` (ndarray): The original data.

- **Returns:**
  - ndarray: The subspace data.

### `gen_rand_subspaces(dims, upper_limit, include_all_attr=True, seed=5)`

Generates random subspaces based on given dimensions.

- **Args:**
  - `dims` (int): Number of dimensions.
  - `upper_limit` (int): Upper limit for the number of subspaces.
  - `include_all_attr` (bool, optional): Whether to include all attributes.
  - `seed` (int, optional): Random seed.

- **Returns:**
  - set: The generated subspaces.

### `fit_model(subspace, data, outlier_detection_method, tempdir)`

Fits an outlier detection model for a given subspace.

- **Args:**
  - `subspace` (tuple): The subspace to fit the model on.
  - `data` (ndarray): The dataset.
  - `outlier_detection_method` (class): The outlier detection model class.
  - `tempdir` (str): Temporary directory for storing data.

- **Returns:**
  - tuple: The subspace and the fitted model.

### `fit_in_all_subspaces(...)`

Fits models for all possible subspaces of the given data.

- **Args:**
  - `outlier_detection_method` (class): The outlier detection model class.
  - `data` (ndarray): The dataset.
  - `tempdir` (str): Temporary directory for storing data.
  - `subspace_limit` (int): 2^subspace_limit will be the maximum amount of subspaces fitted.
  - `seed` (int, optional): Seed for random number generator.
  - `n_jobs` (int): Number of cores to use.

- **Returns:**
  - dict: Dictionary of models fitted on different subspaces.




