TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Andrew Ng’s Machine Learning Course in Python (Logistic Regression)

Benjamin Lau
TDS Archive
Published in
6 min readDec 13, 2018

--

Machine Learning – Andrew Ng

Continuing from the series, this will be python implementation of Andrew Ng’s Machine Learning Course on Logistic Regression.

Logistic regression is used in classification problems where the labels are a discrete number of classes as compared to linear regression, where labels are continuous variables.

Same as usual, we start with importing of libraries and the dataset. This dataset contains 2 different test score of students and their status of admission into the university. We are asked to predict if a student gets admitted into a university based on their test scores.

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_csv("ex2data1.txt",header=None)

Making sense of the data

df.head()
df.describe()

Plotting of the data

pos , neg = (y==1).reshape(100,1) , (y==0).reshape(100,1)
plt.scatter(X[pos[:,0],0],X[pos[:,0],1],c="r",marker="+")
plt.scatter(X[neg[:,0],0],X[neg[:,0],1],marker="o",s=10)
plt.xlabel("Exam 1 score")
plt.ylabel("Exam 2 score")…

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Benjamin Lau
Benjamin Lau

Written by Benjamin Lau

Self-motivated data scientist. My proactive approach has allowed me to embrace and stay at the forefront of the ever-evolving tech landscape.

Responses (8)