A from-scratch implementation of an Artificial Neuron (Perceptron) in C# without using any external Machine Learning libraries. This project models the relationship between house features (Number of Rooms, Distance to Center, Building Age) and their Rent prices using supervised learning.
This project demonstrates the fundamental mechanics of a neural network: input processing, weight initialization, activation functions, and backpropagation (weight updates). The goal is to predict house rents based on a small normalized dataset.
The model is trained on 15 samples and tested on 5 samples. Before processing, the data is normalized (e.g., Rooms/5, Distance/20, Age/30, Rent/10000) to keep values between 0 and 1.
| Feature | Description | Normalization Factor |
|---|---|---|
| Input 1 | Number of Rooms | / 5 |
| Input 2 | Distance to Center (km) | / 20 |
| Input 3 | Building Age (years) | / 30 |
| Target | Rent (₺) | / 10,000 |
This implementation explicitly programs the core math of a single neuron:
-
Summation Function (
$v$ ): Calculates the weighted sum:$v = \sum_{i=1}^{n} w_i x_i$ -
Activation Function (Sigmoid):
Maps the output between 0 and 1:
$y = \frac{1}{1 + e^{-v}}$ -
Weight Update Rule:
Adjusts weights based on error (
$t - y$ ) and learning rate ($\lambda$ ):$w_i = w_i + \lambda(t - y)x_i$ -
Error Evaluation (MSE):
Calculates the Mean Squared Error:
$MSE = \frac{1}{n} \sum (t - y)^2$
The program automatically runs multiple simulations to analyze how different Hyperparameters affect the model's performance:
- Feature Selection: Compares 3-input vs. 2-input (excluding Building Age) performance.
-
Learning Rates (
$\lambda$ ): Tests$0.05$ ,$0.01$ , and$0.1$ to find the best convergence. -
Epochs: Compares training results after
$25$ and$100$ cycles.
A final summary table is printed to the console, allowing for a detailed comparison of Mean Squared Error (MSE) across all test cases.
- Clone the repository.
- Open the
.slnfile in Visual Studio. - Build and Run to see step-by-step training progress and final evaluation tables.