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.49 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.49 kB
| import json | |
| import joblib | |
| import pandas as pd | |
| from huggingface_hub import hf_hub_download | |
| BERKAS = ["model_gb_tuned.joblib", "scaler.joblib", "model_columns.json", "preprocessing_config.json"] | |
| def muat_model(repo_id): | |
| p = {nama: hf_hub_download(repo_id=repo_id, filename=nama) for nama in BERKAS} | |
| return { | |
| "model": joblib.load(p["model_gb_tuned.joblib"]), | |
| "scaler": joblib.load(p["scaler.joblib"]), | |
| "columns": json.load(open(p["model_columns.json"])), | |
| "config": json.load(open(p["preprocessing_config.json"])), | |
| } | |
| def siapkan_fitur(data_mentah, bundel): | |
| cfg = bundel["config"] | |
| df = data_mentah.copy() if isinstance(data_mentah, pd.DataFrame) else pd.DataFrame(data_mentah) | |
| 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(f"Nilai {sorted(asing)} pada kolom '{kol}' tidak dikenal model. Nilai valid: {valid}") | |
| X = pd.get_dummies(df, columns=cfg["fitur_kategorikal"]) | |
| X = X.reindex(columns=bundel["columns"], fill_value=0).astype(float) | |
| if cfg.get("model_membutuhkan_scaling"): | |
| X[cfg["fitur_numerik"]] = bundel["scaler"].transform(X[cfg["fitur_numerik"]]) | |
| return X | |
| def prediksi_gaji(data_mentah, bundel): | |
| # Mengembalikan prediksi gaji tahunan (USD) untuk satu atau beberapa baris data mentah | |
| return bundel["model"].predict(siapkan_fitur(data_mentah, bundel)) | |