swi-ml- 2 mins
Table of Contents:
- What is swi-ml?
- But what is a switchable backend?
- How do I use it?
- What dependencies do I need to install?
- Cherry Points
Small Disclaimer: This library is NOT an alternative to amazing libraries like scikit-learn and cuML. Their interfaces are complete on their own!
What is swi-ml?
swi-ml is a small lightweight Python library, which implements a subset of classical machine learning algorithms, with a twist - it has a switchable backend!
from swi_ml import set_backend # numpy backend (CPU) set_backend("numpy") # cupy backend (GPU) set_backend("cupy")
But what is a switchable backend?
But, most of its code is in serial order.
numpyis primarily designed to be as fast as possible on a single core, and to be as parallelizable as possible if you need to do so.
Moreover, vanilla NumPy cannot accelerate computing on a GPU.
CuPy comes to rescue!
CuPy is an open-source array library accelerated with NVIDIA CUDA, which speeds up some operations more than 100X.
“CuPy’s interface is highly compatible with NumPy; in most cases it can be used as a drop-in replacement.” - So why not use this and create a small library which implements a domain-problem (machine learning in this case) and benefit from both libraries at a single interface?
This is what swi-ml does.
It was built in a duration of a month, where I mostly learnt:
- code structure
- building a library
- implementing correct (bybye
- and most importantly - implementing a
singleton(with correct raises and runtime imports)
How do I use it?
swi-ml is published to PyPI at this URL: https://pypi.org/project/swi-ml/
So installing it is as simple as:
pip install swi-ml
Or, via GitHub:
pip install git+https://github.com/aitikgupta/swi-ml
What dependencies do I need to install?
Except NumPy, there’s no hard-dependency!
Although, to use the GPU-accelerated backend, a working installation of CuPy (install guide) is required.
(Recommended) Checkout the README.md on GitHub for a detailed guide.
Code is open sourced at GitHub, one can find many, many comments within the library.
There was a time in developing cycles, when I decided to - cherry points if one can figure out the previous name! (HINT: It is close to an amazing library by RapidsAI, and has a commit dedicated to it)