Supervised vs Unsupervised Learning
Greetings fellow data science compatriots to my fourth mandatory blog post where I will be talking about the difference between supervised and unsupervised learning since I think I can write 750 words on this as opposed to PCA (Principal Component Analysis) or Eigenvalue/vectors.
First of all, when we talk about learning we should first identify who is learning since it obviously isn’t going to be us. The one that will be supervised or unsupervised would be the machine, and you can pretty much squeeze machine between the words: supervised machine learning/unsupervised machine learning. When it comes to the word supervised, you can kind of draw a parallel to reality. If you’re learning supervised, you pretty much have an instructor who’s there to hold your hand and tell you what to learn while if you’re learning unsupervised; you’re just living on a prayer on what to learn. It’s the same for machine in that for supervised learning, there’s a set variable or column that you’re looking to predict; while in unsupervised learning, there is no set variable that is being predicted.
While they’re both methods of learning, the problems they solve can be quite different from each other. So, let’s dive into what problems are being solved by each.
Supervised learning usually works to solve either classification or regression problems. Classification problems are usually predicting stuff that are usually categorical or Yes/No’s. For example, if you were trying to predict whether someone has the seasonal vaccination or not, if a team is going to win or not, or whether it’s going to rain or not. Regression problem on the other hand usually is trying to predict the supervised variable based off all the other variables in the dataset; essentially, finding a continuous output as opposed to a categorical. For example, you could be trying to predict the housing price, stock prices, or even the expected length and girth. In fact, for our third phase project I was tasked to build a prediction model for seeing whether if someone was seasonal flu vaccinated or H1N1 vaccinated, and supervised learning was the way to go for that since the target variables would be H1N1 Vaccinated/Seasonal Flu Vaccinated (A model for each). Supervised learning is a lot less complex as there’s a specific variable that is trying to be predicted as compared to unsupervised learning. Models for supervised learning consist of Linear/Logistic Regression, Decision Tree, K-Nearest Neighbors, Naive Bayes, Support Vector Machines, Extra Trees, and Random Forests. Some of the models can be used for both classification and regression; linear is used for regression and logistic is used for classification.
Get Charles Pan’s stories in your inbox
Join Medium for free to get updates from this writer.
If you ever need to find out more about these models, you can just google them and click the scikit-learn or someone else's blogpost to go further into it. Below are the imports, it’s interesting to see which models are grouped within the same sklearn for example the linear_models and the ensembles.
Linear Regression and Logistic Regression work to tackle to different types of output solutions (Categorical vs Continuous)
Random Forest and Extra Trees work to tackle the same issue except Random Forest looks to find the best split on where the nodes split for the decision trees while Extra Trees is a more random in that aspect. In terms of the end goal, Random Forest will output a more accurate result, but Extra Trees will provide a similar result at a significantly faster execution time. If you’re strapped on time or the data you’re working with is humongous, Extra Trees would be the way to go.
from sklearn.linear_model import LinearRegression
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.neighbors import NearestNeighbors
from sklearn.naive_bayes import GuassianNB
from sklearn import svm
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import ExtraTreesClassifierUnsupervised learning on the other hand usually works to find all types of patterns within a dataset through clustering and identifying features which could be useful for categorization through principal component analysis. But what kind of problems could people solve with that, especially since it doesn’t seem as straight-forward as supervised learning where you’re looking for a specific output? One example would be if you were tasked to build a recommendation system for Netflix, unsupervised learning would be the way to go. To further go in, in unsupervised learning one can use dimensionality reduction to pick out key features and use clustering to build a recommendation system or targeted marketing for specific clientele who fit the key features. I haven’t learned too much about unsupervised learning yet as I am currently still in Phase 4 of the FlatIron Bootcamp, but it seems a lot more complex but the problems it solves is vastly more different. I look forward to the upcoming project since I think recommendation systems are much more interesting than prediction models. Thanks for coming to my barely above 800 word blogpost.





