Skip to content

Commit

Permalink
Added Project details
Browse files Browse the repository at this point in the history
  • Loading branch information
am-3 committed Dec 8, 2022
1 parent cec10eb commit 3124047
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 8 deletions.
160 changes: 152 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,170 @@
# Project: Machine Learning Framework

## Contributors: Atharva More & Virendra Panchal
## Team: Atharva More & Virendra Panchal

Project for OOPs Lab



### Methodoly:
### Problem Statement

#### Inputs:
Building a framework for Machine Learning as a library.

Demonstrating using House Price Prediction example.





### UML

![uml](E:\Academics\2021-_BTech\002.BTECH-IIITT\3. Sem III\CS208Project-MLframework\imgs\uml.jpeg)





### Assumptions

Input data is given in csv format.

Input data is numeric in nature.

Input data has last column/field as its result/target.





### Methodology

##### Inputs:

CSV file with n columns; of which n-1 are features and the nth column is target.

Linear Regression model is created that predicts the house price of user given features.


##### Training the model:

To train the model, Stochastic Gradient Descent algorithm is applied. In this algorithm, one datapoint is taken at a time for training the model. Appropriate weights are multiplied with the features and added up along with bias.

![gdgif](E:\Academics\2021-_BTech\002.BTECH-IIITT\3. Sem III\CS208Project-MLframework\imgs\gradient_descent_gif.gif)

This gives the predicted value. The loss between true and predicted values is calculated. Further to reduce the loss, first the gradient of the loss is obtained *(which is the derivate of the loss function with respect to the weights and bias)* and then the obtained gradients are multiplied with the learning rate; and subtracted from the corresponding weights and bias.



##### Result:

A Linear Regression model is created that predicts the house price with user given features.



#### Terminologies and techniques used:

![lr](E:\Academics\2021-_BTech\002.BTECH-IIITT\3. Sem III\CS208Project-MLframework\imgs\linear_regression_graph2.png)

**Linear Regression:** Linear Regression is a linear approach for modelling the relationship between a scalar response and one or more explanatory variables (also known as dependent and independent variables). Basically, we plot all the datapoints on a graph and initially a random line (y = mx + c) is drawn which may or may not pass through all the points. The goal is to make the line pass through majority of the datapoints. For that loss is calculated which is the sum of the difference of the actual value and the predicted value (y) of all datapoints. This loss is reduced by changing the parameters of the line (m and c). Finally, a value of m and c is reached such that the loss value doesn't decrease further. This value gives the best line possible.
Here, m is called weight as every feature does have some weightage to the predicted value and c is called bias.

#### Training the model:-

To train the model Stochastic Gradient Descent algorithm is applied. In this one datapoint is taken at a time for training. Appropriate weights are multiplied with the features and added up alog with bias. This gives the predicted value. The loss is calculated and to reduce the loss, first the gradient of the loss is obtained which is the derivate of the loss function with respect to the weights and bias and these gradients are multiplied with the learning rate (how fast the model should learn) and subtracted from the corresponding weights and bias.
**Learning Rate: ** How fast/slow the model should correct itself to minimise the loss between actual and predicted values.

**Gradient Overshooting:-** While training the gradient may or may not overshoot i.e. take a much larger value than expected. So to avoid that we use gradient clipping to make the gradient remain within a range of values.

**Testing the model:-** For testing the model, the user enters the feature values which are then multiplied with their corresponding weights and added up along with the bias. This gives the predicted value.


#### Testing the model:

For testing the model, the user enters the feature values accordingly. These are then multiplied with their corresponding weights and added up along with the bias. This gives the predicted result value.





### Usage

Ensure that the g++ compiler and git is set up in your machine.

You can check if it is ready to go by running ,

```shell
> g++
```

and seeing a similar output on the console.

![g++](E:\Academics\2021-_BTech\002.BTECH-IIITT\3. Sem III\CS208Project-MLframework\imgs\usuage_g++.png)



Now open a terminal/command prompt instance where you want to store the code.

```shell
> cd `target directory`
```

**Note**: Ensure that this directory is empty.



Now let's grab the code from GitHub,

```shell
> git clone https://github.com/am-3/MLframework.git .
```

The code along with the sample datasets will be downloaded.



Let's compile the binaries,

```shell
> g++ Stochastic_Gradient_Descent.cpp -o SGD.exe `output name inplace of SGD`
```



Finally, to execute

On Linux,

```shell
> ./SGD.exe
```



On Windows,

```shell
> .\SGD.exe
```





### Sample Output

![output](E:\Academics\2021-_BTech\002.BTECH-IIITT\3. Sem III\CS208Project-MLframework\imgs\output.png)





### Sample Dataset

| Area | Location | Bedrooms | Price |
| ---- | -------- | -------- | -------- |
| 400 | 1 | 1 | 6200000 |
| 1000 | 1 | 2 | 9500000 |
| 1245 | 1 | 2 | 14900000 |
| 1183 | 1 | 2 | 14000000 |
| 1245 | 1 | 2 | 3600000 |
| 495 | 1 | 1 | 6400000 |
| 495 | 1 | 1 | 3800000 |
| 1050 | 1 | 2 | 15500000 |
| 600 | 1 | 1 | 7000000 |
| 600 | 1 | 1 | 6694000 |
| .... 7190 more rows |
Binary file added imgs/gradient_descent_gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/linear_regression_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/linear_regression_graph2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/usuage_g++.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3124047

Please sign in to comment.