import sklearn code example

Example 1: install sklearn

pip install scikit-learn

Example 2: conda install sklearn 0.20

conda install scikit-learn=0.20

Example 3: install sklearn

sudo pip3 install scikit-learn

Example 4: sklearn version

import nltk
import sklearn

print('The nltk version is {}.'.format(nltk.__version__))
print('The scikit-learn version is {}.'.format(sklearn.__version__))

# The nltk version is 3.0.0.
# The scikit-learn version is 0.15.2.

Example 5: sklearn - check the name of a machine learning

# Define the model
model1 = LogisticRegression()

# Check the name of the model
# It is useful when we are dealing with many alternative models
model1.__class__.__name__

Tags:

C Example