C1W1 - Predicting house price based on multiple features


Course : DeepLearning.AI TensorFlow Developer

In course1 week1 , we are thought about house prediction prices but it is based on only single input feature that is based on number of bedrooms what is the house price.

How should we implement and build a model with input shape that should be based on multiple input features like area, floors, sq ft, number of bedrooms , bathrooms and do the prediction of house price ?

Any help would be great.


The input shape should reflect the number of input features in a row. There are 5 features:

  1. Area
  2. Floors
  3. Square footage
  4. Number of bedrooms
  5. Number of bathrooms

If you use a dense layer with 1 unit, it’ll be Dense(1, input_shape=[5])

To execute what was mentioned in ^ post

import numpy as np
import tensorflow as tf

# Processed Data format with correct input shape
x_train_input = tf.convert_to_tensor(np.array([
        [Area_House1, Floors_House1, SqFt_House1, NumBR_House1, NumBAR_House1], 
        [Area_House2, Floors_House2, SqFt_House2, NumBR_House2, NumBAR_House2], 
        [Area_House3, Floors_House3, SqFt_House3, NumBR_House3, NumBAR_House3], 
        .... etc 
y_train_input = tf.convert_to_tensor(np.array([House1_price, House2_price, House3_price ..... etc etc]))

# Model architecture as per suggested
model = tf.keras.models.Sequential([tf.keras.layers.Dense(1, input_shape=[5])])
model.compile(optimizer='sgd', loss='mean_squared_error')

# Model training
model.fit(x_train_input, y_train_Input, epochs=1000)

feel free to correct me if i’m wrong.