Using scikit-learn with other scientific Python tools
scikit-learn is very popular and widely used in industry and academia, and it works well with other scientific Python tools.
Why Practitioners Rely on Libraries
Suppose you want to apply machine learning to a problem in Python. You need algorithms that learn patterns from data, and you need to understand how each algorithm is meant to be used. Writing every algorithm yourself is slow and error-prone, so practitioners usually rely on a library: a collection of tested, reusable tools that someone else has already built. scikit-learn is one such library.
This article answers three questions before you go further into the chapter: what scikit-learn is, what it provides, and why it is worth knowing about. It also shows you how to use the learning resources that come with it, and how the library fits into a larger working setup.
What do you think happens?
If a library's source code is open for anyone to read, what can you do that you could not do with a black box?
Reveal answer
Read the code behind a step to see what it is doing
Because the source code is available to anyone, the code that performs a step can, in principle, be read. You are not limited to trusting a black box.
Tracing the Path Through This Material
Before looking at what the library contains, it helps to see the order in which you should engage with it. The source gives a concrete instruction: while you read the chapter, you should also browse the scikit-learn user guide and API documentation for more detail and for the many options available for each algorithm. Learning what the library offers comes first. Getting it onto your own system is a separate step that makes it usable.
What Open Source Means Here
scikit-learn is an open source Python library for machine learning. It is free to use and distribute, and its source code is something anyone can obtain and examine.
The phrase open source tells you something about access, not only about cost. Because the source code is available to anyone, you are not limited to trusting a black box. If you want to know what a particular step is doing behind the scenes, the code that performs that step can, in principle, be read. This transparency is one of the features that makes the library valuable to people who want to understand machine learning rather than just call functions that produce results.
Open source projects of this kind are also not frozen at one moment in time. The source describes scikit-learn as constantly being developed and improved, with a very active user community. Improvements arrive continually, and the people who use the library also take part in shaping it.
Algorithms and Documentation as a Pair
scikit-learn offers two main things. The first is a set of machine learning algorithms. The source describes them as state-of-the-art, and it does not list every specific algorithm the library contains. The second is documentation: each algorithm is accompanied by comprehensive documentation describing that algorithm.
The two parts belong together. The algorithms give you working tools, and the documentation explains what each tool is for and what options it offers. If you want a complete list of the algorithms, or the detailed options for one of them, the documentation is the right place to look, which is why the source recommends it so strongly.
Where scikit-learn Sits in a Working Setup
The source notes that scikit-learn works well with a number of other scientific Python tools, which the chapter discusses later. Keep this in mind as you learn: scikit-learn is usually one piece of a larger working setup rather than a complete environment by itself. The source does not describe the details of these connections here, so this article does not claim more than that. The chapter is where those details are covered.
Other scientific Python tools that a learner may meet alongside scikit-learn include NumPy, pandas, SciPy, and matplotlib. Read the diagram below as a map of relationships: scikit-learn sits among these tools, and it works with them rather than replacing them.
Using the Documentation Alongside This Chapter
The learning resources that accompany scikit-learn are the user guide and the API documentation. The source describes the online documentation as very thorough. It also explains that this chapter supplies the machine learning prerequisites needed to understand that documentation in depth. The two work together: the chapter gives you the background, and the documentation gives you the detail for each algorithm.
Planning a study session
You are reading a chapter section about one algorithm in scikit-learn. You want to know what the algorithm is for and what options you can choose from.
- 1Read the chapter section first
The chapter supplies the machine learning background you need to follow the documentation in depth.
- 2Open the user guide for the algorithm
The user guide is one of the two resources the source recommends browsing while you read the chapter.
- 3Check the API documentation for the options
The API documentation provides the detailed options available for each algorithm, so it is where you confirm what you can configure.
- 4Return to the chapter with the details in mind
Combining the background with the documentation's details shows how the pieces of the algorithm fit together.
You understand what the algorithm is for and which options it offers, using the chapter for background and the documentation for detail.
Why scikit-learn Stands Out
The source describes scikit-learn as a very popular tool and as the most prominent Python library for machine learning. It is widely used in both industry and academia. Those two settings have different goals. Companies usually want models that solve business problems, while universities and research groups often want to study and compare methods.
A library that serves both audiences has to be accurate, well documented, and easy to learn from. Several features described in the source line up with those needs: the algorithms are described as state-of-the-art, each one comes with comprehensive documentation, the code is open for anyone to examine, and the project keeps improving with an active community. Taken together, these explain why it is worth knowing about before you go further.
Common Mistakes When Starting with scikit-learn
Common mistake Treating scikit-learn as a complete environment by itself
What it looks likeAssuming that once the library is in place, you have everything needed for a full working setup.
Why it failsThe source notes that scikit-learn works well with other scientific Python tools and is usually one piece of a larger working setup.
Do this insteadThink of scikit-learn as one component, and expect to work with other scientific Python tools as the chapter describes.
Common mistake Skipping the documentation because the algorithms look self-explanatory
What it looks likeUsing an algorithm without checking its user guide or API documentation, and never learning which options it offers.
Why it failsThe documentation is what explains what each algorithm is for and what options it provides. The source lists it as a central resource.
Do this insteadBrowse the user guide and API documentation while you read the chapter.
Common mistake Assuming installation comes first in the learning order
What it looks likeInstalling the library and then trying to decide what it offers.
Why it failsThe source places learning what the library offers first. Installation is a separate step that makes the library usable.
Do this insteadLearn what the library offers, then get it onto your system.
Common mistake Reading open source as only meaning free of charge
What it looks likeBelieving that open source only describes cost.
Why it failsThe phrase open source tells you something about access. The source code can be obtained and examined by anyone.
Do this insteadRemember that open source also means you can inspect how a step works.
Practice: Mapping Your Own Learning Path
Write down three things you want to learn from this chapter. For each one, say which scikit-learn resource you would check for detail (the user guide or the API documentation), and which other scientific Python tool you expect might be involved in the workflow. Explain why you chose each resource.
Hints
- Use the chapter for background and the user guide or API documentation for detail on each algorithm.
- Remember that the chapter covers how scikit-learn works with other scientific Python tools, so you may not know the full answer yet.
- Keep installation separate: decide what you want to learn first, then plan how you will get the library onto your system.
Key Takeaways
- scikit-learn is an open source Python library for machine learning. Its source code is free to use and can be obtained and examined by anyone, so you can read how a step works.
- scikit-learn offers two main things: state-of-the-art machine learning algorithms, and comprehensive documentation for each algorithm that explains what it is for and what options it offers.
- The learning resources are the user guide and the API documentation. Browse them while reading this chapter, and treat the chapter as the source of background and the documentation as the source of detail.
- scikit-learn is a prominent tool because it is widely used in industry and academia, works well with other scientific Python tools, and continues to be developed by an active community.
- scikit-learn is usually one piece of a larger working setup. Learn what it offers first, then install it on your system before using it.