Posts

Showing posts from June, 2024

A Single Layer Perceptron for Regression: Part 5

     New Function created: calculate_rsquare :  This function calculates the R-square value. This value helps understand the accuracy of the model. It is used for both single and multiple linear regression. However, adjusted R-square works better for the latter.   Parameters :  (1) predicted_output(numpy array (m,1)): Predicted output values.                       (2) actual_output(numpy array (m,1)) : The original output values.                       (3) num_of_predictor_variables (int): Number of predictor variables.                       (4) mean_of_output(float or string) : The mean of the actual output values. If it is                                                                                       "default", then the mean has to be calculated.                                                                                      Otherwise it is passed.                      (5) adjusted_r2(Boolean): By default is False. It can be made True if Adjusted R-             

A Single Layer Perceptron for Regression: Part 4

 Testing - Observations, Rectifications, and Plans 1) Adding a second condition to end epochs: Till now, the only condition in the loop was that the difference between the errors of 2 consecutive epochs had to be within the threshold value. This created an issue when the error value kept going up with each epoch. I, hence, added another condition that checks if the current value is 0.2 values higher than the previous error. If yes, then the loop breaks. Reason to use 0.2: While experimenting with the dataset, 0.2 gave the best results. I hope to:      a) Change 0.2 to an argument.      b) Experiment with more datasets to find a more appropriate value to use. 2)    Need to add Accuracy metric: Currently, the code, only shows the error. However, I would like to add the R squared value as a metric to see how good the model is w.r.t. accuracy. Code   The new version of the code can be found on this link:  https://github.com/HridayaAnnuncio247/Single-Layer-Perceptron Dataset Used For Testin