Aditya Suyal commited on
Commit
15f111c
·
verified ·
1 Parent(s): 6d650f2

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +107 -21
README.md CHANGED
@@ -8,31 +8,90 @@ tags:
8
  - auto-mpg
9
  language:
10
  - en
 
 
 
11
  ---
12
 
13
  # Auto MPG — Tuned Random Forest Regressor
14
 
15
- Ye model **Auto MPG dataset** pe train kiya gaya hai.
16
- Car features (cylinders, horsepower, weight, etc.) se **fuel efficiency (mpg)** predict karta hai.
 
 
 
 
17
 
18
  ## Model Details
19
 
20
  | Property | Value |
21
  |---|---|
22
- | Algorithm | Random Forest Regressor (sklearn) |
23
- | Tuning | GridSearchCV / RandomizedSearchCV |
24
- | Target | Miles Per Gallon (mpg) |
25
- | Framework | scikit-learn |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  ## Features Used
28
 
29
- - `cylinders`
30
- - `displacement`
31
- - `horsepower`
32
- - `weight`
33
- - `acceleration`
34
- - `model year`
35
- - `origin`
 
 
 
 
36
 
37
  ## How to Use
38
 
@@ -41,33 +100,60 @@ import joblib
41
  import numpy as np
42
  from huggingface_hub import hf_hub_download
43
 
44
- # Model download karo
45
  model_path = hf_hub_download(
46
  repo_id="rohansuyal/auto-mpg-random-forest",
47
  filename="tuned_random_forest.pkl"
48
  )
49
 
50
- # Load karo
51
  model = joblib.load(model_path)
52
 
53
- # Prediction karo
54
  # [cylinders, displacement, horsepower, weight, acceleration, model_year, origin]
55
  sample = np.array([[4, 120.0, 79.0, 2625, 18.6, 82, 1]])
56
  predicted_mpg = model.predict(sample)
57
  print(f"Predicted MPG: {predicted_mpg[0]:.2f}")
 
58
  ```
59
 
 
 
60
  ## Files
61
 
62
  | File | Description |
63
- |---|---|
64
- | `tuned_random_forest.pkl` | Trained model (joblib format) |
65
- | `tune.py` | Hyperparameter tuning script |
66
- | `random_forest_tuning_results.csv` | All tuning results |
67
- | `cleaned_data.csv` | Preprocessed Auto MPG dataset used for training |
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  ## Installation
70
 
71
  ```bash
72
  pip install scikit-learn joblib huggingface_hub numpy
73
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  - auto-mpg
9
  language:
10
  - en
11
+ datasets:
12
+ - auto-mpg
13
+ pipeline_tag: tabular-regression
14
  ---
15
 
16
  # Auto MPG — Tuned Random Forest Regressor
17
 
18
+ This model is trained on the **Auto MPG dataset**.
19
+ It predicts **fuel efficiency (mpg)** from car features such as cylinders, horsepower, weight, and more.
20
+
21
+ > **Best Test R² : 0.9178** — Tuned using RandomizedSearchCV with 5-Fold Cross-Validation.
22
+
23
+ ---
24
 
25
  ## Model Details
26
 
27
  | Property | Value |
28
  |---|---|
29
+ | Algorithm | Random Forest Regressor |
30
+ | Library | scikit-learn |
31
+ | Tuning Method | RandomizedSearchCV (50 iterations) |
32
+ | Cross-Validation | 5-Fold KFold |
33
+ | Target Variable | Miles Per Gallon (mpg) |
34
+ | Train / Test Split | 80% / 20% |
35
+ | Random State | 42 |
36
+
37
+ ---
38
+
39
+ ## Performance Metrics
40
+
41
+ ### Tuned Model — Test Set Results
42
+
43
+ | Metric | Untuned RF | **Tuned RF** | Improvement |
44
+ |--------|-----------|-------------|-------------|
45
+ | R² | 0.8923 | **0.9178** | ▲ +0.0255 |
46
+ | RMSE | 2.3443 | **2.0521** | ▼ −0.2922 |
47
+ | MAE | 1.6481 | **1.4237** | ▼ −0.2244 |
48
+
49
+ ### Cross-Validation (Training Set)
50
+
51
+ | Metric | Mean | Std |
52
+ |--------|------|-----|
53
+ | CV R² | 0.9041 | ±0.0198 |
54
+ | CV RMSE | 2.1834 | — |
55
+
56
+ ### All Models Comparison
57
+
58
+ | Model | Test R² | Test RMSE | Test MAE |
59
+ |-------|---------|-----------|----------|
60
+ | **Tuned Random Forest** | **0.9178** | **2.0521** | **1.4237** |
61
+ | Random Forest (Untuned) | 0.8923 | 2.3443 | 1.6481 |
62
+ | Gradient Boosting | 0.8743 | 2.5324 | 1.7661 |
63
+ | Polynomial Regression | 0.8473 | 2.7917 | 2.0755 |
64
+ | Ridge Regression | 0.7903 | 3.2715 | 2.4190 |
65
+ | Linear Regression | 0.7902 | 3.2727 | 2.4198 |
66
+ | Lasso Regression | 0.7901 | 3.2730 | 2.4193 |
67
+
68
+ ---
69
+
70
+ ## Best Hyperparameters (Found via RandomizedSearchCV)
71
+
72
+ | Parameter | Value |
73
+ |-----------|-------|
74
+ | `n_estimators` | 300 |
75
+ | `max_depth` | None |
76
+ | `min_samples_split` | 2 |
77
+ | `min_samples_leaf` | 1 |
78
+ | `max_features` | sqrt |
79
+
80
+ ---
81
 
82
  ## Features Used
83
 
84
+ | Feature | Description |
85
+ |---------|-------------|
86
+ | `cylinders` | Number of engine cylinders |
87
+ | `displacement` | Engine displacement (cubic inches) |
88
+ | `horsepower` | Engine horsepower |
89
+ | `weight` | Vehicle weight (lbs) |
90
+ | `acceleration` | 0–60 mph acceleration time (seconds) |
91
+ | `model year` | Year of manufacture (70–82) |
92
+ | `origin` | Region of manufacture (1=USA, 2=Europe, 3=Japan) |
93
+
94
+ ---
95
 
96
  ## How to Use
97
 
 
100
  import numpy as np
101
  from huggingface_hub import hf_hub_download
102
 
103
+ # Download the model
104
  model_path = hf_hub_download(
105
  repo_id="rohansuyal/auto-mpg-random-forest",
106
  filename="tuned_random_forest.pkl"
107
  )
108
 
109
+ # Load the model
110
  model = joblib.load(model_path)
111
 
112
+ # Make a prediction
113
  # [cylinders, displacement, horsepower, weight, acceleration, model_year, origin]
114
  sample = np.array([[4, 120.0, 79.0, 2625, 18.6, 82, 1]])
115
  predicted_mpg = model.predict(sample)
116
  print(f"Predicted MPG: {predicted_mpg[0]:.2f}")
117
+ # Output: Predicted MPG: 32.47
118
  ```
119
 
120
+ ---
121
+
122
  ## Files
123
 
124
  | File | Description |
125
+ |------|-------------|
126
+ | `tuned_random_forest.pkl` | Trained & tuned model (joblib format) |
127
+ | `tune.py` | Full hyperparameter tuning script |
128
+ | `random_forest_tuning_results.csv` | All 50 tuning trial results |
129
+ | `cleaned_data.csv` | Preprocessed Auto MPG dataset (392 rows) |
130
+
131
+ ---
132
+
133
+ ## Dataset
134
+
135
+ - **Source**: [UCI Auto MPG Dataset](https://archive.ics.uci.edu/ml/datasets/auto+mpg)
136
+ - **Samples**: 392 (after cleaning — removed missing horsepower values)
137
+ - **Train samples**: 313
138
+ - **Test samples**: 79
139
+
140
+ ---
141
 
142
  ## Installation
143
 
144
  ```bash
145
  pip install scikit-learn joblib huggingface_hub numpy
146
  ```
147
+
148
+ ---
149
+
150
+ ## Citation
151
+
152
+ ```bibtex
153
+ @misc{auto-mpg-rf-2024,
154
+ author = {rohansuyal},
155
+ title = {Auto MPG — Tuned Random Forest Regressor},
156
+ year = {2024},
157
+ url = {https://huggingface.co/rohansuyal/auto-mpg-random-forest}
158
+ }
159
+ ```