Instructions to use lucasomac/mlp-tabular-binary-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use lucasomac/mlp-tabular-binary-classifier with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://lucasomac/mlp-tabular-binary-classifier") - Notebooks
- Google Colab
- Kaggle
MLP tabular binary classifier (Keras)
A small Multilayer Perceptron (16-8-1) for binary classification of noisy tabular sensor data, trained with a leakage-safe preprocessing pipeline (per-column imputation + scaling fitted on the training split only). Built as part of an Artificial Intelligence course at UDESC (Brazil).
- Code, notebooks and full write-up: https://github.com/lucasomac0/ann-classification-machine-learning
- Paper (SBC format, Portuguese):
docs/relatorio.pdfin the GitHub repository
Model description
| Architecture | Dense(16, ReLU, L2 0.001) β Dense(8, ReLU, L2 0.001) β Dense(1, sigmoid) |
| Loss / optimizer | Binary cross-entropy / Adam |
| Training | batch size 64, up to 100 epochs, early stopping on val_loss (patience 15, best weights restored), 20% of the training set held out for validation |
| Preprocessing | ColumnTransformer: mean / median / KNN (k=5) / mode imputation chosen per column, then StandardScaler; the categorical environment column is ordinal-encoded (cold=0, mild=1, hot=2) |
| Output | probability of the positive class; predicted class = probability β₯ 0.5 |
Intended use and limitations
This is an educational / portfolio model. It is not intended for real decisions.
- The dataset has 10,000 samples, 10 numeric features, 1 categorical feature, 4%β15% missing values per column and outliers. Feature-target linear correlations are weak (about 0.2β0.3 in absolute value).
- Accuracy is around 81% and did not improve with more capacity or different preprocessing (see below). The paper discusses this as consistent with an information limit in the features, but that is a hypothesis, not a proof.
- Each variant was trained once and evaluated on one test split, so differences of about 1 percentage point are within sampling noise.
How to use
The repository expects two files: the trained network (model.keras) and the fitted preprocessor (preprocessor.joblib). New data must have the same columns as the training data, with environment already ordinal-encoded.
import joblib
import keras
import pandas as pd
from huggingface_hub import hf_hub_download
repo = "lucasomac/mlp-tabular-binary-classifier"
model = keras.saving.load_model(hf_hub_download(repo, "model.keras"))
preprocessor = joblib.load(hf_hub_download(repo, "preprocessor.joblib"))
X_new = pd.DataFrame(...) # same columns as the training features
proba = model.predict(preprocessor.transform(X_new)).ravel()
pred = (proba >= 0.5).astype(int)
Evaluation
Held-out test set: 2,000 samples (991 class 0, 1,009 class 1), stratified split, test set used only once for the final evaluation. Version 1.2 is the model published here.
| Version | Change | Accuracy (95% Wilson CI) | Sensitivity | Specificity | F1 |
|---|---|---|---|---|---|
| 1.1 | 16-8-1, L2, StandardScaler, ordinal encoding | 81.60% (79.8β83.2) | 81.67% | 81.53% | 81.75% |
| 1.2 | one-hot encoding of environment |
81.00% (79.2β82.7) | 82.56% | 79.41% | 81.43% |
| 1.3 | RobustScaler | 80.55% (78.8β82.2) | 81.17% | 79.92% | 80.81% |
| 1.4 | 64-32-16, BatchNorm, Dropout 0.2, swish (no L2) | 81.30% (79.5β82.9) | 80.77% | 81.84% | 81.34% |
- Downloads last month
- -
Evaluation results
- accuracy on base_classificacao_binaria (held-out test split)self-reported0.810
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://lucasomac/mlp-tabular-binary-classifier")