robpy 0.0.0__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.

Potentially problematic release.


This version of robpy might be problematic. Click here for more details.

Files changed (56) hide show
  1. robpy-0.0.0/PKG-INFO +31 -0
  2. robpy-0.0.0/README.rst +11 -0
  3. robpy-0.0.0/pyproject.toml +68 -0
  4. robpy-0.0.0/robpy/__init__.py +0 -0
  5. robpy-0.0.0/robpy/covariance/__init__.py +6 -0
  6. robpy-0.0.0/robpy/covariance/base.py +82 -0
  7. robpy-0.0.0/robpy/covariance/cellmcd.py +621 -0
  8. robpy-0.0.0/robpy/covariance/initial_ddcw.py +133 -0
  9. robpy-0.0.0/robpy/covariance/kendall.py +21 -0
  10. robpy-0.0.0/robpy/covariance/mcd.py +470 -0
  11. robpy-0.0.0/robpy/covariance/ogk.py +95 -0
  12. robpy-0.0.0/robpy/covariance/utils/alter_covariance.py +31 -0
  13. robpy-0.0.0/robpy/covariance/utils/cellmcd_utils.py +38 -0
  14. robpy-0.0.0/robpy/covariance/utils/cellmcd_visualization_utils.py +96 -0
  15. robpy-0.0.0/robpy/covariance/wrapping.py +72 -0
  16. robpy-0.0.0/robpy/datasets/__init__.py +4 -0
  17. robpy-0.0.0/robpy/datasets/base.py +389 -0
  18. robpy-0.0.0/robpy/datasets/data/animals.csv +66 -0
  19. robpy-0.0.0/robpy/datasets/data/glass.csv +181 -0
  20. robpy-0.0.0/robpy/datasets/data/stars.csv +48 -0
  21. robpy-0.0.0/robpy/datasets/data/telephone.csv +25 -0
  22. robpy-0.0.0/robpy/datasets/data/topgear.csv +298 -0
  23. robpy-0.0.0/robpy/datasets/descr/animals.rst +26 -0
  24. robpy-0.0.0/robpy/datasets/descr/glass.rst +20 -0
  25. robpy-0.0.0/robpy/datasets/descr/stars.rst +28 -0
  26. robpy-0.0.0/robpy/datasets/descr/telephone.rst +23 -0
  27. robpy-0.0.0/robpy/datasets/descr/topgear.rst +51 -0
  28. robpy-0.0.0/robpy/outliers/__init__.py +4 -0
  29. robpy-0.0.0/robpy/outliers/ddc.py +307 -0
  30. robpy-0.0.0/robpy/pca/__init__.py +3 -0
  31. robpy-0.0.0/robpy/pca/base.py +97 -0
  32. robpy-0.0.0/robpy/pca/robpca.py +89 -0
  33. robpy-0.0.0/robpy/pca/spca.py +48 -0
  34. robpy-0.0.0/robpy/preprocessing/__init__.py +3 -0
  35. robpy-0.0.0/robpy/preprocessing/data_cleaner.py +214 -0
  36. robpy-0.0.0/robpy/preprocessing/scaling.py +57 -0
  37. robpy-0.0.0/robpy/preprocessing/transfo.py +591 -0
  38. robpy-0.0.0/robpy/preprocessing/utils.py +63 -0
  39. robpy-0.0.0/robpy/regression/__init__.py +3 -0
  40. robpy-0.0.0/robpy/regression/base.py +116 -0
  41. robpy-0.0.0/robpy/regression/lts.py +408 -0
  42. robpy-0.0.0/robpy/regression/mm_estimator.py +57 -0
  43. robpy-0.0.0/robpy/regression/s_estimator.py +188 -0
  44. robpy-0.0.0/robpy/univariate/__init__.py +10 -0
  45. robpy-0.0.0/robpy/univariate/adjusted_boxplot.py +103 -0
  46. robpy-0.0.0/robpy/univariate/base.py +53 -0
  47. robpy-0.0.0/robpy/univariate/mcd.py +84 -0
  48. robpy-0.0.0/robpy/univariate/onestep_m.py +143 -0
  49. robpy-0.0.0/robpy/univariate/qn.py +112 -0
  50. robpy-0.0.0/robpy/univariate/tau.py +63 -0
  51. robpy-0.0.0/robpy/utils/distance.py +24 -0
  52. robpy-0.0.0/robpy/utils/general.py +31 -0
  53. robpy-0.0.0/robpy/utils/logging.py +22 -0
  54. robpy-0.0.0/robpy/utils/median.py +62 -0
  55. robpy-0.0.0/robpy/utils/outlyingness.py +61 -0
  56. robpy-0.0.0/robpy/utils/rho.py +35 -0
robpy-0.0.0/PKG-INFO ADDED
@@ -0,0 +1,31 @@
1
+ Metadata-Version: 2.1
2
+ Name: robpy
3
+ Version: 0.0.0
4
+ Summary:
5
+ Author: Thomas Servotte
6
+ Author-email: servottethomas@gmail.com
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Dist: matplotlib (>=3.8.2,<4.0.0)
13
+ Requires-Dist: scikit-learn (>=1.3)
14
+ Requires-Dist: scipy (>=1.11.4,<2.0.0)
15
+ Requires-Dist: seaborn (>=0.13.2,<0.14.0)
16
+ Requires-Dist: statsmodels (>=0.14.1,<0.15.0)
17
+ Requires-Dist: tqdm (>=4.66.1,<5.0.0)
18
+ Description-Content-Type: text/x-rst
19
+
20
+ Robpy
21
+ =========
22
+
23
+ **Robpy** is a Python module for robust statistical methods built on top of scikit-learn and
24
+ SciPy.
25
+
26
+ The project was started in 2023 by Tim Verdonck, Jakob Raymaekers, Thomas Servotte, Sarah Leyder & Thomas Decorte at the University of Antwerp and imec IDLab.
27
+ The project is currently maintained by a the same team and distributed under MIT license.
28
+
29
+
30
+
31
+
robpy-0.0.0/README.rst ADDED
@@ -0,0 +1,11 @@
1
+ Robpy
2
+ =========
3
+
4
+ **Robpy** is a Python module for robust statistical methods built on top of scikit-learn and
5
+ SciPy.
6
+
7
+ The project was started in 2023 by Tim Verdonck, Jakob Raymaekers, Thomas Servotte, Sarah Leyder & Thomas Decorte at the University of Antwerp and imec IDLab.
8
+ The project is currently maintained by a the same team and distributed under MIT license.
9
+
10
+
11
+
@@ -0,0 +1,68 @@
1
+ [tool.poetry]
2
+ name = "robpy"
3
+ version = "0.0.0" # versioning is done by poetry-dynamic-versioning
4
+ description = ""
5
+ authors = ["Thomas Servotte <servottethomas@gmail.com>", "Sarah Leyder <sarah.leyder@uantwerpen.be>"]
6
+ readme = "README.rst"
7
+
8
+ [tool.poetry-dynamic-versioning]
9
+ enable = true
10
+ style = "pep440" # Default is pep440, can also use "semver" or others
11
+ vcs = "git"
12
+ source = "tag" # use git tags
13
+
14
+ [tool.black]
15
+ line-length = 100
16
+ exclude = '''
17
+ (
18
+ /(
19
+ | \.git
20
+ | \.venv
21
+ )/
22
+ | .ipynb
23
+ )
24
+ '''
25
+
26
+ [tool.flake8]
27
+ extend-ignore = "E203"
28
+ exclude = [
29
+ ".git",
30
+ "__pycache__",
31
+ ".venv",
32
+ "conf.py"
33
+ ]
34
+ per-file-ignores = [
35
+ '__init__.py:F401',
36
+ ]
37
+ max-complexity = 10
38
+ max-line-length = 100
39
+
40
+ [tool.poetry.dependencies]
41
+ python = "^3.10"
42
+ scikit-learn = ">=1.3"
43
+ matplotlib = "^3.8.2"
44
+ scipy = "^1.11.4"
45
+ tqdm = "^4.66.1"
46
+ statsmodels = "^0.14.1"
47
+ seaborn = "^0.13.2"
48
+
49
+ [tool.poetry.group.dev.dependencies]
50
+ pytest = ">=7.4"
51
+ black = "^23.11.0"
52
+ flake8 = "^6.1.0"
53
+ jupyter = "^1.0.0"
54
+ flake8-pyproject = "^1.2.3"
55
+ nbdime = "^4.0.1"
56
+ ipympl = "^0.9.3"
57
+ ipykernel = "^6.29.4"
58
+ sphinx = "^7.4.7"
59
+ sphinx-rtd-theme = "^2.0.0"
60
+ nbsphinx = "^0.9.5"
61
+ poetry-dynamic-versioning = {extras = ["plugin"], version = "^1.4.1"}
62
+
63
+
64
+
65
+
66
+ [build-system]
67
+ requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
68
+ build-backend = "poetry_dynamic_versioning.backend"
File without changes
@@ -0,0 +1,6 @@
1
+ from robpy.covariance.base import RobustCovarianceEstimator
2
+ from robpy.covariance.mcd import FastMCDEstimator
3
+ from robpy.covariance.wrapping import WrappingCovarianceEstimator
4
+ from robpy.covariance.ogk import OGKEstimator
5
+ from robpy.covariance.kendall import KendallTauEstimator
6
+ from robpy.covariance.cellmcd import CellMCDEstimator
@@ -0,0 +1,82 @@
1
+ from __future__ import annotations
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ import pandas as pd
5
+
6
+ from scipy.stats import chi2
7
+ from scipy.linalg import pinvh
8
+ from sklearn.covariance import EmpiricalCovariance
9
+ from sklearn.exceptions import NotFittedError
10
+ from robpy.utils.distance import mahalanobis_distance
11
+
12
+
13
+ class RobustCovarianceEstimator(EmpiricalCovariance):
14
+ def __init__(self, *, store_precision=True, assume_centered=False, nans_allowed=False):
15
+ super().__init__(
16
+ store_precision=store_precision,
17
+ assume_centered=assume_centered,
18
+ )
19
+ self.nans_allowed = nans_allowed
20
+
21
+ def fit(self, X: np.ndarray | pd.DataFrame) -> RobustCovarianceEstimator:
22
+ """Fit the covariance estimator."""
23
+ if isinstance(X, pd.DataFrame):
24
+ X = X.values
25
+ if self.nans_allowed:
26
+ self.n_features_in_ = X.shape[1]
27
+ else:
28
+ X = self._validate_data(X) # this sets n_features_in_ also
29
+
30
+ if self.assume_centered:
31
+ self.location_ = np.zeros(X.shape[1])
32
+ else:
33
+ self.location_ = X.mean(0)
34
+ covariance = self.calculate_covariance(X)
35
+ self._set_covariance(covariance)
36
+ if self.store_precision:
37
+ self.precision_ = pinvh(covariance)
38
+ self.default_covariance_ = np.cov(X, rowvar=False)
39
+ self._robust_distances = mahalanobis_distance(
40
+ X, location=self.location_, covariance=self.covariance_
41
+ )
42
+ self._mahalanobis_distances = mahalanobis_distance(
43
+ X, location=self.location_, covariance=self.default_covariance_
44
+ )
45
+
46
+ return self
47
+
48
+ def calculate_covariance(self, X) -> np.ndarray:
49
+ raise NotImplementedError
50
+
51
+ @property
52
+ def covariance(self) -> np.ndarray:
53
+ if not hasattr(self, "covariance_") or self.covariance_ is None:
54
+ raise NotFittedError()
55
+ return self.covariance_
56
+
57
+ @property
58
+ def correlation(self) -> np.ndarray:
59
+ if not hasattr(self, "correlation_"):
60
+ raise AttributeError("This estimator does not calculate correlation.")
61
+ return self.correlation_
62
+
63
+ def distance_distance_plot(
64
+ self, chi2_percentile: float = 0.975, figsize: tuple[int, int] = (4, 4)
65
+ ):
66
+ if not hasattr(self, "covariance_"):
67
+ raise NotFittedError()
68
+
69
+ fig, ax = plt.subplots(1, 1, figsize=figsize)
70
+
71
+ threshold = np.sqrt(chi2.ppf(chi2_percentile, self.n_features_in_))
72
+
73
+ ax.scatter(x=self._mahalanobis_distances, y=self._robust_distances)
74
+
75
+ ax.axhline(threshold, color="grey", linestyle="--")
76
+ ax.axvline(threshold, color="grey", linestyle="--")
77
+ ax.axline((0, 0), slope=1, color="grey", linestyle="-.")
78
+
79
+ ax.set_xlabel("Mahalanobis distance (default covariance)")
80
+ ax.set_ylabel("Robust distance")
81
+
82
+ return fig