diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-11 01:19:44 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-11 01:19:44 +0000 |
commit | c3e242f2704013b733751a62149d2640a26a8e26 (patch) | |
tree | e6b8356d8ca3017aa6641581c1d5ee712ccccbb7 | |
parent | 8b6f897eb5dc0674b1e4a44ba6921066f836db76 (diff) |
automatic import of python-gower
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-gower.spec | 326 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 328 insertions, 0 deletions
@@ -0,0 +1 @@ +/gower-0.1.2.tar.gz diff --git a/python-gower.spec b/python-gower.spec new file mode 100644 index 0000000..d5659b9 --- /dev/null +++ b/python-gower.spec @@ -0,0 +1,326 @@ +%global _empty_manifest_terminate_build 0 +Name: python-gower +Version: 0.1.2 +Release: 1 +Summary: Python implementation of Gowers distance, pairwise between records in two data sets +License: MIT +URL: https://github.com/wwwjk366/gower +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/7c/b8/f02ffa72009105e981b21fe957895107d1b3c81dece43167d28d8acfdfb0/gower-0.1.2.tar.gz +BuildArch: noarch + +Requires: python3-numpy +Requires: python3-scipy + +%description +<!-- badges: start --> +[](https://travis-ci.com/wwwjk366/gower) +[](https://pypi.org/project/gower/) +[](https://pepy.tech/project/gower/month) +<!-- badges: end --> + +# Introduction + +Gower's distance calculation in Python. Gower Distance is a distance measure that can be used to calculate distance between two entity whose attribute has a mixed of categorical and numerical values. [Gower (1971) A general coefficient of similarity and some of its properties. Biometrics 27 857–874.](https://www.jstor.org/stable/2528823?seq=1) + +More details and examples can be found on my personal website here:(https://www.thinkdatascience.com/post/2019-12-16-introducing-python-package-gower/) + +Core functions are wrote by [Marcelo Beckmann](https://sourceforge.net/projects/gower-distance-4python/files/). + +# Examples + +## Installation + +``` +pip install gower +``` + +## Generate some data + +```python +import numpy as np +import pandas as pd +import gower + +Xd=pd.DataFrame({'age':[21,21,19, 30,21,21,19,30,None], +'gender':['M','M','N','M','F','F','F','F',None], +'civil_status':['MARRIED','SINGLE','SINGLE','SINGLE','MARRIED','SINGLE','WIDOW','DIVORCED',None], +'salary':[3000.0,1200.0 ,32000.0,1800.0 ,2900.0 ,1100.0 ,10000.0,1500.0,None], +'has_children':[1,0,1,1,1,0,0,1,None], +'available_credit':[2200,100,22000,1100,2000,100,6000,2200,None]}) +Yd = Xd.iloc[1:3,:] +X = np.asarray(Xd) +Y = np.asarray(Yd) + +``` + +## Find the distance matrix + +```python +gower.gower_matrix(X) +``` + + + + + array([[0. , 0.3590238 , 0.6707398 , 0.31787416, 0.16872811, + 0.52622986, 0.59697855, 0.47778758, nan], + [0.3590238 , 0. , 0.6964303 , 0.3138769 , 0.523629 , + 0.16720603, 0.45600235, 0.6539635 , nan], + [0.6707398 , 0.6964303 , 0. , 0.6552807 , 0.6728013 , + 0.6969697 , 0.740428 , 0.8151941 , nan], + [0.31787416, 0.3138769 , 0.6552807 , 0. , 0.4824794 , + 0.48108295, 0.74818605, 0.34332284, nan], + [0.16872811, 0.523629 , 0.6728013 , 0.4824794 , 0. , + 0.35750175, 0.43237334, 0.3121036 , nan], + [0.52622986, 0.16720603, 0.6969697 , 0.48108295, 0.35750175, + 0. , 0.2898751 , 0.4878362 , nan], + [0.59697855, 0.45600235, 0.740428 , 0.74818605, 0.43237334, + 0.2898751 , 0. , 0.57476616, nan], + [0.47778758, 0.6539635 , 0.8151941 , 0.34332284, 0.3121036 , + 0.4878362 , 0.57476616, 0. , nan], + [ nan, nan, nan, nan, nan, + nan, nan, nan, nan]], dtype=float32) + + +## Find Top n results + +```python +gower.gower_topn(Xd.iloc[0:2,:], Xd.iloc[:,], n = 5) +``` + + + + + {'index': array([4, 3, 1, 7, 5]), + 'values': array([0.16872811, 0.31787416, 0.3590238 , 0.47778758, 0.52622986], + dtype=float32)} + + + + +%package -n python3-gower +Summary: Python implementation of Gowers distance, pairwise between records in two data sets +Provides: python-gower +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-gower +<!-- badges: start --> +[](https://travis-ci.com/wwwjk366/gower) +[](https://pypi.org/project/gower/) +[](https://pepy.tech/project/gower/month) +<!-- badges: end --> + +# Introduction + +Gower's distance calculation in Python. Gower Distance is a distance measure that can be used to calculate distance between two entity whose attribute has a mixed of categorical and numerical values. [Gower (1971) A general coefficient of similarity and some of its properties. Biometrics 27 857–874.](https://www.jstor.org/stable/2528823?seq=1) + +More details and examples can be found on my personal website here:(https://www.thinkdatascience.com/post/2019-12-16-introducing-python-package-gower/) + +Core functions are wrote by [Marcelo Beckmann](https://sourceforge.net/projects/gower-distance-4python/files/). + +# Examples + +## Installation + +``` +pip install gower +``` + +## Generate some data + +```python +import numpy as np +import pandas as pd +import gower + +Xd=pd.DataFrame({'age':[21,21,19, 30,21,21,19,30,None], +'gender':['M','M','N','M','F','F','F','F',None], +'civil_status':['MARRIED','SINGLE','SINGLE','SINGLE','MARRIED','SINGLE','WIDOW','DIVORCED',None], +'salary':[3000.0,1200.0 ,32000.0,1800.0 ,2900.0 ,1100.0 ,10000.0,1500.0,None], +'has_children':[1,0,1,1,1,0,0,1,None], +'available_credit':[2200,100,22000,1100,2000,100,6000,2200,None]}) +Yd = Xd.iloc[1:3,:] +X = np.asarray(Xd) +Y = np.asarray(Yd) + +``` + +## Find the distance matrix + +```python +gower.gower_matrix(X) +``` + + + + + array([[0. , 0.3590238 , 0.6707398 , 0.31787416, 0.16872811, + 0.52622986, 0.59697855, 0.47778758, nan], + [0.3590238 , 0. , 0.6964303 , 0.3138769 , 0.523629 , + 0.16720603, 0.45600235, 0.6539635 , nan], + [0.6707398 , 0.6964303 , 0. , 0.6552807 , 0.6728013 , + 0.6969697 , 0.740428 , 0.8151941 , nan], + [0.31787416, 0.3138769 , 0.6552807 , 0. , 0.4824794 , + 0.48108295, 0.74818605, 0.34332284, nan], + [0.16872811, 0.523629 , 0.6728013 , 0.4824794 , 0. , + 0.35750175, 0.43237334, 0.3121036 , nan], + [0.52622986, 0.16720603, 0.6969697 , 0.48108295, 0.35750175, + 0. , 0.2898751 , 0.4878362 , nan], + [0.59697855, 0.45600235, 0.740428 , 0.74818605, 0.43237334, + 0.2898751 , 0. , 0.57476616, nan], + [0.47778758, 0.6539635 , 0.8151941 , 0.34332284, 0.3121036 , + 0.4878362 , 0.57476616, 0. , nan], + [ nan, nan, nan, nan, nan, + nan, nan, nan, nan]], dtype=float32) + + +## Find Top n results + +```python +gower.gower_topn(Xd.iloc[0:2,:], Xd.iloc[:,], n = 5) +``` + + + + + {'index': array([4, 3, 1, 7, 5]), + 'values': array([0.16872811, 0.31787416, 0.3590238 , 0.47778758, 0.52622986], + dtype=float32)} + + + + +%package help +Summary: Development documents and examples for gower +Provides: python3-gower-doc +%description help +<!-- badges: start --> +[](https://travis-ci.com/wwwjk366/gower) +[](https://pypi.org/project/gower/) +[](https://pepy.tech/project/gower/month) +<!-- badges: end --> + +# Introduction + +Gower's distance calculation in Python. Gower Distance is a distance measure that can be used to calculate distance between two entity whose attribute has a mixed of categorical and numerical values. [Gower (1971) A general coefficient of similarity and some of its properties. Biometrics 27 857–874.](https://www.jstor.org/stable/2528823?seq=1) + +More details and examples can be found on my personal website here:(https://www.thinkdatascience.com/post/2019-12-16-introducing-python-package-gower/) + +Core functions are wrote by [Marcelo Beckmann](https://sourceforge.net/projects/gower-distance-4python/files/). + +# Examples + +## Installation + +``` +pip install gower +``` + +## Generate some data + +```python +import numpy as np +import pandas as pd +import gower + +Xd=pd.DataFrame({'age':[21,21,19, 30,21,21,19,30,None], +'gender':['M','M','N','M','F','F','F','F',None], +'civil_status':['MARRIED','SINGLE','SINGLE','SINGLE','MARRIED','SINGLE','WIDOW','DIVORCED',None], +'salary':[3000.0,1200.0 ,32000.0,1800.0 ,2900.0 ,1100.0 ,10000.0,1500.0,None], +'has_children':[1,0,1,1,1,0,0,1,None], +'available_credit':[2200,100,22000,1100,2000,100,6000,2200,None]}) +Yd = Xd.iloc[1:3,:] +X = np.asarray(Xd) +Y = np.asarray(Yd) + +``` + +## Find the distance matrix + +```python +gower.gower_matrix(X) +``` + + + + + array([[0. , 0.3590238 , 0.6707398 , 0.31787416, 0.16872811, + 0.52622986, 0.59697855, 0.47778758, nan], + [0.3590238 , 0. , 0.6964303 , 0.3138769 , 0.523629 , + 0.16720603, 0.45600235, 0.6539635 , nan], + [0.6707398 , 0.6964303 , 0. , 0.6552807 , 0.6728013 , + 0.6969697 , 0.740428 , 0.8151941 , nan], + [0.31787416, 0.3138769 , 0.6552807 , 0. , 0.4824794 , + 0.48108295, 0.74818605, 0.34332284, nan], + [0.16872811, 0.523629 , 0.6728013 , 0.4824794 , 0. , + 0.35750175, 0.43237334, 0.3121036 , nan], + [0.52622986, 0.16720603, 0.6969697 , 0.48108295, 0.35750175, + 0. , 0.2898751 , 0.4878362 , nan], + [0.59697855, 0.45600235, 0.740428 , 0.74818605, 0.43237334, + 0.2898751 , 0. , 0.57476616, nan], + [0.47778758, 0.6539635 , 0.8151941 , 0.34332284, 0.3121036 , + 0.4878362 , 0.57476616, 0. , nan], + [ nan, nan, nan, nan, nan, + nan, nan, nan, nan]], dtype=float32) + + +## Find Top n results + +```python +gower.gower_topn(Xd.iloc[0:2,:], Xd.iloc[:,], n = 5) +``` + + + + + {'index': array([4, 3, 1, 7, 5]), + 'values': array([0.16872811, 0.31787416, 0.3590238 , 0.47778758, 0.52622986], + dtype=float32)} + + + + +%prep +%autosetup -n gower-0.1.2 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-gower -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.2-1 +- Package Spec generated @@ -0,0 +1 @@ +1d33bdd101ad7196dbadad0fc09de08c gower-0.1.2.tar.gz |