7sugiwa commited on
Commit
13e1b1e
1 Parent(s): 9df8aa8

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +5 -5
  2. prediction.py +1 -2
app.py CHANGED
@@ -11,8 +11,7 @@ from eda import (average_sales_by_region, average_sales_and_profit_over_time,
11
  segment_vs_region_distribution, sales_vs_profit_across_segments,
12
  category_composition_for_profit_and_sales)
13
 
14
- # Load the model for predictions
15
- model = joblib.load('best_model.pkl')
16
 
17
  # Load the dataset for EDA
18
  @st.cache_data
@@ -68,8 +67,9 @@ elif selection == "Make a Prediction":
68
  'Sales', 'Discount', 'Quantity', 'Sub-Category'
69
  ])
70
 
71
- # Preprocess and predict (You'll need to adjust this part based on how your model expects input)
72
- # For example, you might need to transform 'input_features' to match the expected input format of your model
73
- predicted_profit = model.predict(input_features) # Adjust this line as necessary
74
 
 
75
  st.write(f'Predicted Profit: {predicted_profit:.2f}')
 
11
  segment_vs_region_distribution, sales_vs_profit_across_segments,
12
  category_composition_for_profit_and_sales)
13
 
14
+ from prediction import make_prediction
 
15
 
16
  # Load the dataset for EDA
17
  @st.cache_data
 
67
  'Sales', 'Discount', 'Quantity', 'Sub-Category'
68
  ])
69
 
70
+
71
+
72
+ predicted_profit = make_prediction(input_features) # Adjust this line as necessary
73
 
74
+
75
  st.write(f'Predicted Profit: {predicted_profit:.2f}')
prediction.py CHANGED
@@ -52,7 +52,6 @@ model = joblib.load('best_model.pkl')
52
  preprocessor = joblib.load('preprocessor.pkl')
53
 
54
  def make_prediction(input_features):
55
- encoded_features = preprocessor.transform(input_features)
56
- processed_features = pipeline.transform(encoded_features)
57
  prediction = model.predict(processed_features)
58
  return prediction[0]
 
52
  preprocessor = joblib.load('preprocessor.pkl')
53
 
54
  def make_prediction(input_features):
55
+ processed_features = pipeline.transform(input_features)
 
56
  prediction = model.predict(processed_features)
57
  return prediction[0]