Data Science (Python) :: Logistic Regression

Sunil Kumar SV
1 min readJul 16, 2017

--

Intention of this post is to give a quick refresher (thus, it’s assumed that you are already familiar with the stuff) of concept of “Logistic Regression” (using Python). You can treat this as FAQ’s as well.

What kind of problems does Logistic Regression model generally fit to?

Classification problems. For e.g, predict if person will buy a product or not (dependent variable) considering his/her age and salary (independent variables)

********************************************

Sample code for fitting logistic regression to the set?

from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 0)
classifier.fit(X_train, y_train) # X_train is training set for independent variables and y_train is the training set for dependent variables

# Predicting the Test set results
y_pred = classifier.predict(X_test)

********************************************

What is confusion matrix?

Confusion matrix gives us an idea about how many predictions were right and how many prediction were wrong.

*******************************************

Code for creating the confusion matrix?

from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred) #y_test is the test set for dependent variable

Next :- Data Science (Python) :: K-NN (K — Nearest Neighbors)

Prev :- Data Science :: Advantages & Disadvantages of Each Regression Model

If you liked this article, please hit the ❤ icon below

--

--

Sunil Kumar SV

#ProductManager #TechEnthusiast #DataScienceEnthusiast #LoveToSolveProblemsUsingTech #Innovation