利用python完成课程作业ex1的第二部分,第二部分要求如下:
In this part, you will implement linear regression with multiple variables to predict the prices of houses. Suppose you are selling your house and you want to know what a good market price would be. One way to do this is to rst collect information on recent houses sold and make a model of housing prices.
在ex1_mul.py的代码中,分为三个部分,每个部分分别如下:
- Part 1: Feature Normalization
- Part 2: Gradient Descent
- Part 3: Normal Equations
具体代码如下:
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 17 12:02:43 2019
@author: Lonely_hanhan
"""
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
print('Plotting Data ...\n')
Data = np.loadtxt('D:\exercise\machine-learning-ex1\machine-learning-ex1\ex1\ex1data2.txt', delimiter=',')
X &#