Tabular Regression
Scikit-learn
Joblib
Indonesian
gradient-boosting
regression
salary-prediction
tabular
Instructions to use Minee12/ds-salary-gradient-boosting with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Minee12/ds-salary-gradient-boosting with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Minee12/ds-salary-gradient-boosting", "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
Download inference.py from Minee12/ds-salary-gradient-boosting: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/Minee12/ds-salary-gradient-boosting/resolve/main/inference.py
- Command line
-
hf download hf://Minee12/ds-salary-gradient-boosting/inference.py
-
curl -L -o inference.py https://huggingface.co/Minee12/ds-salary-gradient-boosting/resolve/main/inference.py
1.37 kB
| import json | |
| import joblib | |
| import pandas as pd | |
| BERKAS = ["model_final.joblib", "preprocessing_config.json"] | |
| def muat_model(repo_id): | |
| from huggingface_hub import hf_hub_download | |
| p = {nama: hf_hub_download(repo_id=repo_id, filename=nama) for nama in BERKAS} | |
| with open(p["preprocessing_config.json"]) as f: | |
| config = json.load(f) | |
| return {"model": joblib.load(p["model_final.joblib"]), "config": config} | |
| def siapkan_fitur(data_mentah, bundel): | |
| cfg = bundel["config"] | |
| df = data_mentah.copy() if isinstance(data_mentah, pd.DataFrame) else pd.DataFrame(data_mentah) | |
| kurang = [k for k in cfg["urutan_fitur_input"] if k not in df.columns] | |
| if kurang: | |
| raise ValueError("Kolom input berikut tidak ada: " + str(kurang)) | |
| df = df[cfg["urutan_fitur_input"]] | |
| for kol, valid in cfg["kategori_valid"].items(): | |
| asing = set(df[kol].astype(str)) - set(valid) | |
| if asing: | |
| raise ValueError("Nilai " + str(sorted(asing)) + " pada kolom '" + kol + "' tidak dikenal model. Nilai valid: " + str(valid)) | |
| return df | |
| def prediksi_gaji(data_mentah, bundel): | |
| # Mengembalikan prediksi gaji tahunan (USD) untuk satu atau beberapa baris data mentah. | |
| # Imputasi, encoding, dan scaling dilakukan otomatis oleh pipeline di dalam model. | |
| return bundel["model"].predict(siapkan_fitur(data_mentah, bundel)) | |