Spaces:
Sleeping
Sleeping
File size: 1,185 Bytes
ec8033f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# app/recommender.py
import pandas as pd
import json
def recommend_plans(bill_file, customer_type):
"""
Recommend SME or Enterprise plans based on usage patterns.
"""
# Load plan data
if customer_type == "SME":
plans = pd.read_csv("data/plans_sme.csv")
elif customer_type == "Enterprise":
plans = pd.read_csv("data/plans_enterprise.csv")
else:
return pd.DataFrame([{"message": "No plans available for this customer type"}])
# Load bill data (simulate usage capture for now)
try:
if bill_file.name.endswith(".json"):
bill_data = json.load(bill_file)
else:
bill_data = {"lines": 10, "data_usage_gb": 50, "current_cost": 500}
except:
bill_data = {"lines": 10, "data_usage_gb": 50, "current_cost": 500}
# Simple matching logic: filter plans based on number of lines / data usage
recommended = plans[
(plans["min_lines"] <= bill_data["lines"]) &
(plans["max_lines"] >= bill_data["lines"])
]
recommended = recommended.sort_values(by="price_per_line")
return recommended[["plan_name", "price_per_line", "data_quota_gb", "notes"]].head(5)
|