Python commands to import algorithms in Machine Learning

Published by Patrick Mebus on

Python commands to import algorithms in Machine Learning

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

One very comfortable thing about Machine Learning is, that we don’t have to write an algorithm from scratch every time. By importing algorithms from libraries we can save tons of time. This article provides a short overview about the import commands for some commonly used algorithms in supervised and unsupervised learning.

For the examples in this article we’ll import our Machine Learning algorithms from the library scikit-learn

1. Linear Regression
from sklearn import linear_model
2. Logistic Regression
From sklearn.linear_model import LogisticRegression
3. Decision Tree (Regression)
from sklearn import tree 
4. Decision Tree (Classification)
from sklearn.tree import DecisionTreeClassifier
5. Random Forest (Regression)
from sklearn.ensemble import RandomForestRegressor  from sklearn.datasets import make_regression
6. Random Forest (Classification)
from sklearn.ensemble import RandomForestClassifier 
from sklearn.datasets import make_classification
7. k-Nearest Neigbor
from sklearn.neighbors import KNeighborsClassifier
8. Support Vector Machine
from sklearn import svm
9. Naive Bayes (Gauss)
from sklearn.naive_bayes import GaussianNB

You see. To import algorithms in Machine Learning we just need a few lines of code. You will all find them in the sklearn documentation as well. But I think it cant be wrong to have them all in one place.

Was this article helpful for your work? Leave a comment 🙂 

exited about this post? feel free to share

Patrick Mebus

I’m a Digital Marketer with deep passion for Search Engines, Automation and AI. I’m here to make Machine Learning more feasible for Search Engine Marketers.

2 Comments

Coding for SEM - Reaching the next level - SEM SMARTATION · April 19, 2020 at 7:02 pm

[…] The great thing Python in Machine Learning is, that you don’t have to build every model or every algorithm from scratch. There a plenty of Python libraries where you can import the needed algorithms from. An overview about commonly used import commands for algorithms in Python you’ll find here: https://sem-smartation.com/import-algorithms/ […]

How to build a Keyword-Classifier with Machine Learning - SEM SMARTATION · April 19, 2020 at 7:07 pm

[…] As an algorithm we now import the Logistic Regression from scikit-learn and create our Python model object. That’s the great thing about Python. You don’t need to write every algorithm from scratch and use the import function instead (An overview about import commands for other algorithms you’ll find here) […]

Leave a Reply

Your email address will not be published. Required fields are marked *