Getting the Right Library for Machine Learning

By John Paul Mueller, Luca Massaron

Part of Machine Learning For Dummies Cheat Sheet

When working with R and Python for machine learning, you gain the benefit of not having to reinvent the wheel when it comes to algorithms. There is a library available to meet your specific needs — you just need to know which one to use. This table provides you with a listing of the libraries used for machine learning for both R and Python. When you want to perform any algorithm-related task, simply load the library needed for that task into your programming environment.

Algorithm Python implementation R implementation
Adaboost sklearn.ensemble.AdaBoostClassifier


sklearn.ensemble.AdaBoostRegressor
library(ada) : ada
Gradient Boosting sklearn.ensemble.GradientBoostingClassifier


sklearn.ensemble.GradientBoostingRegressor
library(gbm) : gbm
K-means sklearn.cluster.KMeans


sklearn.cluster.MiniBatchKMeans
library(stats) : kmeans
K-nearest Neighbors sklearn.neighbors.KNeighborsClassifier


sklearn.neighbors.KNeighborsRegressor
library(class): knn
Linear regression sklearn.linear_model.LinearRegression


sklearn.linear_model.Ridge


sklearn.linear_model.Lasso


sklearn.linear_model.ElasticNet


sklearn.linear_model.SGDRegressor
library(stats) : lm


library(stats) : glm


library(MASS) : lm.ridge


library(lars) : lars


library(glmnet) : glmnet
Logistic regression sklearn.linear_model.LogisticRegression


sklearn.linear_model.SGDClassifier
library(stats) : glm


library(glmnet) : glmnet
Naive Bayes sklearn.naive_bayes.GaussianNB


sklearn.naive_bayes.MultinomialNB


sklearn.naive_bayes.BernoulliNB
library(klaR) : NaiveBayes


library(e1071) : naiveBayes
Neural Networks sklearn.neural_network.BernoulliRBM


(in version 0.18 of Scikit-learn, a new implementation of supervised neural network will be introducted)
library(neuralnet) : neuralnet


library(AMORE) : train


library(nnet) : nnet
PCA sklearn.decomposition.PCA library(stats): princomp


library(stats) : stats
Random Forest sklearn.ensemble.RandomForestClassifier


sklearn.ensemble.RandomForestRegressor


sklearn.ensemble.ExtraTreesClassifier


sklearn.ensemble.ExtraTreesRegressor
library(randomForest) : randomForest
Support Vector Machines sklearn.svm.SVC


sklearn.svm.LinearSVC


sklearn.svm.NuSVC


sklearn.svm.SVR


sklearn.svm.LinearSVR


sklearn.svm.NuSVR


sklearn.svm.OneClassSVM
library(e1071) : svm
SVD sklearn.decomposition.TruncatedSVD


sklearn.decomposition.NMF
library(irlba) : irlba


library(svd) : svd