Preprocessing and Data Representation
Decomposition re-expresses data so that its main variation is easier to see.
A Table With No Answers
Many beginners arrive at machine learning expecting that every algorithm will be judged by a clear score: accuracy for a classifier, error for a regressor. When they meet unsupervised methods, they face data that has no known answers attached. Suppose you have a large table of measurements taken from patients, and nobody has labeled which patients have a particular condition. You could still try an unsupervised method to look for structure in that table. The question this article answers is whether the lack of an obvious score is a good reason to skip that step.
What do you think happens?
Before reading on, decide: if an algorithm produces no clear accuracy score, is that a good reason to skip it when you have unlabeled data?
Reveal answer
No, the method may still reveal useful structure, though results need careful interpretation
The source states that it is often hard to quantify the usefulness of an unsupervised algorithm, but that this difficulty should not stop you from using these methods to gather insights. The difficulty is a reason to be careful when interpreting results, not a reason to avoid the methods.
Why Beginners Distrust Unlabeled Results
The belief that unsupervised methods are not worth much is understandable. Supervised learning gives a built-in test: you hold back some labeled examples, the model predicts their answers, and you compare those predictions to the truth. Unsupervised learning removes that built-in test, because the data arrives without the answers the algorithm would need to be checked against. A learner who has grown used to that checking step may conclude that a method without it cannot be trusted or cannot be useful.
The source offers a more accurate picture. Unsupervised learning algorithms can be applied for exploratory data analysis and preprocessing. They can be used in the absence of supervision information, and they are important for understanding the properties of data. In some cases they are the only way to make sense of your data when no supervision information is available. This is a claim about purpose: these methods are chosen to reveal structure and prepare data, not to earn a score.
Three Tools for Exploring Data
The source names three families of unsupervised tools that a learner needs at this stage. Decomposition is described as an essential tool for further understanding data. Manifold learning is also described as a tool for further understanding data. Clustering is described as a technique used to group data. The source presents these together as the methods practitioners use every day to understand their data. Each one takes the same kind of unlabeled input but aims at a different kind of structure.
The three tools are not interchangeable. Decomposition re-expresses data so that its main variation is easier to see. Manifold learning is aimed at data that lies on a curved, lower-dimensional surface inside a space with many features. Clustering asks which observations belong together. The source emphasizes purpose over technique: all three are there to help you understand the data before you decide what to do with it.
Manifold Learning on a Curved Surface
Manifold learning deals with a particular situation. Imagine data with many features that, in practice, lies on a curved surface inside that high-dimensional space. Two points can look far apart when measured in the full space while sitting close together along the surface itself. The goal of manifold learning, as the source frames it, is to help you understand the structure of such data. The source does not spell out the internal workings of any manifold method, so the important point here is the purpose: a representation in which the data's structure can be examined more easily.
How scikit-learn Organizes Algorithms
Once you choose an algorithm, you still need to know how scikit-learn expects you to use it. The library shares one application programming interface, or API, across all of its algorithms. Preprocessing methods, supervised learning methods, and unsupervised learning methods are all implemented as classes. These classes are called estimators. The consequence is that the same basic pattern applies to a clustering method, a decomposition method, or a classifier: you must first create an object of the particular class before applying the algorithm.
Think of the class as a blueprint and the object as the working instance built from it. The class describes what the algorithm is; the object holds the settings you chose and, after training, the results it learned. Because every scikit-learn algorithm follows this shape, once you understand the pattern for one, the others look familiar.
Mistakes Beginners Make With Unsupervised Results
Common mistake Skipping an unsupervised method because no accuracy score exists
What it looks likeA table of unlabeled patient measurements is set aside because there is no test set to compare predictions against.
Why it failsThe source says that the difficulty of quantifying usefulness is a reason to be careful, not a reason to avoid the methods. The purpose of these methods is to gather insights and reveal structure.
Do this insteadUse the method to explore the data, then interpret what it shows with caution and check whether the structure makes sense.
Common mistake Calling a method on the class instead of an object
What it looks likePCA.fit(X_train) is written directly on the class name.
Why it failsEstimators are classes that must be instantiated before the algorithm is applied, so the method needs an object to work on.
Do this insteadCreate the object first, as in pca = PCA(n_components=2), and then call pca.fit(X_train).
Common mistake Treating the three tools as interchangeable when each reveals a different kind of structure
Practice: Choosing How to Explore Unlabeled Data
A research team has a large table of unlabeled measurements and wants to know whether the patients fall into natural groups. A colleague says the team should not run any unsupervised method because there is no accuracy score to check the result. Explain why this reasoning is weak, name the tool best suited to looking for natural groups, and describe the first two steps you would take in code to use a scikit-learn estimator for that tool.
Hints
- Recall the source's point that difficulty of measuring usefulness is a reason for care, not avoidance.
- Clustering is the source's named technique for grouping data.
- Remember that you must instantiate the estimator class before fitting it.
Key Takeaways
- Unsupervised learning can be applied for exploratory data analysis and preprocessing, and is sometimes the only way to make sense of data when no supervision information exists.
- Decomposition, manifold learning, and clustering are essential tools for understanding data, each revealing a different kind of structure.
- Usefulness is harder to measure without labels, but that difficulty calls for careful interpretation rather than skipping the methods.
- Every scikit-learn algorithm is an estimator class, so you must instantiate an object of the class before applying the algorithm.