Instructions to use rmaitest/mlmodel2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use rmaitest/mlmodel2 with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("rmaitest/mlmodel2", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Upload house_price_prediction.py with huggingface_hub
Browse files- house_price_prediction.py +20 -0
house_price_prediction.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import joblib
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
def predict_price(size, bedrooms, age):
|
| 5 |
+
"""Predicts house price based on input features."""
|
| 6 |
+
# Load the model
|
| 7 |
+
model = joblib.load("house_price_model.pkl")
|
| 8 |
+
|
| 9 |
+
# Create a DataFrame from user input
|
| 10 |
+
input_data = pd.DataFrame({
|
| 11 |
+
'Size (sq ft)': [size],
|
| 12 |
+
'Number of Bedrooms': [bedrooms],
|
| 13 |
+
'Age of House (years)': [age]
|
| 14 |
+
})
|
| 15 |
+
|
| 16 |
+
# Predict the price using the trained model
|
| 17 |
+
predicted_price = model.predict(input_data)[0]
|
| 18 |
+
|
| 19 |
+
# Return the prediction
|
| 20 |
+
return {"predicted_price": predicted_price}
|