Scikit-learn

Scikit-learn is part of the SciPy Toolkits, which are packages that are affiliated with SciPy. More information on SciPy toolkits and a list of available ones can be found at https://www.scipy.org/scikits.html . The first release of Scikit-learn came in 2007, but the first publication presenting the package in 2011 was Machine Learning in Python, Pedregosa et al., JMLR 12, pp. 2825-2830, 2011. For a wealth of examples, documentation, and reading, see the Scikit-learn web page ( http://scikit-learn.org ). The package is well-maintained and the documentation is excellent and very extensive in coverage.

After this brief introduction, we do as we did in the previous chapters—we start a Jupyter Notebook and run the standard imports.

Now we also, of course, want to import Scikit-learn. The following code imports it and also prints out the version number of the installed Scikit-learn:

import sklearn 
sklearn.__version__

Next, I have created a function that removes the right and top axis in a plot or a grid of plots. It comes in handy when producing figures; it is important to be able to present the data and results from the analysis in a clear and focused way. Removing unnecessary lines in a plot is part of this and also saves text space. The name of the despine function is inspired by the equivalent function in the excellent package, Seaborn, which can help you make nice figures as well ( https://stanford.edu/~mwaskom/software/seaborn/ ):

def despine(axs): 
    # to be able to handle subplot grids 
    # it assumes the input is a list of  
    # axes instances, if it is not a list,  
    # it puts it in one 
    if type(axs) != type([]): 
        axs = [axs] 
    for ax in axs: 
        ax.yaxis.set_ticks_position('left') 
        ax.xaxis.set_ticks_position('bottom') 
        ax.spines['bottom'].set_position(('outward', 10)) 
        ax.spines['left'].set_position(('outward', 10)) 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset