# Tabular Classification

Tabular classification is the task of classifying a target category (a group) based on set of attributes.

Glucose | Blood Pressure | Skin Thickness | Insulin | BMI |
---|---|---|---|---|

148 | 72 | 35 | 0 | 33.6 |

150 | 50 | 30 | 0 | 35.1 |

141 | 60 | 29 | 1 | 39.2 |

Diabetes |
---|

1 |

1 |

0 |

## About Tabular Classification

## About the Task

Tabular classification is the task of assigning a label or class given a limited number of attributes. For example, the input can be data related to a customer (balance of the customer, the time being a customer, or more) and the output can be whether the customer will churn from the service or not. There are three types of categorical variables:

- Binary variables: Variables that can take two values, like yes or no, open or closed. The task of predicting binary variables is called binary classification.
- Ordinal variables: Variables with a ranking relationship, e.g., good, insignificant, and bad product reviews. The task of predicting ordinal variables is called ordinal classification.
- Nominal variables: Variables with no ranking relationship among them, e.g., predicting an animal from their weight and height, where categories are cat, dog, or bird. The task of predicting nominal variables is called multinomial classification.

## Use Cases

### Fraud Detection

Tabular classification models can be used in detecting fraudulent credit card transactions, where the features could be the amount of the transaction and the account balance, and the target to predict could be whether the transaction is fraudulent or not. This is an example of binary classification.

### Churn Prediction

Tabular classification models can be used in predicting customer churn in telecommunication. An example dataset for the task is hosted here.

## Model Hosting and Inference

You can use the skops library to share, explore, and use `scikit-learn`

models on the Hugging Face Hub. `skops`

models have widgets to try the models on the browser and have descriptive reports (also known as model cards) in their repositories. You can pull a `scikit-learn`

model like below using `skops`

:

```
from skops import hub_utils
import joblib
hub_utils.download(repo_id="user-name/my-awesome-model", dst=target_path)
model = joblib.load(Path(target_path)/"model.pkl")
model.predict(sample)
```

## Useful Resources

- Check out the scikit-learn organization to learn more about different algorithms used for this task.
- Skops documentation
- Skops announcement blog

### Training your own model in just a few seconds

We have built a baseline trainer application to which you can drag and drop your dataset. It will train a baseline and push it to your Hugging Face Hub profile with a model card containing information about the model.

## Compatible libraries

Scikit-learnNo example widget is defined for this task.

Note Contribute by proposing a widget for this task !

Note Breast cancer prediction model based on decision trees.

Note Binary classification dataset based on a census on income.

Note Multi-class dataset on iris flower species.

- accuracy
- Accuracy is the proportion of correct predictions among the total number of cases processed. It can be computed with: Accuracy = (TP + TN) / (TP + TN + FP + FN) Where: TP: True positive TN: True negative FP: False positive FN: False negative

- recall
- Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN is the false negatives.

- precision
- Precision is the fraction of correctly labeled positive examples out of all of the examples that were labeled as positive. It is computed via the equation: Precision = TP / (TP + FP) where TP is the True positives (i.e. the examples correctly labeled as positive) and FP is the False positive examples (i.e. the examples incorrectly labeled as positive).

- f1
- The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall)