๐ Keras Neural Network — House Price Prediction
Learn Regression with a Simple Dataset + Copy & Execute Python
๐ 1. What are we going to predict?
In this example, a neural network learns the relationship between house size and house price.
| House Size (sq ft) | Price (₹ lakh) |
|---|---|
| 500 | 20 |
| 600 | 24 |
| 700 | 28 |
| 800 | 32 |
| 900 | 36 |
| 1000 | 40 |
| 1100 | 44 |
| 1200 | 48 |
๐ง 2. How the Neural Network Works
Input
Output
The model receives house size as input. During training it changes its internal weights until its predicted prices become close to the actual prices.
๐ป 3. Keras Python Code
The editor lets students copy and edit the real Keras/TensorFlow program. The browser execution button runs a lightweight Python demonstration of the same regression idea using Pyodide, because loading the complete TensorFlow/Keras runtime directly into a normal webpage is very large.
๐ข 4. Mathematics Behind the Model
z = wx + b
ReLU:
ReLU(z) = max(0,z)
Here w represents the weight, x represents the input house size and b is the bias.
MSE = (1/n) ฮฃ(y − ลท)²
The optimizer tries to reduce this error by adjusting the neural network's weights and biases.
⚙️ 5. Important Keras Commands
| Command | Purpose |
|---|---|
keras.Sequential() |
Creates a sequential neural network |
model.compile() |
Defines optimizer, loss and metrics |
model.fit() |
Trains the neural network |
model.predict() |
Generates predictions for new data |
๐ฏ 6. What Should the Model Learn?
Looking at the training data, the relationship is approximately:
Therefore, for a 750 sq ft house:
A properly trained neural network should therefore produce a prediction close to ₹30 lakh.
๐ 7. Complete Learning Process
This process repeats for many epochs until the model learns a useful relationship between input and output.
No comments:
Post a Comment