saiph 2.0.3__tar.gz → 2.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- saiph-2.0.4/.github/workflows/pr-title.yml +17 -0
- saiph-2.0.4/.github/workflows/release.yml +42 -0
- saiph-2.0.4/.github/workflows/saiph-ci.yml +44 -0
- saiph-2.0.4/.gitignore +140 -0
- saiph-2.0.4/.pre-commit-config.yaml +7 -0
- saiph-2.0.4/.readthedocs.yaml +27 -0
- saiph-2.0.4/.tool-versions +1 -0
- saiph-2.0.4/CONTRIBUTING.md +13 -0
- saiph-2.0.4/PKG-INFO +17 -0
- saiph-2.0.4/README.md +42 -0
- saiph-2.0.4/bin/create_csv.py +85 -0
- saiph-2.0.4/docs/conf.py +72 -0
- saiph-2.0.4/docs/index.rst +20 -0
- saiph-2.0.4/docs/requirements.txt +2 -0
- saiph-2.0.4/docs/source/example/README.rst +4 -0
- saiph-2.0.4/docs/source/example/plot_example.py +67 -0
- saiph-2.0.4/docs/source/reference.rst +56 -0
- saiph-2.0.4/fixtures/iris.csv +151 -0
- saiph-2.0.4/fixtures/wbcd.csv +684 -0
- saiph-2.0.4/justfile +100 -0
- saiph-2.0.4/pyproject.toml +96 -0
- saiph-2.0.4/release.py +215 -0
- saiph-2.0.4/ruff.toml +74 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/__init__.py +2 -2
- {saiph-2.0.3 → saiph-2.0.4}/saiph/conftest.py +2 -2
- {saiph-2.0.3 → saiph-2.0.4}/saiph/contribution.py +2 -3
- {saiph-2.0.3 → saiph-2.0.4}/saiph/inverse_transform.py +5 -8
- {saiph-2.0.3 → saiph-2.0.4}/saiph/inverse_transform_test.py +19 -43
- {saiph-2.0.3 → saiph-2.0.4}/saiph/lib/size.py +1 -3
- {saiph-2.0.3 → saiph-2.0.4}/saiph/models.py +16 -17
- {saiph-2.0.3 → saiph-2.0.4}/saiph/projection.py +18 -34
- {saiph-2.0.3 → saiph-2.0.4}/saiph/projection_test.py +17 -33
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/famd.py +31 -48
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/famd_sparse.py +13 -16
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/famd_sparse_test.py +3 -7
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/famd_test.py +2 -4
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/mca.py +19 -30
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/mca_test.py +2 -4
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/pca.py +11 -15
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/pca_test.py +2 -6
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/utils/common.py +9 -14
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/utils/common_test.py +5 -11
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/utils/svd.py +9 -11
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/utils/svd_test.py +1 -3
- {saiph-2.0.3 → saiph-2.0.4}/saiph/serializer.py +6 -12
- {saiph-2.0.3 → saiph-2.0.4}/saiph/serializer_test.py +2 -2
- saiph-2.0.4/saiph/tests/__init_.py +0 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/tests/profile_memory.py +1 -1
- {saiph-2.0.3 → saiph-2.0.4}/saiph/visualization.py +10 -24
- saiph-2.0.4/setup.cfg +10 -0
- saiph-2.0.4/tests/fixtures/breast_cancer_wisconsin.csv +684 -0
- saiph-2.0.4/tests/fixtures/breast_cancer_wisconsin_supplemental.csv +684 -0
- saiph-2.0.4/tests/fixtures/iris.csv +151 -0
- saiph-2.0.4/tests/fixtures/iris_factomineR_contributions.csv +8 -0
- saiph-2.0.4/tests/fixtures/iris_factomineR_cos2.csv +6 -0
- saiph-2.0.4/tests/fixtures/wbcd_supplemental_coordinates_famd.csv +684 -0
- saiph-2.0.4/tests/fixtures/wbcd_supplemental_coordinates_mca.csv +684 -0
- saiph-2.0.4/tests/fixtures/wbcd_supplemental_coordinates_pca.csv +684 -0
- saiph-2.0.4/uv.lock +2624 -0
- saiph-2.0.3/PKG-INFO +0 -21
- saiph-2.0.3/pyproject.toml +0 -110
- {saiph-2.0.3 → saiph-2.0.4}/LICENSE +0 -0
- /saiph-2.0.3/saiph/reduction/utils/__init__.py → /saiph-2.0.4/py.typed +0 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/contribution_test.py +0 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/exception.py +0 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/reduction/__init__.py +0 -0
- /saiph-2.0.3/saiph/tests/__init_.py → /saiph-2.0.4/saiph/reduction/utils/__init__.py +0 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/tests/benchmark_test.py +0 -0
- {saiph-2.0.3 → saiph-2.0.4}/saiph/tests/profile_cpu.py +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: "Check PR title"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- edited
|
|
8
|
+
- synchronize
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
main:
|
|
12
|
+
name: Validate PR title
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: amannn/action-semantic-pull-request@v4
|
|
16
|
+
env:
|
|
17
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- '*.*.*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
name: Release
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout code
|
|
14
|
+
uses: actions/checkout@v2
|
|
15
|
+
|
|
16
|
+
- name: Set up Python 3.12
|
|
17
|
+
uses: actions/setup-python@v2
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: uv sync
|
|
28
|
+
|
|
29
|
+
- name: Build project for distribution
|
|
30
|
+
run: uv build
|
|
31
|
+
|
|
32
|
+
- name: Create Release
|
|
33
|
+
uses: ncipollo/release-action@v1
|
|
34
|
+
with:
|
|
35
|
+
artifacts: "dist/*"
|
|
36
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
37
|
+
draft: false
|
|
38
|
+
|
|
39
|
+
- name: Publish to PyPI
|
|
40
|
+
env:
|
|
41
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
42
|
+
run: uv publish
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: "Check PR ci"
|
|
2
|
+
|
|
3
|
+
on: pull_request
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
saiph-ci:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
strategy:
|
|
9
|
+
matrix:
|
|
10
|
+
python-version: [
|
|
11
|
+
"3.11",
|
|
12
|
+
"3.12",
|
|
13
|
+
"3.13",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
19
|
+
uses: actions/setup-python@v4
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v5
|
|
25
|
+
with:
|
|
26
|
+
enable-cache: false
|
|
27
|
+
|
|
28
|
+
- name: Install just
|
|
29
|
+
uses: extractions/setup-just@v2
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: uv sync --extra matplotlib --group dev --group doc
|
|
33
|
+
|
|
34
|
+
- name: Typecheck
|
|
35
|
+
run: just typecheck
|
|
36
|
+
|
|
37
|
+
- name: Lint
|
|
38
|
+
run: just lint
|
|
39
|
+
|
|
40
|
+
- name: Build docs
|
|
41
|
+
run: just docs
|
|
42
|
+
|
|
43
|
+
- name: Run tests
|
|
44
|
+
run: just test
|
saiph-2.0.4/.gitignore
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib64/
|
|
18
|
+
parts/
|
|
19
|
+
sdist/
|
|
20
|
+
var/
|
|
21
|
+
wheels/
|
|
22
|
+
pip-wheel-metadata/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
|
|
53
|
+
# Translations
|
|
54
|
+
*.mo
|
|
55
|
+
*.pot
|
|
56
|
+
|
|
57
|
+
# Django stuff:
|
|
58
|
+
*.log
|
|
59
|
+
local_settings.py
|
|
60
|
+
db.sqlite3
|
|
61
|
+
db.sqlite3-journal
|
|
62
|
+
|
|
63
|
+
# Flask stuff:
|
|
64
|
+
instance/
|
|
65
|
+
.webassets-cache
|
|
66
|
+
|
|
67
|
+
# Scrapy stuff:
|
|
68
|
+
.scrapy
|
|
69
|
+
|
|
70
|
+
# Sphinx documentation
|
|
71
|
+
docs/_build/
|
|
72
|
+
|
|
73
|
+
# PyBuilder
|
|
74
|
+
target/
|
|
75
|
+
|
|
76
|
+
# Jupyter Notebook
|
|
77
|
+
.ipynb_checkpoints
|
|
78
|
+
|
|
79
|
+
# IPython
|
|
80
|
+
profile_default/
|
|
81
|
+
ipython_config.py
|
|
82
|
+
|
|
83
|
+
# pyenv
|
|
84
|
+
.python-version
|
|
85
|
+
|
|
86
|
+
# pipenv
|
|
87
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
88
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
89
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
90
|
+
# install all needed dependencies.
|
|
91
|
+
#Pipfile.lock
|
|
92
|
+
|
|
93
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
94
|
+
__pypackages__/
|
|
95
|
+
|
|
96
|
+
# Celery stuff
|
|
97
|
+
celerybeat-schedule
|
|
98
|
+
celerybeat.pid
|
|
99
|
+
|
|
100
|
+
# SageMath parsed files
|
|
101
|
+
*.sage.py
|
|
102
|
+
|
|
103
|
+
# Environments
|
|
104
|
+
.env
|
|
105
|
+
.venv
|
|
106
|
+
env/
|
|
107
|
+
venv/
|
|
108
|
+
ENV/
|
|
109
|
+
env.bak/
|
|
110
|
+
venv.bak/
|
|
111
|
+
|
|
112
|
+
# Spyder project settings
|
|
113
|
+
.spyderproject
|
|
114
|
+
.spyproject
|
|
115
|
+
|
|
116
|
+
# Rope project settings
|
|
117
|
+
.ropeproject
|
|
118
|
+
|
|
119
|
+
# mkdocs documentation
|
|
120
|
+
/site
|
|
121
|
+
|
|
122
|
+
# mypy
|
|
123
|
+
.mypy_cache/
|
|
124
|
+
.dmypy.json
|
|
125
|
+
dmypy.json
|
|
126
|
+
|
|
127
|
+
# Pyre type checker
|
|
128
|
+
.pyre/
|
|
129
|
+
|
|
130
|
+
# pytest-benchmark
|
|
131
|
+
.benchmarks/
|
|
132
|
+
|
|
133
|
+
# fil-profile results
|
|
134
|
+
fil-result/
|
|
135
|
+
|
|
136
|
+
# benchmark .csv
|
|
137
|
+
tmp/
|
|
138
|
+
|
|
139
|
+
# uv
|
|
140
|
+
.venv/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# .readthedocs.yaml
|
|
2
|
+
# Read the Docs configuration file
|
|
3
|
+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
4
|
+
|
|
5
|
+
# Required
|
|
6
|
+
version: 2
|
|
7
|
+
|
|
8
|
+
# Set the version of Python and other tools you might need
|
|
9
|
+
build:
|
|
10
|
+
os: ubuntu-24.04
|
|
11
|
+
tools:
|
|
12
|
+
python: "3.12"
|
|
13
|
+
|
|
14
|
+
# Build documentation in the docs/ directory with Sphinx
|
|
15
|
+
sphinx:
|
|
16
|
+
configuration: docs/conf.py
|
|
17
|
+
|
|
18
|
+
# If using Sphinx, optionally build your docs in additional formats such as PDF
|
|
19
|
+
# formats:
|
|
20
|
+
# - pdf
|
|
21
|
+
|
|
22
|
+
# Optionally declare the Python requirements required to build your docs
|
|
23
|
+
python:
|
|
24
|
+
install:
|
|
25
|
+
- requirements: docs/requirements.txt
|
|
26
|
+
- method: pip
|
|
27
|
+
path: .
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
python 3.13.5
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Contributing to Saiph
|
|
2
|
+
|
|
3
|
+
## Releasing a new version
|
|
4
|
+
|
|
5
|
+
Depending on the version bump you want to do, you'll run
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv run python release.py --bump-type {patch, minor, major} # choose one
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This will bump the version, commit it, and generate a tag and push it.
|
|
12
|
+
|
|
13
|
+
A Github action will then build that version and push it on `pypi`.
|
saiph-2.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: saiph
|
|
3
|
+
Version: 2.0.4
|
|
4
|
+
Summary: A projection package
|
|
5
|
+
Author-email: Octopize <help@octopize.io>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: <3.14,>=3.11
|
|
9
|
+
Requires-Dist: msgspec<0.20,>=0.19
|
|
10
|
+
Requires-Dist: numpy<2,>=1
|
|
11
|
+
Requires-Dist: pandas>=2.2.2
|
|
12
|
+
Requires-Dist: pydantic<3,>=2
|
|
13
|
+
Requires-Dist: scikit-learn<2,>=1.0
|
|
14
|
+
Requires-Dist: scipy<2,>=1.14
|
|
15
|
+
Requires-Dist: toolz<2,>=1
|
|
16
|
+
Provides-Extra: matplotlib
|
|
17
|
+
Requires-Dist: matplotlib<4,>=3.5.2; extra == 'matplotlib'
|
saiph-2.0.4/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Saiph
|
|
2
|
+
|
|
3
|
+
Saiph not only is the sixth-brightest star in the constellation of Orion (https://en.wikipedia.org/wiki/Saiph), but also a package enabling to project data.
|
|
4
|
+
|
|
5
|
+
Projection fitting is done through PCA, MCA or FAMD.
|
|
6
|
+
|
|
7
|
+
The main module imputes which one should be used depending on the given data, but each module can be used on his own.
|
|
8
|
+
|
|
9
|
+
The package provides a visualization module for correlation circles, contributions and explained variance.
|
|
10
|
+
|
|
11
|
+
See the documentation for more details and a tutorial.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install saiph
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv sync --extra matplotlib --group dev --group doc
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you want to install dev dependencies, make sure you have a rust compiler installed:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
29
|
+
just install
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation
|
|
33
|
+
|
|
34
|
+
To get the documentation, clone the repo then
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
just install docs docs-open
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
Saiph is under MIT license.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import csv
|
|
4
|
+
import os
|
|
5
|
+
import random
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
import typer
|
|
11
|
+
from faker import Faker
|
|
12
|
+
from tqdm import tqdm # type: ignore
|
|
13
|
+
|
|
14
|
+
fake = Faker("en_US")
|
|
15
|
+
CITIES = [
|
|
16
|
+
"Lyon",
|
|
17
|
+
"Nantes",
|
|
18
|
+
"Paris",
|
|
19
|
+
"Marseille",
|
|
20
|
+
"Cholet",
|
|
21
|
+
"Rochefourchat",
|
|
22
|
+
"Ornes",
|
|
23
|
+
"Senconac",
|
|
24
|
+
"Caunette-sur-Lauquet",
|
|
25
|
+
"Cherbourg",
|
|
26
|
+
]
|
|
27
|
+
CITIES_WEIGHTS = (20, 10, 50, 10, 4, 1, 1, 1, 1, 2)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def eprint(*args: Any, **kwargs: dict[str, Any]) -> None:
|
|
31
|
+
print(*args, file=sys.stderr, **kwargs) # noqa: T201 # type: ignore
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def human_size(size: int, units: list[str] = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB"]) -> str:
|
|
35
|
+
"""Return a human readable string representation of bytes."""
|
|
36
|
+
return (
|
|
37
|
+
str(size) + units[0]
|
|
38
|
+
if size < 1024 or len(units) == 1
|
|
39
|
+
else human_size(size >> 10, units[1:])
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_city() -> str:
|
|
44
|
+
return random.choices(CITIES, weights=CITIES_WEIGHTS)[0] # noqa: S311
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_row(dimension_count: int = 3) -> dict[str, Any]:
|
|
48
|
+
r = {
|
|
49
|
+
"latitude": fake.latitude(),
|
|
50
|
+
"longitude": fake.longitude(),
|
|
51
|
+
"city": get_city(),
|
|
52
|
+
}
|
|
53
|
+
r.update({f"city_{i}": get_city() for i in range(dimension_count - 3)})
|
|
54
|
+
|
|
55
|
+
return r
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def main(
|
|
59
|
+
outfile: Path,
|
|
60
|
+
row_count: int = 1000,
|
|
61
|
+
dimension_count: int = 3,
|
|
62
|
+
) -> int:
|
|
63
|
+
"""Generate CSV with fake data."""
|
|
64
|
+
eprint(f"generating {row_count} fake rows")
|
|
65
|
+
|
|
66
|
+
if dimension_count < 3:
|
|
67
|
+
raise ValueError(f"Expected dimension_count >= 3, got {dimension_count} instead")
|
|
68
|
+
|
|
69
|
+
header = list(get_row(dimension_count).keys())
|
|
70
|
+
with open(outfile, "w") as f:
|
|
71
|
+
writer = csv.DictWriter(f, fieldnames=header)
|
|
72
|
+
writer.writeheader()
|
|
73
|
+
|
|
74
|
+
for i in tqdm(range(row_count)):
|
|
75
|
+
writer.writerow(get_row(dimension_count))
|
|
76
|
+
|
|
77
|
+
if Path(outfile.name).exists():
|
|
78
|
+
size = os.path.getsize(outfile.name)
|
|
79
|
+
eprint(f"Wrote {human_size(size)} file")
|
|
80
|
+
|
|
81
|
+
return 0
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
typer.run(main)
|
saiph-2.0.4/docs/conf.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
#
|
|
3
|
+
# This file only contains a selection of the most common options. For a full
|
|
4
|
+
# list see the documentation:
|
|
5
|
+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
|
6
|
+
|
|
7
|
+
# -- Path setup --------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
# If extensions (or modules to document with autodoc) are in another directory,
|
|
10
|
+
# add these directories to sys.path here. If the directory is relative to the
|
|
11
|
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
12
|
+
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import List
|
|
16
|
+
|
|
17
|
+
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
|
18
|
+
|
|
19
|
+
# import saiph # noqa: E402
|
|
20
|
+
|
|
21
|
+
# -- Project information -----------------------------------------------------
|
|
22
|
+
|
|
23
|
+
project = "Saiph"
|
|
24
|
+
copyright = "2024, Octopize"
|
|
25
|
+
author = "Octopize"
|
|
26
|
+
|
|
27
|
+
# The full version, including alpha/beta/rc tags
|
|
28
|
+
release = "1.5.6"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# -- General configuration ---------------------------------------------------
|
|
32
|
+
|
|
33
|
+
# Add any Sphinx extension module names here, as strings. They can be
|
|
34
|
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
|
35
|
+
# ones.
|
|
36
|
+
extensions = [
|
|
37
|
+
"sphinx.ext.autodoc",
|
|
38
|
+
"sphinx.ext.napoleon",
|
|
39
|
+
"sphinx_gallery.gen_gallery",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
# Add any paths that contain templates here, relative to this directory.
|
|
43
|
+
templates_path = ["_templates"]
|
|
44
|
+
|
|
45
|
+
# List of patterns, relative to source directory, that match files and
|
|
46
|
+
# directories to ignore when looking for source files.
|
|
47
|
+
# This pattern also affects html_static_path and html_extra_path.
|
|
48
|
+
exclude_patterns: List[str] = ["requirements.txt"]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# -- Options for HTML output -------------------------------------------------
|
|
52
|
+
|
|
53
|
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
54
|
+
# a list of builtin themes.
|
|
55
|
+
#
|
|
56
|
+
html_theme = "sphinx_rtd_theme"
|
|
57
|
+
|
|
58
|
+
# Add any paths that contain custom static files (such as style sheets) here,
|
|
59
|
+
# relative to this directory. They are copied after the builtin static files,
|
|
60
|
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
61
|
+
html_static_path: List[str] = []
|
|
62
|
+
|
|
63
|
+
source_suffix = {
|
|
64
|
+
".rst": "restructuredtext",
|
|
65
|
+
".txt": "markdown",
|
|
66
|
+
".md": "markdown",
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
sphinx_gallery_conf = {
|
|
70
|
+
"examples_dirs": "source/example", # path to your example scripts
|
|
71
|
+
"gallery_dirs": "build/examples", # path to where to save gallery generated output
|
|
72
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.. Saiph documentation master file, created by
|
|
2
|
+
sphinx-quickstart on Fri Sep 24 09:52:44 2021.
|
|
3
|
+
|
|
4
|
+
Welcome to Saiph's documentation!
|
|
5
|
+
=================================
|
|
6
|
+
|
|
7
|
+
.. toctree::
|
|
8
|
+
:maxdepth: 2
|
|
9
|
+
:caption: Contents:
|
|
10
|
+
|
|
11
|
+
build/examples/plot_example
|
|
12
|
+
source/reference
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Indices and tables
|
|
16
|
+
==================
|
|
17
|
+
|
|
18
|
+
* :ref:`genindex`
|
|
19
|
+
* :ref:`modindex`
|
|
20
|
+
* :ref:`search`
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tutorial
|
|
3
|
+
=========================
|
|
4
|
+
|
|
5
|
+
This example shows how saiph works.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import pandas as pd
|
|
9
|
+
|
|
10
|
+
import saiph
|
|
11
|
+
from saiph.visualization import plot_circle
|
|
12
|
+
|
|
13
|
+
# %%
|
|
14
|
+
# Fit the model
|
|
15
|
+
# ------------------------
|
|
16
|
+
|
|
17
|
+
df = pd.read_csv("../../../tests/fixtures/iris.csv")
|
|
18
|
+
|
|
19
|
+
coord, model = saiph.fit_transform(df, nf=5)
|
|
20
|
+
print(coord.head())
|
|
21
|
+
# %%
|
|
22
|
+
# Project individuals
|
|
23
|
+
# ------------------------
|
|
24
|
+
#
|
|
25
|
+
saiph.visualization.plot_projections(model, df, (0, 1))
|
|
26
|
+
# %%
|
|
27
|
+
# Get statistics about the projection
|
|
28
|
+
# ------------------------
|
|
29
|
+
#
|
|
30
|
+
model = saiph.stats(model, df)
|
|
31
|
+
print(model.cos2)
|
|
32
|
+
|
|
33
|
+
# %%
|
|
34
|
+
# Correlation circle
|
|
35
|
+
# ------------------------
|
|
36
|
+
#
|
|
37
|
+
plot_circle(model=model)
|
|
38
|
+
|
|
39
|
+
# %%
|
|
40
|
+
# Variable contributions
|
|
41
|
+
# ------------------------
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
print(model.contributions)
|
|
45
|
+
# %%
|
|
46
|
+
# ------------------------
|
|
47
|
+
#
|
|
48
|
+
saiph.visualization.plot_var_contribution(
|
|
49
|
+
model.contributions["Dim. 1"].to_numpy(), model.contributions.index.to_numpy()
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# %%
|
|
54
|
+
# Explained variance
|
|
55
|
+
# ------------------------
|
|
56
|
+
#
|
|
57
|
+
print(model.explained_var)
|
|
58
|
+
|
|
59
|
+
# %%
|
|
60
|
+
# ------------------------
|
|
61
|
+
#
|
|
62
|
+
print(model.explained_var_ratio)
|
|
63
|
+
|
|
64
|
+
# %%
|
|
65
|
+
# ------------------------
|
|
66
|
+
#
|
|
67
|
+
saiph.visualization.plot_explained_var(model)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
API Reference
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
saiph
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
.. automodule:: saiph
|
|
8
|
+
:members:
|
|
9
|
+
|
|
10
|
+
saiph.models
|
|
11
|
+
------------
|
|
12
|
+
|
|
13
|
+
.. automodule:: saiph.models
|
|
14
|
+
:members:
|
|
15
|
+
:undoc-members:
|
|
16
|
+
:show-inheritance:
|
|
17
|
+
|
|
18
|
+
saiph.famd
|
|
19
|
+
----------
|
|
20
|
+
|
|
21
|
+
.. automodule:: saiph.reduction.famd
|
|
22
|
+
:members:
|
|
23
|
+
:undoc-members:
|
|
24
|
+
:show-inheritance:
|
|
25
|
+
|
|
26
|
+
saiph.mca
|
|
27
|
+
---------
|
|
28
|
+
|
|
29
|
+
.. automodule:: saiph.reduction.mca
|
|
30
|
+
:members:
|
|
31
|
+
:undoc-members:
|
|
32
|
+
:show-inheritance:
|
|
33
|
+
|
|
34
|
+
saiph.pca
|
|
35
|
+
---------
|
|
36
|
+
|
|
37
|
+
.. automodule:: saiph.reduction.pca
|
|
38
|
+
:members:
|
|
39
|
+
:undoc-members:
|
|
40
|
+
:show-inheritance:
|
|
41
|
+
|
|
42
|
+
saiph.svd
|
|
43
|
+
---------
|
|
44
|
+
|
|
45
|
+
.. automodule:: saiph.reduction.utils.svd
|
|
46
|
+
:members:
|
|
47
|
+
:undoc-members:
|
|
48
|
+
:show-inheritance:
|
|
49
|
+
|
|
50
|
+
saiph.visualization
|
|
51
|
+
-------------------
|
|
52
|
+
|
|
53
|
+
.. automodule:: saiph.visualization
|
|
54
|
+
:members:
|
|
55
|
+
:undoc-members:
|
|
56
|
+
:show-inheritance:
|