robust-mixed-dist 0.1.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.
- robust_mixed_dist-0.1.0/LICENSE +19 -0
- robust_mixed_dist-0.1.0/PKG-INFO +27 -0
- robust_mixed_dist-0.1.0/README.md +4 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist/__init__.py +0 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist/binary.py +110 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist/mixed.py +776 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist/multiclass.py +57 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist/quantitative.py +666 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist.egg-info/PKG-INFO +27 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist.egg-info/SOURCES.txt +12 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist.egg-info/dependency_links.txt +1 -0
- robust_mixed_dist-0.1.0/robust_mixed_dist.egg-info/top_level.txt +1 -0
- robust_mixed_dist-0.1.0/setup.cfg +4 -0
- robust_mixed_dist-0.1.0/setup.py +23 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2018 The Python Packaging Authority
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: robust-mixed-dist
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: For more information, check out the official documentation of `robust_mixed_dist` at: https://fabioscielzoortiz.github.io/robust_mixed_dist-docu/intro.html
|
|
5
|
+
Home-page: https://github.com/FabioScielzoOrtiz/robust_mixed_dist-package
|
|
6
|
+
Author: Fabio Scielzo Ortiz
|
|
7
|
+
Author-email: fabio.scielzoortiz@gmail.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
# robust_mixed_dist
|
|
25
|
+
|
|
26
|
+
For more information, check out the official documentation of `robust_mixed_dist` at: https://fabioscielzoortiz.github.io/robust_mixed_dist-docu/intro.html
|
|
27
|
+
|
|
File without changes
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import polars as pl
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from scipy.spatial import distance
|
|
4
|
+
from scipy.spatial.distance import pdist, squareform
|
|
5
|
+
|
|
6
|
+
################################################################################
|
|
7
|
+
|
|
8
|
+
def sokal_dist_matrix(X):
|
|
9
|
+
"""
|
|
10
|
+
Calculates the Sokal distance matrix for a data matrix `X` using SciPy.
|
|
11
|
+
|
|
12
|
+
Parameters (inputs)
|
|
13
|
+
----------
|
|
14
|
+
X: a pandas/polars DataFrame or a NumPy array. It represents a data matrix.
|
|
15
|
+
|
|
16
|
+
Returns (outputs)
|
|
17
|
+
-------
|
|
18
|
+
M: the Sokal distance matrix between the rows of X.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
if isinstance(X, pl.DataFrame):
|
|
22
|
+
X = X.to_numpy()
|
|
23
|
+
if isinstance(X, pd.DataFrame):
|
|
24
|
+
X = X.to_numpy()
|
|
25
|
+
|
|
26
|
+
# Compute the pairwise distances using pdist and convert to a square form.
|
|
27
|
+
M = squareform(pdist(X, metric='sokalmichener'))
|
|
28
|
+
|
|
29
|
+
return M
|
|
30
|
+
|
|
31
|
+
################################################################################
|
|
32
|
+
|
|
33
|
+
def sokal_dist(xi, xr) :
|
|
34
|
+
"""
|
|
35
|
+
Calculates the Sokal distance between a pair of vectors.
|
|
36
|
+
|
|
37
|
+
Parameters (inputs)
|
|
38
|
+
----------
|
|
39
|
+
xi, xr: a pair of quantitative vectors. They represent a couple of statistical observations.
|
|
40
|
+
|
|
41
|
+
Returns (outputs)
|
|
42
|
+
-------
|
|
43
|
+
The Sokal distance between the observations `xi` and `xr`.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
if isinstance(xi, (pl.DataFrame, pd.DataFrame)) :
|
|
47
|
+
xi = xi.to_numpy().flatten()
|
|
48
|
+
elif isinstance(xi, (pd.Series, pl.Series)) :
|
|
49
|
+
xi = xi.to_numpy()
|
|
50
|
+
if isinstance(xr, (pl.DataFrame, pd.DataFrame)) :
|
|
51
|
+
xr = xr.to_numpy().flatten()
|
|
52
|
+
elif isinstance(xr, (pd.Series, pl.Series)) :
|
|
53
|
+
xr = xr.to_numpy()
|
|
54
|
+
|
|
55
|
+
return distance.sokalmichener(xi, xr)
|
|
56
|
+
|
|
57
|
+
################################################################################
|
|
58
|
+
|
|
59
|
+
def jaccard_dist_matrix(X):
|
|
60
|
+
"""
|
|
61
|
+
Calculates the Jaccard distance matrix for a data matrix `X` using SciPy.
|
|
62
|
+
|
|
63
|
+
Parameters (inputs)
|
|
64
|
+
----------
|
|
65
|
+
X: a pandas/polars DataFrame or a NumPy array. It represents a data matrix.
|
|
66
|
+
|
|
67
|
+
Returns (outputs)
|
|
68
|
+
-------
|
|
69
|
+
M: the Jaccard distance matrix between the rows of X.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
if isinstance(X, pl.DataFrame):
|
|
73
|
+
X = X.to_numpy()
|
|
74
|
+
if isinstance(X, pd.DataFrame):
|
|
75
|
+
X = X.to_numpy()
|
|
76
|
+
|
|
77
|
+
# Compute the pairwise distances using pdist and convert to a square form.
|
|
78
|
+
M = squareform(pdist(X, metric='jaccard'))
|
|
79
|
+
|
|
80
|
+
return M
|
|
81
|
+
|
|
82
|
+
################################################################################
|
|
83
|
+
|
|
84
|
+
def jaccard_dist(xi, xr) :
|
|
85
|
+
"""
|
|
86
|
+
Calculates the Jaccard distance between a pair of vectors.
|
|
87
|
+
|
|
88
|
+
Parameters (inputs)
|
|
89
|
+
----------
|
|
90
|
+
xi, xr: a pair of quantitative vectors. They represent a couple of statistical observations.
|
|
91
|
+
|
|
92
|
+
Returns (outputs)
|
|
93
|
+
-------
|
|
94
|
+
The Jaccard distance between the observations `xi` and `xr`.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
if isinstance(xi, (pl.DataFrame, pd.DataFrame)) :
|
|
98
|
+
xi = xi.to_numpy().flatten()
|
|
99
|
+
elif isinstance(xi, (pd.Series, pl.Series)) :
|
|
100
|
+
xi = xi.to_numpy()
|
|
101
|
+
if isinstance(xr, (pl.DataFrame, pd.DataFrame)) :
|
|
102
|
+
xr = xr.to_numpy().flatten()
|
|
103
|
+
elif isinstance(xr, (pd.Series, pl.Series)) :
|
|
104
|
+
xr = xr.to_numpy()
|
|
105
|
+
|
|
106
|
+
return distance.jaccard(xi, xr)
|
|
107
|
+
|
|
108
|
+
################################################################################
|
|
109
|
+
|
|
110
|
+
|