Total Pageviews

Monday, August 31, 2026

🏠 ANN Example: House Price Prediction

🏠 ANN Example: House Price Prediction

Use House Size, Number of Bedrooms and House Age to predict the price of a house using an Artificial Neural Network.

1. What is ANN?

An Artificial Neural Network (ANN) is a machine-learning model consisting of interconnected neurons.

Each neuron receives inputs, multiplies them by weights, adds a bias, and processes the result using an activation function.

In this example, the ANN performs a regression task. Instead of predicting YES or NO, it predicts a numerical value: house price.

House Size Bedrooms House Age Predicted Price

2. Example House Data

Feature Actual Value Normalized Value
House Size 1500 sq.ft 0.75
Bedrooms 3 0.60
House Age 10 years 0.20
Why normalize?

Different features can have very different numerical ranges. Normalization puts them on a comparable scale before the ANN processes them.

X₁ = House Size = 0.75
X₂ = Bedrooms = 0.60
X₃ = House Age = 0.20

3. ANN Architecture

INPUT LAYER
House Size
X₁ = 0.75
Bedrooms
X₂ = 0.60
House Age
X₃ = 0.20
OUTPUT LAYER
Predicted
House Price

The input features move through the hidden layer and finally reach the output neuron.

4. Step-by-Step Mathematical Calculation

Click each button to understand how the ANN calculates the predicted house price.

1 Identify the Inputs

The ANN receives three normalized input values:

X₁ = House Size = 0.75
X₂ = Bedrooms = 0.60
X₃ = House Age = 0.20

These inputs are passed to the hidden neuron.

2 Assign Weights and Bias

Suppose the hidden neuron H₁ has the following learned parameters:

W₁ = 0.60
W₂ = 0.30
W₃ = -0.20
Bias = 0.10

Notice that the weight for house age is negative. In this simplified example, this means increasing house age contributes negatively to the neuron's calculation.

3 Calculate the Weighted Sum

The basic neuron equation is:

Z = X₁W₁ + X₂W₂ + X₃W₃ + b

Substitute the values:

Z = (0.75 × 0.60) + (0.60 × 0.30) + (0.20 × -0.20) + 0.10

Calculate each multiplication:

0.75 × 0.60 = 0.450
0.60 × 0.30 = 0.180
0.20 × -0.20 = -0.040

Add the values:

Z = 0.450 + 0.180 - 0.040 + 0.100

Z = 0.690

Therefore: Weighted Sum = 0.690

4 Apply Activation Function

For this teaching example, we use the sigmoid function:

Sigmoid(z) = 1 / (1 + e-z)

We have:

Z = 0.690

Therefore:

H₁ = 1 / (1 + e-0.690)

Approximately:

e-0.690 ≈ 0.502

H₁ ≈ 1 / (1 + 0.502)

H₁ ≈ 0.666

The hidden neuron therefore produces approximately: 0.666.

5 Calculate the Output

Suppose the output neuron has:

Output Weight = 2.00
Output Bias = 0.20

The output neuron calculates:

Y = (H₁ × Output Weight) + Output Bias

Substitute:

Y = (0.666 × 2.00) + 0.20

Calculate:

0.666 × 2.00 = 1.332

Y = 1.332 + 0.20

Y = 1.532

The ANN's normalized output is therefore: 1.532.

6 Convert to House Price

Suppose our simplified normalization scheme represents 1.00 = ₹50 lakh.

Predicted Price = Normalized Output × ₹50 lakh

Substitute:

Predicted Price = 1.532 × ₹50 lakh
Predicted Price = ₹76.6 lakh
🏠 Predicted House Price ≈ ₹76.6 Lakh
Important:

This is a classroom demonstration. A real house-price ANN would use properly defined feature scaling, a suitable output layer, a real training dataset, and parameters learned from that data.

5. Complete ANN Mathematical Flow

INPUT

House Size = 0.75
Bedrooms = 0.60
House Age = 0.20


WEIGHTED SUM
Z = (0.75 × 0.60) + (0.60 × 0.30) + (0.20 × -0.20) + 0.10
Z = 0.690


SIGMOID ACTIVATION
H₁ ≈ 0.666


OUTPUT
Y = (0.666 × 2.00) + 0.20
Y = 1.532


PRICE CONVERSION
1.532 × ₹50 lakh


🏠 PREDICTED PRICE ≈ ₹76.6 LAKH

6. Important ANN Terms

Input Layer Hidden Layer Output Layer Neuron Weight Bias Weighted Sum Activation Function Sigmoid Regression Prediction

Key idea: In regression, an ANN can produce a continuous numerical prediction, such as house price, rather than a simple class such as PASS/FAIL.

No comments:

Post a Comment