I just started Tensorflow and am solving this problem but I am getting errors. The problem is that the base price for a house is 50k and each bedroom costs 50k each. So a 1 bedroom house is 100k, 2 bedroom is 150k and so on. We have to predict the cost of a 7 Bedroom house.
I have tried using 'import numpy as np' and also 'import numpy' but error still remains.
import tensorflow as tf
import numpy
from tensorflow import keras
def house_model(y_new):
xs = numpy.array([1.0,2.0,3.0,4.0], dtype = float)
ys = numpy.array([1.0,1.5,2.0,2.5], dtype = float)
model = tf.keras.Sequential([keras.layers.dense(units=1, input_shape=[1])])
model.compile(optimizer = 'sgd', loss = 'mean_squared_error')
model.fit(xs,ys,epochs = 500)
return model.predict(y_new)[7.0]
prediction = house_model([7.0])
print(prediction)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-23-55d468d60746> in <module>
----> 1 prediction = house_model([7.0])
2 print(prediction)
<ipython-input-20-0e67265afcf6> in house_model(y_new)
1 def house_model(y_new):
----> 2 xs = numpy.array([1.0,2.0,3.0,4.0], dtype = float)
3 ys = numpy.array([1.0,1.5,2.0,2.5], dtype = float)
4 model = tf.keras.Sequential([keras.layers.dense(units=1, input_shape=[1])])
5 model.compile(optimizer = 'sgd', loss = 'mean_squared_error')
NameError: name 'numpy' is not defined