Professional Documents
Culture Documents
The objective of this tutorial is to practice regression analysis using Python and get hands-on practice in
performing linear regression.
import pandas as pd
import numpy as np
import scipy.special as sps
import matplotlib.pyplot as plt
# define an error vector to save all error values over all iterations.
error_all = []
Y_hat = sps.expit(np.dot(X,w))
#
==========================================================================
===
# Compute the error below
#
==========================================================================
===
e = -np.mean(np.multiply(Y,np.log(Y_hat)) + np.multiply((1-
Y),np.log(1-Y_hat)))
error_all.append(e)
w_old = w
w = w - eta*grad_e