Skip to content

This block shows the process of forcasting a house price in Zetaforge

Notifications You must be signed in to change notification settings

zetane/block-forecasting-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Certainly! Here's a more detailed and structured README.md file:

# House Price Prediction Using Neural Network

This repository contains code to train and evaluate a neural network for predicting house prices using the California housing dataset. The model is implemented using PyTorch, and the data preprocessing is done with scikit-learn.

## Requirements

- Python 3.x
- PyTorch
- scikit-learn

You can install the required libraries using pip:

```bash
pip install torch scikit-learn

Code Overview

The main functionality is provided by the compute function, which trains and evaluates a neural network for regression prediction.

compute Function

def compute(epoch):
    """Trains and evaluates a neural network for regression prediction.

    Inputs:
        epoch (int): The number of training epochs.

    Outputs:
        result (dict): A dictionary containing the predicted house prices and the average loss.

    Requirements:
        PyTorch, scikit-learn
    """
    # Function implementation here...

test Function

The test function demonstrates how to use the compute function:

def test():
    """Test the compute function."""
    print("Running test")
    result = compute(epoch=100)
    print("Predictions:", result["predictions"])
    print("Average Loss:", result["avg_loss"])

test()

Data Loading and Preprocessing

The California housing dataset is loaded using scikit-learn's fetch_california_housing. The data is split into training and testing sets, and features are standardized using StandardScaler.

Neural Network Definition

A simple feedforward neural network is defined with one hidden layer.

Training

The model is trained using the Mean Squared Error (MSE) loss function and the Adam optimizer. Training progress is printed every 10 epochs.

Evaluation

The model is evaluated on the test set. Predictions and the average loss are returned.

Example Output

Running test
Epoch [10/100], Loss: 0.5241
Epoch [20/100], Loss: 0.4312
...
Epoch [100/100], Loss: 0.2289
Average loss on test data: 0.3012
Predictions: [2.511, 3.412, 1.911, ...]
Average Loss: 0.3012

About

This block shows the process of forcasting a house price in Zetaforge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published