|
|
import joblib |
|
|
import numpy as np |
|
|
import requests |
|
|
from io import BytesIO |
|
|
|
|
|
|
|
|
model_url = "https://huggingface.co/mahaqj/ml_assignment_3/resolve/main/best_model.joblib" |
|
|
scaler_url = "https://huggingface.co/mahaqj/ml_assignment_3/resolve/main/scaler.joblib" |
|
|
|
|
|
|
|
|
model_bytes = BytesIO(requests.get(model_url).content) |
|
|
model = joblib.load(model_bytes) |
|
|
|
|
|
|
|
|
scaler_bytes = BytesIO(requests.get(scaler_url).content) |
|
|
scaler = joblib.load(scaler_bytes) |
|
|
|
|
|
|
|
|
features = ["MedInc", "HouseAge", "AveRooms", "AveBedrms", "Population", "AveOccup", "Latitude", "Longitude"] |
|
|
|
|
|
|
|
|
print("Enter feature values!") |
|
|
user_input = [] |
|
|
for feature in features: |
|
|
val = float(input(f"Enter value for {feature}: ")) |
|
|
user_input.append(val) |
|
|
|
|
|
|
|
|
user_input = np.array(user_input).reshape(1, -1) |
|
|
user_input_scaled = scaler.transform(user_input) |
|
|
|
|
|
|
|
|
prediction = model.predict(user_input_scaled)[0] |
|
|
predicted_price = prediction * 100000 |
|
|
print(f"\nPredicted median house value: ${predicted_price:,.5f}") |