C1W1 Assignment: Housing Prices#

  • base cost 50k

  • 50k each bedroom

  • 1 bedroom 100k

  • scale 100,000 to 1

import tensorflow as tf
import numpy as np
def house_model():

    xs = np.arange(1, 7)
    ys = 0.5 * xs + 0.5
    
    model = tf.keras.Sequential([
        tf.keras.layers.Dense(1, input_shape=(1,))])

    model.compile(optimizer='sgd', loss='mse')
    
    model.fit(xs, ys, epochs=1000)
    
    return model
model = house_model()
new_y = 7.0
prediction = model.predict([new_y])[0]
print(prediction)
1/1 [==============================] - 0s 92ms/step
[4.008728]