Skip to content

Commit ade65da

Browse files
authored
Merge pull request #5 from JEENB/pdf
pdf & models email integration left
2 parents d572fff + 86e7cea commit ade65da

File tree

11 files changed

+50
-13
lines changed

11 files changed

+50
-13
lines changed

__pycache__/models.cpython-39.pyc

-2.74 KB
Binary file not shown.

models.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def reg_training_model(df, degree = 1, split_ratio = 0.2, email ="dummy"):
7272

7373

7474
##-------------------------------------------------
75-
#---------- Accuracy vs Predicted -----------------
75+
#---------- Ac vs Predicted -----------------
7676
##-------------------------------------------------
7777

7878
# x axis = actual
@@ -86,11 +86,12 @@ def reg_training_model(df, degree = 1, split_ratio = 0.2, email ="dummy"):
8686
y_= min(min(y_test), min(y_test_pred), min(y_train), min(y_train_pred))
8787
x = np.linspace(y_,y,1000)
8888
plt.plot(x,x, color = "g")
89-
89+
plt.xlabel("Actual Results")
90+
plt.ylabel("Predicted Results")
9091
plt.legend(loc='upper left')
9192
plt.title("Actual VS Predicted")
9293
plt.savefig("server_data/actual_pred.png")
93-
plt.show()
94+
9495

9596

9697
##------------------------------------
@@ -102,7 +103,7 @@ def reg_training_model(df, degree = 1, split_ratio = 0.2, email ="dummy"):
102103
plt.ylabel("Mean Square Error")
103104
plt.title("Comparing Errors")
104105
plt.savefig("server_data/compare_error.png")
105-
plt.show()
106+
106107

107108

108109
##-------------------------------------------------
@@ -119,20 +120,21 @@ def reg_training_model(df, degree = 1, split_ratio = 0.2, email ="dummy"):
119120
plt.legend(loc='upper left')
120121
plt.title("Residual VS Predicted")
121122
plt.savefig("server_data/residual_pred.png")
122-
plt.show()
123+
123124

124125

125126

126127
##-------------------------------------------------
127128
#---------- Normal Q- Q----------------------------
128129
##-------------------------------------------------
129-
fig, (ax1, ax2) = plt.subplot(1,2, figsize=(10,6))
130+
fig, (ax1, ax2) = plt.subplots(1,2, figsize=(10,6))
130131
fig.suptitle('Normal Q-Q')
131-
ax1 = sm.qqplot(residual_train, line='45', color ='b')
132+
sm.qqplot(residual_train, line='45', ax = ax1)
132133
ax1.set_title("Train")
133-
ax2 = sm.qqplot(residual_test, line='45', color = 'r')
134-
plt.show()
135-
136-
134+
ax1.set_ylabel("Standard Residual")
135+
sm.qqplot(residual_test, line='45', ax = ax2)
136+
ax2.set_title("Test")
137+
ax2.set_ylabel("Standard Residual")
138+
plt.savefig("server_data/residual_pred.png")
137139
return 0
138140

received.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ x,y
9999
50.039575939875988,85.232007342325673
100100
48.149858891028863,66.224957888054632
101101
25.128484647772304,53.454394214850524
102+
22.23, 21.23

report/2.png

945 KB
Loading

report/create_report.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,46 @@ def create_report():
6666
section("Results")
6767

6868
section("1. Polynomial Fitting")
69-
pdf.image("neworignial.jpeg",50,140,w=120, h = 72)
69+
pdf.image("./server_data/fitting.png",50,140,w=120, h = 72)
7070
pdf.ln(84)
7171
multi_line("The above figure represents the regression line being fitted to the training instances. If the regression line passes through all the points then the polynomial degree chosen overfits the data. Similarly, if the line does not touch even a single point, you might be underfitting the training instances.")
7272

73-
73+
pdf.add_page()
74+
section("2. Actual vs Predicted")
75+
pdf.image("./server_data/actual_pred.png",50,20,w=120, h = 72)
76+
pdf.ln(84)
77+
multi_line("The above scatter plot represents the spread of predicted and actual scores. Assuming out model perfectly fits the data we can expect the points spread across the y = x line.")
78+
line("")
7479

80+
81+
section("3. Residual vs Predicted")
82+
pdf.image("./server_data/actual_pred.png",50,140,w=120, h = 72)
83+
pdf.ln(84)
84+
line("Residual = h(x) - f(x)")
85+
line("where,")
86+
line("h(x) is the predicted value and f(x) is the actual value")
87+
line("")
88+
multi_line("The fitted vs residuals plot is mainly useful for investigating: Whether linearity holds. This is indicated by the mean residual value for every fitted value region being close to 0. In R this is indicated by the red line being close to the dashed line. Whether homoskedasticity holds. The spread of residuals should be approximately the same across the x-axis. Whether there are outliers. This is indicated by some extreme residuals that are far from the rest.")
89+
90+
91+
pdf.add_page()
92+
section("4. Mean Squared Error")
93+
pdf.image("./server_data/compare_error.png",50,20,w=120, h = 72)
94+
pdf.ln(80)
95+
multi_line("The mean squared error is calculated as the sum of differences in actual and predicted result squared. The lower the MSE the better the model performs.")
96+
line("")
97+
98+
section("4. Normal Q-Q Plots")
99+
pdf.image("./server_data/normalqq.png",50,125,w=120, h = 72)
100+
pdf.ln(75)
101+
line("")
102+
multi_line("The Q-Q plot, or quantile-quantile plot, is a graphical tool to help us assess if a set of data plausibly came from some theoretical distribution such as a Normal or exponential. For example, if we run a statistical analysis that assumes our dependent variable is Normally distributed, we can use a Normal Q-Q plot to check that assumption. It's just a visual check, not an air-tight proof, so it is somewhat subjective. But it allows us to see at-a-glance if our assumption is plausible, and if not, how the assumption is violated and what data points contribute to the violation.")
103+
line('')
104+
multi_line("A Q-Q plot is a scatterplot created by plotting two sets of quantiles against one another. If both sets of quantiles came from the same distribution, we should see the points forming a line that's roughly straight. Here's an example of a Normal Q-Q plot when both sets of quantiles truly come from Normal distributions.")
105+
106+
pdf.add_page()
107+
pdf.image("./report/2.png",0,0,width)
108+
75109
pdf.output("./server_data/report.pdf", 'F')
76110

77111

server_data/actual_pred.png

2.25 KB
Loading

server_data/compare_error.png

-548 Bytes
Loading

server_data/fitting.png

162 Bytes
Loading

server_data/normalqq.png

19.9 KB
Loading

server_data/report.pdf

808 KB
Binary file not shown.

server_data/residual_pred.png

6.44 KB
Loading

0 commit comments

Comments
 (0)