bogliosimone / similaripy Goto Github PK
View Code? Open in Web Editor NEWFast Python KNN-Similarity algorithms for Collaborative Filtering models in Recommender System and others.
License: MIT License
Fast Python KNN-Similarity algorithms for Collaborative Filtering models in Recommender System and others.
License: MIT License
Hi Simone,
This is a great library and would be very helpful in one of our projects. The ask is can we incoporate weighted Jaccard Similairity in the library?
Or is there in general any library you guys might know off which we can utilise to find weighted jaccard similairity of close to 3lakh rows?
Thanks in advance.
Hello, thank you for making this package.
I get following logs, when trying to install similaripy with pip on Windows. Can you help me?
pip install similaripy
Collecting similaripy
Using cached https://files.pythonhosted.org/packages/9a/3a/44821be2e597c49b9bc5bd066df3729893af54c6209d7b05cafe3d39e448/similaripy-0.1.1.tar.gz
Requirement already satisfied: scipy>=1.0.0 in c:\users\gaha\anaconda3\lib\site-packages (from similaripy) (1.3.2)
Requirement already satisfied: numpy>=1.14.0 in c:\users\gaha\anaconda3\lib\site-packages (from similaripy) (1.17.4)
Requirement already satisfied: tqdm>=4.19.6 in c:\users\gaha\anaconda3\lib\site-packages (from similaripy) (4.40.2)
Building wheels for collected packages: similaripy
Building wheel for similaripy (setup.py) ... | WARNING: Subprocess output does not appear to be encoded as cp1250
error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\gaha\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gaha\\AppData\\Local\\Temp\\pip-install-midhwich\\similaripy\\setup.py'"'"'; __file__='"'"'C:\\Users\\gaha\\AppData\\Local\\Temp\\pip-install-midhwich\\similaripy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\gaha\AppData\Local\Temp\pip-wheel-_z119i4r' --python-tag cp37
cwd: C:\Users\gaha\AppData\Local\Temp\pip-install-midhwich\similaripy\
Complete output (38 lines):
C:\Users\gaha\Anaconda3\lib\site-packages\setuptools\dist.py:476: UserWarning: Normalizing '0.1.01' to '0.1.1'
normalized_version,
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\similaripy
copying similaripy\normalization.py -> build\lib.win-amd64-3.7\similaripy
copying similaripy\similarity.py -> build\lib.win-amd64-3.7\similaripy
copying similaripy\utility.py -> build\lib.win-amd64-3.7\similaripy
copying similaripy\__init__.py -> build\lib.win-amd64-3.7\similaripy
running egg_info
writing similaripy.egg-info\PKG-INFO
writing dependency_links to similaripy.egg-info\dependency_links.txt
writing requirements to similaripy.egg-info\requires.txt
writing top-level names to similaripy.egg-info\top_level.txt
reading manifest file 'similaripy.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'similaripy.egg-info\SOURCES.txt'
creating build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\__init__.py -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\coo_to_csr.h -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\normalization.cpp -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\normalization.pyx -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\s_plus.cpp -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\s_plus.h -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\s_plus.pyx -> build\lib.win-amd64-3.7\similaripy\cython_code
running build_ext
building 'similaripy.cython_code.s_plus' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\similaripy
creating build\temp.win-amd64-3.7\Release\similaripy\cython_code
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Isimilaripy\cython_code -IC:\Users\gaha\Anaconda3\include -IC:\Users\gaha\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include" /EHsc /Tpsimilaripy\cython_code\s_plus.cpp /Fobuild\temp.win-amd64-3.7\Release\similaripy\cython_code\s_plus.obj /O2 /openmp
s_plus.cpp
C:\Users\gaha\Anaconda3\include\pyconfig.h(59): fatal error C1083: Nie moľna otworzy† pliku do\x88Ącz: 'io.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for similaripy
Running setup.py clean for similaripy
Failed to build similaripy
Installing collected packages: similaripy
Running setup.py install for similaripy ... \ WARNING: Subprocess output does not appear to be encoded as cp1250
error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\gaha\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gaha\\AppData\\Local\\Temp\\pip-install-midhwich\\similaripy\\setup.py'"'"'; __file__='"'"'C:\\Users\\gaha\\AppData\\Local\\Temp\\pip-install-midhwich\\similaripy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\gaha\AppData\Local\Temp\pip-record-gdm22cde\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\gaha\AppData\Local\Temp\pip-install-midhwich\similaripy\
Complete output (38 lines):
C:\Users\gaha\Anaconda3\lib\site-packages\setuptools\dist.py:476: UserWarning: Normalizing '0.1.01' to '0.1.1'
normalized_version,
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\similaripy
copying similaripy\normalization.py -> build\lib.win-amd64-3.7\similaripy
copying similaripy\similarity.py -> build\lib.win-amd64-3.7\similaripy
copying similaripy\utility.py -> build\lib.win-amd64-3.7\similaripy
copying similaripy\__init__.py -> build\lib.win-amd64-3.7\similaripy
running egg_info
writing similaripy.egg-info\PKG-INFO
writing dependency_links to similaripy.egg-info\dependency_links.txt
writing requirements to similaripy.egg-info\requires.txt
writing top-level names to similaripy.egg-info\top_level.txt
reading manifest file 'similaripy.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'similaripy.egg-info\SOURCES.txt'
creating build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\__init__.py -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\coo_to_csr.h -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\normalization.cpp -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\normalization.pyx -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\s_plus.cpp -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\s_plus.h -> build\lib.win-amd64-3.7\similaripy\cython_code
copying similaripy\cython_code\s_plus.pyx -> build\lib.win-amd64-3.7\similaripy\cython_code
running build_ext
building 'similaripy.cython_code.s_plus' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\similaripy
creating build\temp.win-amd64-3.7\Release\similaripy\cython_code
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Isimilaripy\cython_code -IC:\Users\gaha\Anaconda3\include -IC:\Users\gaha\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\include" /EHsc /Tpsimilaripy\cython_code\s_plus.cpp /Fobuild\temp.win-amd64-3.7\Release\similaripy\cython_code\s_plus.obj /O2 /openmp
s_plus.cpp
C:\Users\gaha\Anaconda3\include\pyconfig.h(59): fatal error C1083: Nie moľna otworzy† pliku do\x88Ącz: 'io.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\gaha\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\gaha\\AppData\\Local\\Temp\\pip-install-midhwich\\similaripy\\setup.py'"'"'; __file__='"'"'C:\\Users\\gaha\\AppData\\Local\\Temp\\pip-install-midhwich\\similaripy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\gaha\AppData\Local\Temp\pip-record-gdm22cde\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output. for full command output.
Reading the example in the readme:
import similaripy as sim
import scipy.sparse as sps
# create a random user-rating matrix (URM)
urm = sps.random(1000, 2000, density=0.025)
# train the model with 50 knn per item
model = sim.cosine(urm.T, k=50)
# recommend 100 items to users 1, 14 and 8
user_recommendations = sim.dot_product(urm, model, target_rows=[1,14,8], k=100)
I have a doubt in the usage of the k param on the last row.. What is its sense?
Can I use the dot product as the standard dot product between 2 matrices? Can you clarify this please?
Can you help me?
I get following logs, when trying to install similaripy with pip on ubuntu.
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting similaripy
Using cached http://mirrors.aliyun.com/pypi/packages/55/7f/323eb210bc8db521479e61ca913f2da810d6d7fa6ee4f9b34bcf7a2d5227/similaripy-0.1.2.tar.gz (331 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: scipy>=1.0.0 in ./.local/lib/python3.8/site-packages (from similaripy) (1.6.2)
Requirement already satisfied: numpy>=1.14.0 in ./.local/lib/python3.8/site-packages (from similaripy) (1.20.1)
Requirement already satisfied: tqdm>=4.19.6 in ./.local/lib/python3.8/site-packages (from similaripy) (4.59.0)
Building wheels for collected packages: similaripy
Building wheel for similaripy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/atr1506/anaconda3/envs/jumper/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-30x2fjf5
cwd: /tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/
Complete output (44 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/similaripy
copying similaripy/utility.py -> build/lib.linux-x86_64-3.8/similaripy
copying similaripy/__init__.py -> build/lib.linux-x86_64-3.8/similaripy
copying similaripy/similarity.py -> build/lib.linux-x86_64-3.8/similaripy
copying similaripy/normalization.py -> build/lib.linux-x86_64-3.8/similaripy
running egg_info
writing manifest file 'similaripy.egg-info/SOURCES.txt'
creating build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/__init__.py -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/coo_to_csr.h -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/normalization.cpp -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/normalization.pyx -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/s_plus.cpp -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/s_plus.h -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/s_plus.pyx -> build/lib.linux-x86_64-3.8/similaripy/cython_code
running build_ext
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/similaripy
creating build/temp.linux-x86_64-3.8/similaripy/cython_code
gcc -pthread -B /home/atr1506/anaconda3/envs/jumper/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isimilaripy/cython_code -I/home/atr1506/anaconda3/envs/jumper/include/python3.8 -c similaripy/cython_code/s_plus.cpp -o build/temp.linux-x86_64-3.8/similaripy/cython_code/s_plus.o -Wno-unused-function -Wno-maybe-uninitialized -O3 -ffast-math -fopenmp -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from similaripy/cython_code/s_plus.cpp:671:0:
similaripy/cython_code/s_plus.h: In member function ‘void s_plus::SparseMatrixMultiplier<Index, Value>::foreach(Function&)’:
similaripy/cython_code/s_plus.h:115:22: error: ‘pow’ is not a member of ‘std’
xy = std::pow(xy, a1); // very slow operation
^
similaripy/cython_code/s_plus.h:115:22: note: suggested alternative:
In file included from /usr/include/features.h:424:0,
from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/limits.h:26,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:168,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:7,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:34,
from /home/atr1506/anaconda3/envs/jumper/include/python3.8/Python.h:11,
from similaripy/cython_code/s_plus.cpp:36:
/usr/include/x86_64-linux-gnu/bits/math-finite.h:156:1: note: ‘pow’
__MATH_REDIRCALL (pow, , (_Mdouble_, _Mdouble_));
^
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for similaripy
Running setup.py clean for similaripy
Failed to build similaripy
Installing collected packages: similaripy
Running setup.py install for similaripy ... error
ERROR: Command errored out with exit status 1:
command: /home/atr1506/anaconda3/envs/jumper/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7425mi13/install-record.txt --single-version-externally-managed --compile --install-headers /home/atr1506/anaconda3/envs/jumper/include/python3.8/similaripy
cwd: /tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/
Complete output (46 lines):
running install
/home/atr1506/anaconda3/envs/jumper/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/similaripy
copying similaripy/utility.py -> build/lib.linux-x86_64-3.8/similaripy
copying similaripy/__init__.py -> build/lib.linux-x86_64-3.8/similaripy
copying similaripy/similarity.py -> build/lib.linux-x86_64-3.8/similaripy
copying similaripy/normalization.py -> build/lib.linux-x86_64-3.8/similaripy
running egg_info
writing manifest file 'similaripy.egg-info/SOURCES.txt'
creating build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/__init__.py -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/coo_to_csr.h -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/normalization.cpp -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/normalization.pyx -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/s_plus.cpp -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/s_plus.h -> build/lib.linux-x86_64-3.8/similaripy/cython_code
copying similaripy/cython_code/s_plus.pyx -> build/lib.linux-x86_64-3.8/similaripy/cython_code
running build_ext
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/similaripy
creating build/temp.linux-x86_64-3.8/similaripy/cython_code
gcc -pthread -B /home/atr1506/anaconda3/envs/jumper/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isimilaripy/cython_code -I/home/atr1506/anaconda3/envs/jumper/include/python3.8 -c similaripy/cython_code/s_plus.cpp -o build/temp.linux-x86_64-3.8/similaripy/cython_code/s_plus.o -Wno-unused-function -Wno-maybe-uninitialized -O3 -ffast-math -fopenmp -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from similaripy/cython_code/s_plus.cpp:671:0:
similaripy/cython_code/s_plus.h: In member function ‘void s_plus::SparseMatrixMultiplier<Index, Value>::foreach(Function&)’:
similaripy/cython_code/s_plus.h:115:22: error: ‘pow’ is not a member of ‘std’
xy = std::pow(xy, a1); // very slow operation
^
similaripy/cython_code/s_plus.h:115:22: note: suggested alternative:
In file included from /usr/include/features.h:424:0,
from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/limits.h:26,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:168,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h:7,
from /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h:34,
from /home/atr1506/anaconda3/envs/jumper/include/python3.8/Python.h:11,
from similaripy/cython_code/s_plus.cpp:36:
/usr/include/x86_64-linux-gnu/bits/math-finite.h:156:1: note: ‘pow’
__MATH_REDIRCALL (pow, , (_Mdouble_, _Mdouble_));
^
error: command '/usr/bin/gcc' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/atr1506/anaconda3/envs/jumper/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ftjbpqb_/similaripy_ada36661a39543cab2f2804c28e2d698/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7425mi13/install-record.txt --single-version-externally-managed --compile --install-headers /home/atr1506/anaconda3/envs/jumper/include/python3.8/similaripy Check the logs for full command output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.