Locate the Algorithm You Need
Machine learning requires the use of a large number of algorithms to perform various tasks. However, finding the specific algorithm you want to know about could be difficult. The following table provides you with an online location for information about the most common algorithms.
Choose the Right Algorithm
Machine Learning For Dummies, 2nd Edition discusses a lot of different algorithms, and it may seem at times as if it will never run out. The following table provides you with a quick summary of the strengths and weaknesses of the various algorithms.
Algorithm | Best at | Pros | Cons |
Random Forest |
|
|
|
Gradient Boosting |
|
|
|
Linear regression | * Baseline predictions * Econometric predictions * Modelling marketing responses |
* Simple to understand and explain * It seldom overfits * Using L1 & L2 regularization is effective in feature selection * Fast to train * Easy to train on big data thanks to its stochastic version |
* You have to work hard to make it fit nonlinear functions * Can suffer from outliers |
Support Vector Machines |
|
|
|
K-Nearest Neighbors |
|
|
|
Adaboost |
|
|
|
Naive Bayes |
|
|
|
Neural Networks |
|
|
|
Logistic regression |
|
|
|
SVD |
|
|
|
PCA |
|
|
|
K-means |
|
|
|
Get the Right Package
When working with Python, you gain the benefit of not having to reinvent the wheel when it comes to algorithms. There is a package available to meet your specific needs—you just need to know which one to use. The following table provides you with a listing of common Python packages. When you want to perform any algorithm-related task, simply load the package needed for that task into your programming environment.
- Adaboost: ensemble.AdaBoostClassifier and sklearn.ensemble.AdaBoostRegressor
- Gradient Boosting: ensemble.GradientBoostingClassifier and sklearn.ensemble.GradientBoostingRegressor
- K-means: cluster.KMeans and sklearn.cluster.MiniBatchKMeans
- K-Nearest Neighbors: neighbors.KNeighborsClassifier and sklearn.neighbors.KNeighborsRegressor
- Linear regression: linear_model.LinearRegression, sklearn.linear_model.Ridge, sklearn.linear_model.Lasso, sklearn.linear_model.ElasticNet, and sklearn.linear_model.SGDRegressor
- Logistic regression: linear_model.LogisticRegression and sklearn.linear_model.SGDClassifier
- Naive Bayes: naive_bayes.GaussianNB. sklearn.naive_bayes.MultinomialNB, and sklearn.naive_bayes.BernoulliNB
- Neural Networks: keras
- Principal Component Analysis (PCA): sklearn.decomposition.PCA
- Random Forest: ensemble.RandomForestClassifier. sklearn.ensemble.RandomForestRegressor, sklearn.ensemble.ExtraTreesClassifier, and sklearn.ensemble.ExtraTreesRegressor
- Support Vector Machines (SVMs): svm.SVC, sklearn.svm.LinearSVC, sklearn.svm.NuSVC, sklearn.svm.SVR, sklearn.svm.LinearSVR, sklearn.svm.NuSVR, and sklearn.svm.OneClassSVM
- Singular Value Decomposition (SVD): decomposition.TruncatedSVD and sklearn.decomposition.NMF
Differentiating Learning Types
Algorithms are said to learn, but it’s important to know how they learn because they most definitely don’t learn in the same way that humans do. Learning comes in many different flavors, depending on the algorithm and its objectives. You can divide machine learning algorithms into three main groups based on their purpose:
- Supervised learning: Occurs when an algorithm learns from example data and associated target responses that can consist of numeric values or string labels — such as classes or tags — in order to later predict the correct response when posed with new examples. The supervised approach is, indeed, similar to human learning under the supervision of a teacher. The teacher provides good examples for the student to memorize, and the student then derives general rules from these specific examples.
- Unsupervised learning: Occurs when an algorithm learns from plain examples without any associated response, leaving the algorithm to determine the data patterns on its own. This type of algorithm tends to restructure the data into something else, such as new data features that may represent a class or some new values helpful for additional analysis or for the training a predictive model.
- Reinforcement learning: Occurs when you sequentially present the algorithm with examples that lack labels, as in unsupervised learning. However, you accompany each example with positive or negative feedback according to the solution the algorithm proposes. Reinforcement learning is connected to applications for which the algorithm must make decisions (so that the product is prescriptive, not just descriptive, as in unsupervised learning), and the decisions bear consequences.