Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -47,13 +47,10 @@ def predict_sales():
|
|
| 47 |
input_data = pd.DataFrame([sample])
|
| 48 |
|
| 49 |
# Make prediction (get log_sales)
|
| 50 |
-
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
# Convert predicted_sales to Python float
|
| 56 |
-
predicted_sales = round(float(predicted_price), 2)
|
| 57 |
# The conversion above is needed as we convert the model prediction (log price) to actual price using np.exp, which returns predictions as NumPy float32 values.
|
| 58 |
# When we send this value directly within a JSON response, Flask's jsonify function encounters a datatype error
|
| 59 |
|
|
|
|
| 47 |
input_data = pd.DataFrame([sample])
|
| 48 |
|
| 49 |
# Make prediction (get log_sales)
|
| 50 |
+
predictions = model.predict(input_data)[0]
|
| 51 |
|
| 52 |
+
# Round predictions
|
| 53 |
+
predicted_sales = [round(float(x), 2) for x in predictions]
|
|
|
|
|
|
|
|
|
|
| 54 |
# The conversion above is needed as we convert the model prediction (log price) to actual price using np.exp, which returns predictions as NumPy float32 values.
|
| 55 |
# When we send this value directly within a JSON response, Flask's jsonify function encounters a datatype error
|
| 56 |
|