From 1ac1c89c2f6a91f9c3d0cbf5ebc7e01c51e90ff4 Mon Sep 17 00:00:00 2001 From: Aditya Agashe Date: Fri, 25 Oct 2019 17:47:32 +0530 Subject: [PATCH] Create housePrice.py A neural network that predicts the price of a house according to a simple formula. So, imagine if house pricing was as easy as a house costs 50k + 50k per bedroom, so that a 1 bedroom house costs 100k, a 2 bedroom house costs 150k, etc. How would you create a neural network that learns this relationship so that it would predict a 7 bedroom house as costing close to 400k etc? Hint: Your network might work better if you scale the house price down. You don't have to give the answer 400...it might be better to create something that predicts the number 4, and then your answer is in the 'hundreds of thousands', etc. --- Artificial Neural Network/housePrice.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Artificial Neural Network/housePrice.py diff --git a/Artificial Neural Network/housePrice.py b/Artificial Neural Network/housePrice.py new file mode 100644 index 0000000..f82a8e1 --- /dev/null +++ b/Artificial Neural Network/housePrice.py @@ -0,0 +1,9 @@ +import tensorflow as tf +import numpy as np +from tensorflow import keras +model =tf.keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])]) +model.compile(optimizer='sgd',loss='mean_squared_error') +xs = np.array([-1.0,0,1.0,2.0,3.0,4.0,5.0,6.0],dtype = float) +ys = np.array([0,0.5,1.0,1.5,2.0,2.5,3.0,3.5], dtype = float) +model.fit(xs,ys,epochs=500) +print(model.predict([7.0]))