Suchinthana commited on
Commit
26f2246
·
1 Parent(s): e989afe

Graph update

Browse files
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -29,26 +29,28 @@ 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 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()
 
29
  # Predicting on test set for comparison
30
  y_pred = model.predict(X_test)
31
 
32
+ # Plotting Wait vs Good
33
+ plt.figure(figsize=(12, 6))
34
 
35
+ # Scatter plot for Wait vs Good
36
+ plt.subplot(1, 2, 1)
37
+ plt.scatter(X_test.iloc[:, 1], y_test, color='blue', alpha=0.6, label='Actual Good Values') # X_test[:, 1] for wait
38
+ plt.scatter(wait, predicted_value, color='red', label=f'Input: Wait={wait}, Predicted Good={predicted_value:.2f}', zorder=5)
39
+ plt.title('Wait vs Good')
40
+ plt.xlabel('Wait')
41
+ plt.ylabel('Good')
42
+ plt.legend()
43
+ plt.grid(True)
44
+
45
+ # Plotting USA vs Good
46
+ plt.subplot(1, 2, 2)
47
+ plt.scatter(X_test.iloc[:, 3], y_test, color='blue', alpha=0.6, label='Actual Good Values') # X_test[:, 3] for usa
48
+ plt.scatter(usa, predicted_value, color='red', label=f'Input: USA={usa}, Predicted Good={predicted_value:.2f}', zorder=5)
49
+ plt.title('USA vs Good')
50
+ plt.xlabel('USA')
51
+ plt.ylabel('Good')
52
+ plt.legend()
53
+ plt.grid(True)
54
 
55
  # Adjust layout and save the plot
56
  plt.tight_layout()