Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/linux_installation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Package Installation

on: [push, pull_request]

jobs:
linux-installation:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5

- name: Install dependencies
run: pip install poetry

- name: Run installation script
run: |
chmod +x scripts/install_user_linux.sh && ./scripts/install_user_linux.sh

- name: Run example
run: poetry run python example.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to have an example run in an installation file?

24 changes: 24 additions & 0 deletions .github/workflows/windows_installation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Package Installation

on: [push, pull_request]

jobs:
windows-installation:

runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5

- name: Install dependencies
run: pip install poetry

- name: Run installation script
run: |
./scripts/install_user_windows.ps1
poetry add pyqt5-qt5==5.15.2

- name: Run example
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to have an example run in an installation file?

run: poetry run python example.py
54 changes: 38 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PySATL-CPD
PySATL-CPD

[status-shield]: https://img.shields.io/github/actions/workflow/status/PySATL/pysatl-cpd/.github/workflows/check.yaml?branch=main&event=push&style=for-the-badge&label=Checks
[status-url]: https://github.com/PySATL/pysatl-cpd/blob/main/.github/workflows/check.yaml
Expand Down Expand Up @@ -28,30 +28,44 @@ At the moment, the module implements the following CPD algorithms:
## Requirements

- Python 3.10+

- Poetry 2.1.0+



## Installation

Clone the repository:
Clone repository:

```bash
git clone https://github.com/PySATL/pysatl-cpd
```sh
git clone https://github.com/PySATL/pysatl-cpd.git
```

Install dependencies:


### Linux

Go to repository directory and run installation script:

```bash
poetry install
cd pysatl-cpd
chmod +x scripts/install_user_linux.sh && ./scripts/install_user_linux.sh
```

Or run ```create_user_venv.sh``` (for linux)

```bash
chmod +x create_user_venv.sh
./create_user_venv.sh

### Windows

Go to repository directory and run installation script:

```shell
Set-Location pysatl-cpd
./scripts/install_user_windows.ps1
```




## Change point detection example:

```python
Expand Down Expand Up @@ -165,21 +179,27 @@ Located change points: [25, 201, 396]
```



## Development

Install requirements
If you want to contribute, you should create development environment as follows:

### Linux

```bash
poetry install --with dev
chmod +x scripts/install_dev_linux.sh && ./scripts/install_dev_linux.sh
```

Or run ```create_dev_venv.sh``` (for linux)

```bash
chmod +x create_dev_venv.sh
./create_dev_venv.sh

### Windows

```shell
./scripts/install_dev_windows.ps1
```



## Pre-commit

Install pre-commit hooks:
Expand All @@ -194,6 +214,8 @@ Starting manually:
poetry run pre-commit run --all-files --color always --verbose --show-diff-on-failure
```



## License

This project is licensed under the terms of the **MIT** license. See the [LICENSE](LICENSE) for more information.
142 changes: 142 additions & 0 deletions docs/Guide CPD Benchmark.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Guide benchmarking

This guide is intended for those who plan to use the benchmarking of the pysatl-cpd project to analyze algorithms for finding change points.

## Installation

Clone repository:

```bash
git clone https://github.com/PySATL/pysatl-cpd.git
```



### Linux

Go to repository folder and run installation script:

```bash
cd pysatl-cpd
chmod +x scripts/install_user_linux.sh && ./scripts/install_user_linux.sh
```



### Windows

Go to repository folder and run installation script

```shell
Set-Location pysatl-cpd
./scripts/install_user_windows.ps1
```



## Data Generation

### Available distributions

| Распределение | Название | Параметры |
| ------------------- | --------------------- | ------------------------------------------------------- |
| Normal | `normal` | `mean`, `variance` |
| Exponential | `exponential` | `rate` |
| Weibull | `weibull` | `shape`, `scale` |
| Uniform | `uniform` | `min`, `max` |
| Beta | `beta` | `alpha`, `beta` |
| Gamma | `gamma` | `alpha`, `beta` |
| t-Student | `t` | `n` |
| Lognormal | `lognorm` | `s` |
| Multivariate normal | `multivariate_normal` | `mean`, in the form of string of list, z `"[0.5, 2.0]"` |



### How to configure?

To generate a test time series, create a new configuration file inside the `pysatl_cpd/examples/configs` directory. This file defines the segments that will be concatenated in order to create the final time series.

Structure of the config file:

```yaml
- name: config_name
distributions:
- type: dist1
length: length1
parameters:
parameter1_1: value1_1
parameter1_2: value1_2
- type: dist2
length: length2
parameters:
parameter2_1: value2_1
parameter2_2: value2_2
# ... you can add more distribution segments here
```

**Fields**:

- `name`: A unique name for your configuration.
- `distributions`: A list of data segments to be generated. Each item in the list is a segment.
- `type`: The distribution type for the segment (e.g., normal, uniform).
- `length`: The length (number of data points) for this segment.
- `parameters`: The parameters required by the chosen distribution type (e.g., mean and variance for a normal distribution).



> Note: The available distribution types and their parameters must match the options listed in the table above. Please refer to it for a complete list of supported distributions and their required parameters.

### Config example

```yaml
- name: example
distributions:
- type: exponential
length: 200
parameters:
rate: 2.0
- type: beta
length: 200
parameters:
alpha: 1.0
beta: 5.0
- type: uniform
length: 200
parameters:
min: 0
max: 0.5
```



## Algorithm configure

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this section is empty?



## Experiment run

Run example in the main directory:

```bash
poetry run python example.py
```



## Troubleshooting

### Import error: cannot import matplotlib

If you saw a similar error when running the script:

![](figures/trouble_1.png)

And then you get this error:

![](figures/trouble_1_1.png)

Then try installing a lower version of the package:

```bash
poetry add pyqt5-qt5==5.15.2
```
Binary file added docs/Guide CPD Benchmark.pdf
Binary file not shown.
Binary file added docs/figures/trouble_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/figures/trouble_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion create_dev_venv.sh → scripts/install_dev_linux.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

# Install dependencies
pip install poetry

# Create virtual environment
if command -v python3 &>/dev/null; then
PYTHON_CMD="python3"
elif command -v python &>/dev/null; then
Expand All @@ -18,5 +21,5 @@ echo "Using $PYTHON_CMD for installing .venv"
$PYTHON_CMD -m venv .venv
source .venv/bin/activate
pip install poetry
poetry install --with dev
poetry install --with-dev
deactivate
8 changes: 8 additions & 0 deletions scripts/install_dev_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pip install poetry

py -3 -m venv .venv

. .\.venv\Scripts\Activate.ps1
pip install poetry
poetry install --with-dev
deactivate
3 changes: 3 additions & 0 deletions create_user_venv.sh → scripts/install_user_linux.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

# Install dependencies
pip install poetry

# Create virtual environment
if command -v python3 &>/dev/null; then
PYTHON_CMD="python3"
elif command -v python &>/dev/null; then
Expand Down
8 changes: 8 additions & 0 deletions scripts/install_user_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pip install poetry

py -3 -m venv .venv

. .\.venv\Scripts\Activate.ps1
pip install poetry
poetry install
deactivate
Loading