Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,14 @@ import numpy as np
|
|
| 3 |
import joblib # For loading the serialized model
|
| 4 |
import pandas as pd # For data manipulation
|
| 5 |
from flask import Flask, request, jsonify # For creating the Flask API
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
# Initialize the Flask application
|
| 8 |
sales_predictor_api = Flask("Sales Predictor")
|
|
@@ -28,8 +36,9 @@ def predict_rental_price():
|
|
| 28 |
the predicted rental price as a JSON response.
|
| 29 |
"""
|
| 30 |
# Get the JSON data from the request body
|
|
|
|
| 31 |
property_data = request.get_json()
|
| 32 |
-
|
| 33 |
|
| 34 |
# Extract relevant features from the JSON data
|
| 35 |
sample = {
|
|
@@ -47,7 +56,7 @@ def predict_rental_price():
|
|
| 47 |
|
| 48 |
# Convert the extracted data into a Pandas DataFrame
|
| 49 |
input_data = pd.DataFrame([sample])
|
| 50 |
-
|
| 51 |
# Make prediction
|
| 52 |
predicted_sales = model.predict(input_data)[0]
|
| 53 |
|
|
|
|
| 3 |
import joblib # For loading the serialized model
|
| 4 |
import pandas as pd # For data manipulation
|
| 5 |
from flask import Flask, request, jsonify # For creating the Flask API
|
| 6 |
+
import logging
|
| 7 |
+
|
| 8 |
+
# Configure the logging
|
| 9 |
+
logging.basicConfig(
|
| 10 |
+
level=logging.INFO, # You can change to DEBUG for more details
|
| 11 |
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
| 12 |
+
)
|
| 13 |
+
logger = logging.getLogger(__name__)
|
| 14 |
|
| 15 |
# Initialize the Flask application
|
| 16 |
sales_predictor_api = Flask("Sales Predictor")
|
|
|
|
| 36 |
the predicted rental price as a JSON response.
|
| 37 |
"""
|
| 38 |
# Get the JSON data from the request body
|
| 39 |
+
logger.debug(f"predict_rental_price called")
|
| 40 |
property_data = request.get_json()
|
| 41 |
+
logger.debug(f"property data {property_data}")
|
| 42 |
|
| 43 |
# Extract relevant features from the JSON data
|
| 44 |
sample = {
|
|
|
|
| 56 |
|
| 57 |
# Convert the extracted data into a Pandas DataFrame
|
| 58 |
input_data = pd.DataFrame([sample])
|
| 59 |
+
logger.debug(f"input_data {input_data}")
|
| 60 |
# Make prediction
|
| 61 |
predicted_sales = model.predict(input_data)[0]
|
| 62 |
|