Question: Problem 1 . Boston house data . CRIM, RM , LSTAT, AGE . ( 5 0 ) ( 1 ) , . Google drive hw

Problem 1. Boston house data.
CRIM, RM, LSTAT, AGE .(50)
(1),. Google drive
hw1_bostonhouse.ipynb.(30)
(2) Cost function graph.(10)
(3) Scikit learn Linear regression library
.(10)
# HW1. House price prediction using linear regression
# import library
import tensorflow as tf
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
# X, Y
boston = pd.read_csv('Boston_house.csv')
X = boston[['CRIM','RM', 'LSTAT', 'AGE']]
y = boston[['Target']]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
X_train = np.array(X_train, dtype=np.float32)
X_test = np.array(X_test, dtype=np.float32)
y_train = np.array(y_train, dtype=np.float32)
y_test = np.array(y_test, dtype=np.float32)
# Model parameter
# .
# learning rate
# learning rate.
learning_rate =0.1
# Gradient descent
def gradientDescent():
with tf.GradientTape() as tape:
# (Gradient descent).
cost =[]
for step in range(10001):
gradientDescent()
pred = tf.matmul(X_test,W)+ b
cost_inst = tf.reduce_mean(tf.square(pred - y_test))
cost = np.append(cost, cost_inst)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!