# Python Implementation of SVM, Logistics Regression, Naive Bayes, Decision Tree, Random Forest…

Original article was published on Deep Learning on Medium # Python Implementation of SVM, Logistics Regression, Naive Bayes, Decision Tree, Random Forest using Scikit-learn (just 3 line of Code)

## Python Implementation of 5 Machine Learning Algorithm for Machine Learning Classification Problems

Hello Programmers!

Here I am gonna show How to Implement SVM, Logistics Regression, Naive Bayes, Decision Tree, Random Forest in Python using Scikit-learn or sklearn. And yeah this is too easy to implement, just write three lines of Python code, and you get your Decision Tree classifier.

Because this is beauty of sklearn (Scikit-learn).

Note: You can get this notebook in my Github, I give you link below.

So let’s dirty our hands by some coding.

First we need a dataset, and I have a dataset of Market where you have to predict that customer purchasing item or not.

## What has in my Dataset?

1. Have three columns
2. Age: Age of Person
3. Estimated Salary: Salary of an individual
4. Purchased: Customer buy or not

## Important Python Libraries:

1. Numpy for handling arrays
2. Pandas for creating DataFrame
3. Sklearn for Machine Learning

## Installing Libraries Using pip

`#dependencies!pip install numpy!pip install pandas!pip install sklearn`

## In 

train_test_split: Split arrays or matrices into random train and test subsets or you can say it split the dataset into train set and test set by 20%

`# Importing the librariesimport numpy as npimport pandas as pd# Importing the datasetdataset = pd.read_csv('dataset.csv')display(dataset.head())X = dataset[['Age', 'EstimatedSalary']].valuesy = dataset['Purchased'].valuesprint('-'*80)print(f'Shape of X is {X.shape}\nShape of y is {y.shape}')# Splitting the dataset into the Training set and Test setfrom sklearn.model_selection import train_test_splitX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)print('-'*80)print(f"Lenght of X_train: {len(X_train)}\nLenght of X_test: {len(X_test)}")print(f"Lenght of y_train: {len(y_train)}\nLenght of y_test: {len(y_test)}")`