Download test_models.py from carywoods/mm: direct link, hf CLI and curl.
- Browser
- Download file 823 Bytes
-
https://huggingface.co/carywoods/mm/resolve/main/test_models.py
- Command line
-
hf download hf://carywoods/mm/test_models.py
-
curl -L -o test_models.py https://huggingface.co/carywoods/mm/resolve/main/test_models.py
823 Bytes
| import joblib | |
| import pandas as pd | |
| # Load models and pipeline | |
| model_rf = joblib.load("rf_model.joblib") | |
| model_gb = joblib.load("gb_model.joblib") | |
| model_lr = joblib.load("lr_model.joblib") | |
| pipeline = joblib.load("pipeline.joblib") | |
| # Create sample input | |
| sample = pd.DataFrame([{ | |
| 'MOTHER_AGE_GRP': '25–34', | |
| 'MOTHER_MARITALSTATUS_AT_BIRTH': 'Married', | |
| 'MOTHER_RESID_COUNTY_TYPE': 'Urban', | |
| 'SMOKING_DURING_PREG_IND': 'No', | |
| 'SMOKING_BEFORE_PREG_IND': 'No', | |
| 'NUM_BIRTHS_BY_MOTHER': 1, | |
| 'VISITS_IN_1ST_TRIMESTER_IND': 'Yes' | |
| }]) | |
| # Preprocess | |
| X = pipeline.transform(sample) | |
| # Predict | |
| print("Logistic Regression Probability:", model_lr.predict_proba(X)[0][1]) | |
| print("Random Forest Probability:", model_rf.predict_proba(X)[0][1]) | |
| print("Gradient Boosting Probability:", model_gb.predict_proba(X)[0][1]) | |