This article was originally published at Codeperfectplus.
Logistic Regression is a kind of parametric classification model. It's a binary classification machine learning algorithm. It can only be used to distinguish between 2 different categories like —
- Like if an E-mail is spam(1) or not(0).
- Whether the tumour is malignant (1) or not (0)
The theory behind Logistic Regression is very similar to the one from Linear Regression, so if you don’t know what Linear Regression is, take 5 minutes to read this Introduction.
- Binary Logistic Regression
- Multinomial Logistic Regression
- Ordinal Logistic Regression
- For Logistic regression, there should be minimal or no multicollinearity among the independent variables.
- The Logistic regression assumes that the independent variables are linearly related to the log of odds.
- The Logistic regression usually requires a large sample size to predict properly.
- In Logistic regression dependent, the variable should be binary.
- The Logistic regression assumes the observations to be independent of each other.
# Impoer Library for classification import numpy as np from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.linear_model import Logi from sklearn.metrics import accuracy_score from sklearn.pipeline import Pipeline from sklearn.preprocessing import StandardScaler import joblib
np.random.seed(10) # split data for training and testing purpose iris = load_iris() X = iris.data y = iris.target train_X, test_X, train_y, test_y = train_test_split(X, y, train_size=0.8)
# Create pipeline pipe = Pipeline([ ('scaler', StandardScaler()), ('logistic',LogisticRegression(),) ]) # fit and predict clf = pipe.fit(train_X, train_y) pred_y = clf.predict(test_X) score = accuracy_score(test_y, pred_y) print(score)
- Deploy Your First Django App With Heroku
- Single-layer Neural Networks in Machine Learning (Perceptrons)
- 5 Tips for Computer Programming Beginners
- What Is Git and GitHub?
- What is Simple Linear Regression?
- Introduction to Machine Learning and it's Type.
- Difference Between Machine Learning and Artificial Intelligence