Usage Example
Installation
pip install huggingface_hub
Loading the Model
from huggingface_hub import hf_hub_download
import pickle
model_path = hf_hub_download(
repo_id="RayyanAhmed9477/house-price-prediction-model",
filename="house_price_model.pkl"
)
with open(model_path, 'rb') as f:
model_data = pickle.load(f)
Making Predictions
import pandas as pd
input_data = pd.DataFrame([{
"property_type": "House",
"location": "DHA Defence",
"city": "Lahore",
"baths": 3,
"purpose": "For Sale",
"bedrooms": 4,
"Area_in_Marla": 5.0
}])
for col in ["property_type", "location", "city", "purpose"]:
if col in model_data["label_encoders"]:
le = model_data["label_encoders"][col]
try:
input_data[col] = le.transform([str(input_data[col].iloc[0])])
except ValueError:
input_data[col] = le.transform([le.classes_[0]])
prediction = model_data["model"].predict(input_data[model_data["feature_columns"]])[0]
print(f"Predicted Price: {prediction}")