Difference Between scikit-learn and sklearn | Towards Data Science

scikit-learn is definitely one of the most commonly used packages when it comes to Machine Learning and Python. However, a lot of newcomers get confused about the naming of the package itself due to the fact that it looks to appear with two distinct names; scikit-learn and sklearn.
In today’s short article, we will discuss whether there’s any difference between the two packages in the first place. Additionally, we’ll discuss whether it matters which one you install and import in your source code.
The project was originally started back in 2007 as part of the Google Summer of Code while the first public release was made in early 2010.
scikit-learn is an open source Machine Learning Python package that offers functionality supporting supervised and unsupervised learning. Additionally, it provides tools for model development, selection and evaluation as well as many other utilities including data pre-processing functionality.
More specifically, scikit-learn’s main functionality includes classification, regression, clustering, dimensionality reduction, model selection and pre-processing. sThe library is very simple to use and most importantly efficient as it is built on NumPy, SciPy and matplotlib.
The short answer is no. scikit-learn and sklearn both refer to the same package however, there are a couple of things you need to be aware of.
Firstly, you can install the package by using either of scikit-learn or sklearn identifiers however, it is recommended to install scikit-learn through pip using the skikit-learn identifier.
If you install the package using the sklearn identifier and then run pip list you will notice the annoying sklearn 0.0 entry:
$ pip install sklearn$ pip listPackage       Version------------- -------joblib        1.0.1numpy         1.21.2pip           19.2.3scikit-learn  0.24.2scipy         1.7.1setuptools    41.2.0sklearn       0.0threadpoolctl 2.2.0
Additionally, if you now attempt to uninstall sklearn, the package won’t be uninstalled:
$ pip uninstall sklearn$ pip listPackage       Version------------- -------joblib        1.0.1numpy         1.21.2pip           19.2.3scikit-learn  0.24.2scipy         1.7.1setuptools    41.2.0threadpoolctl 2.2.0
Essentially, sklearn is a dummy project on PyPi that will in turn install scikit-learn. Therefore, if you uninstall sklearn you are just uninstalling the dummy package, and not the actual package itself.
Now despite how you installed scikit-learn, you must import it in your code using the sklearn identifier:
import sklearn
If you attempt to import the package using the scikit-learn identifier, you will end up with a SyntaxError:
>>> import sklearn>>> import scikit-learnFile "<stdin>", line 1import scikit-learn             ^SyntaxError: invalid syntax
Even if you try to import it with __import__() in order to deal with the hyphen in the package’s name, you will still get a ModuleNotFoundError:
>>> __import__('scikit-learn')Traceback (most recent call last):File "<stdin>", line 1, in <module>ModuleNotFoundError: No module named 'scikit-learn'
In today’s short article, we attempted to shed some light around scikit-learn and sklearn since a lot of beginners seem to be confused about which term to use when developing ML functionality in Python.
In general, you are advised to install the library using the scikit-learn identifier (i.e. pip install scikit-learn) but in your source code, you must import it using the sklearn identifier (i.e. import sklearn).
Become a member and read every story on Medium. Your membership fee directly supports me and other writers you read.
You may also like