Spaces:
Sleeping
Sleeping
Suchinthana
commited on
Commit
·
e989afe
1
Parent(s):
778ce34
Error correction
Browse files
app.py
CHANGED
@@ -29,44 +29,26 @@ def predict_and_plot(dirty, wait, lastyear, usa):
|
|
29 |
# Predicting on test set for comparison
|
30 |
y_pred = model.predict(X_test)
|
31 |
|
32 |
-
# Creating subplots for
|
33 |
-
fig, axs = plt.subplots(
|
34 |
|
35 |
# Plot dirty variable distribution with predicted value
|
36 |
-
axs[0
|
37 |
-
axs[0
|
38 |
-
axs[0
|
39 |
-
axs[0
|
40 |
-
axs[0
|
41 |
-
axs[0
|
42 |
-
axs[0
|
43 |
|
44 |
# Plot wait variable distribution with predicted value
|
45 |
-
axs[
|
46 |
-
axs[
|
47 |
-
axs[
|
48 |
-
axs[
|
49 |
-
axs[
|
50 |
-
axs[
|
51 |
-
axs[
|
52 |
-
|
53 |
-
# Plot lastyear variable distribution with predicted value
|
54 |
-
axs[1, 0].hist(X_test[:, 2], bins=30, color='gray', alpha=0.5, label='Lastyear Distribution')
|
55 |
-
axs[1, 0].axvline(lastyear, color='orange', linestyle='--', label='Input Value (Lastyear)')
|
56 |
-
axs[1, 0].axvline(predicted_value, color='red', linestyle='-', label='Predicted Value')
|
57 |
-
axs[1, 0].set_title('Distribution of Lastyear')
|
58 |
-
axs[1, 0].set_xlabel('Lastyear')
|
59 |
-
axs[1, 0].set_ylabel('Frequency')
|
60 |
-
axs[1, 0].legend()
|
61 |
-
|
62 |
-
# Plot usa variable distribution with predicted value
|
63 |
-
axs[1, 1].hist(X_test[:, 3], bins=30, color='gray', alpha=0.5, label='USA Distribution')
|
64 |
-
axs[1, 1].axvline(usa, color='orange', linestyle='--', label='Input Value (USA)')
|
65 |
-
axs[1, 1].axvline(predicted_value, color='red', linestyle='-', label='Predicted Value')
|
66 |
-
axs[1, 1].set_title('Distribution of USA')
|
67 |
-
axs[1, 1].set_xlabel('USA')
|
68 |
-
axs[1, 1].set_ylabel('Frequency')
|
69 |
-
axs[1, 1].legend()
|
70 |
|
71 |
# Adjust layout and save the plot
|
72 |
plt.tight_layout()
|
|
|
29 |
# Predicting on test set for comparison
|
30 |
y_pred = model.predict(X_test)
|
31 |
|
32 |
+
# Creating subplots for dirty and wait, showing predicted value
|
33 |
+
fig, axs = plt.subplots(1, 2, figsize=(12, 6))
|
34 |
|
35 |
# Plot dirty variable distribution with predicted value
|
36 |
+
axs[0].hist(X_test.iloc[:, 0], bins=30, color='gray', alpha=0.5, label='Dirty Distribution') # Use iloc for pandas DataFrame
|
37 |
+
axs[0].axvline(dirty, color='orange', linestyle='--', label='Input Value (Dirty)')
|
38 |
+
axs[0].axvline(predicted_value, color='red', linestyle='-', label='Predicted Value')
|
39 |
+
axs[0].set_title('Distribution of Dirty')
|
40 |
+
axs[0].set_xlabel('Dirty')
|
41 |
+
axs[0].set_ylabel('Frequency')
|
42 |
+
axs[0].legend()
|
43 |
|
44 |
# Plot wait variable distribution with predicted value
|
45 |
+
axs[1].hist(X_test.iloc[:, 1], bins=30, color='gray', alpha=0.5, label='Wait Distribution') # Use iloc for pandas DataFrame
|
46 |
+
axs[1].axvline(wait, color='orange', linestyle='--', label='Input Value (Wait)')
|
47 |
+
axs[1].axvline(predicted_value, color='red', linestyle='-', label='Predicted Value')
|
48 |
+
axs[1].set_title('Distribution of Wait')
|
49 |
+
axs[1].set_xlabel('Wait')
|
50 |
+
axs[1].set_ylabel('Frequency')
|
51 |
+
axs[1].legend()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# Adjust layout and save the plot
|
54 |
plt.tight_layout()
|