Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,22 +38,16 @@ with col1:
|
|
| 38 |
with col2:
|
| 39 |
input_data['day'] = st.slider("Day", 1, 31)
|
| 40 |
input_data['month'] = st.slider("Month", 1, 12, value=6)
|
| 41 |
-
input_data['year'] = st.number_input("Year", 2018, 2020, value=2020)
|
| 42 |
|
| 43 |
-
# Create a button to
|
| 44 |
if st.button("Predict"):
|
| 45 |
# Feature Scaling
|
| 46 |
numerical_cols = ['day', 'month', 'year', 'shop_id', 'item_id', 'item_price', 'item_category_id']
|
| 47 |
-
|
| 48 |
-
input_df = pd.DataFrame(input_data, index=[0])
|
| 49 |
-
input_df_scaled = scaler.transform(input_df[numerical_cols])
|
| 50 |
-
input_df_scaled = pd.DataFrame(input_df_scaled, columns=numerical_cols)
|
| 51 |
-
|
| 52 |
-
# Fit the model
|
| 53 |
-
rf_model.fit(input_df_scaled)
|
| 54 |
|
| 55 |
# Make predictions using the trained model
|
| 56 |
-
predictions = rf_model.predict(
|
| 57 |
|
| 58 |
# Display the predicted sales value to the user
|
| 59 |
st.write("The predicted sales are:", predictions[0])
|
|
|
|
| 38 |
with col2:
|
| 39 |
input_data['day'] = st.slider("Day", 1, 31)
|
| 40 |
input_data['month'] = st.slider("Month", 1, 12, value=6)
|
| 41 |
+
input_data['year'] = st.number_input("Year", 2018, 2020, value=2020, step=1)
|
| 42 |
|
| 43 |
+
# Create a button to make a prediction
|
| 44 |
if st.button("Predict"):
|
| 45 |
# Feature Scaling
|
| 46 |
numerical_cols = ['day', 'month', 'year', 'shop_id', 'item_id', 'item_price', 'item_category_id']
|
| 47 |
+
input_df = pd.DataFrame(input_data, index=[0])[numerical_cols]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Make predictions using the trained model
|
| 50 |
+
predictions = rf_model.predict(input_df)
|
| 51 |
|
| 52 |
# Display the predicted sales value to the user
|
| 53 |
st.write("The predicted sales are:", predictions[0])
|