Forest Cover Classifier
An educational scikit-learn model that classifies cartographic observations into the seven forest cover types in the UCI Covertype dataset. The repository packages the project-selected decision tree with the exact 54-feature schema and class labels needed for inference.
Model Description
The task is seven-class classification for 30 m x 30 m cells in four wilderness areas of Roosevelt National Forest, Colorado. The input contains 54 integer features: 10 cartographic measurements, 4 one-hot wilderness-area indicators, and 40 one-hot soil-type indicators. The output is a class id from 1 to 7 and its forest-cover label.
The original notebook uses the raw UCI values without scaling or other transformations. The required feature order is preserved in feature_schema.json. No raw dataset is redistributed in this repository.
Intended Use
Use this model for educational demonstrations, reproducibility checks, and experiments with classical tabular classification. It is not a production ecological monitoring system and should not be treated as a substitute for field data, expert review, or current environmental measurement.
How to Use
Install the dependencies from requirements.txt. For a row loaded from the UCI data file, pass a dictionary with the named features:
import pandas as pd
from inference import FEATURE_ORDER, predict
columns = FEATURE_ORDER + ["Cover_Type"]
row = pd.read_csv("covtype.data", header=None, names=columns).iloc[0]
print(predict(row[FEATURE_ORDER].to_dict()))
The helper also accepts a 54-value list in the exact order from feature_schema.json, or a pandas DataFrame containing those named columns. The command-line form is python inference.py --json '<JSON object>'.
Training
The notebook loaded all 581,012 rows of the UCI Covertype data, separated Cover_Type from the 54 predictors, and used train_test_split(test_size=0.2, random_state=42) for the model evaluations. The notebook also contains an earlier 30% split assignment that is immediately overwritten by the 20% split before training; the 20% split is therefore the one used for the reported results.
Three classical models were compared:
| Model | Notebook test accuracy |
|---|---|
| Logistic Regression | 68.74% |
K-Nearest Neighbors (n_neighbors=5) |
96.87% |
Decision Tree (random_state=42) |
93.90% |
The project selected the decision tree because it offered a useful balance of accuracy and computation time (the notebook reports about 8.8 seconds for its run). The uploaded artifact is that unpruned DecisionTreeClassifier(random_state=42) trained on the full training split.
Evaluation
The uploaded artifact was retrained from the public UCI covtype.data.gz file using the notebook's 20% holdout split and reproduced the notebook's 93.895% decision-tree accuracy.
| Metric | Test split |
|---|---|
| Accuracy | 0.93895 |
| Macro precision | 0.90343 |
| Macro recall | 0.89996 |
| Macro F1 | 0.90163 |
| Weighted precision | 0.93893 |
| Weighted recall | 0.93895 |
| Weighted F1 | 0.93894 |
Per-class results:
| Class | Label | Precision | Recall | F1 | Support |
|---|---|---|---|---|---|
| 1 | Spruce/Fir | 0.9386 | 0.9378 | 0.9382 | 42,557 |
| 2 | Lodgepole Pine | 0.9484 | 0.9478 | 0.9481 | 56,500 |
| 3 | Ponderosa Pine | 0.9271 | 0.9339 | 0.9305 | 7,121 |
| 4 | Cottonwood/Willow | 0.8472 | 0.8118 | 0.8291 | 526 |
| 5 | Aspen | 0.8385 | 0.8301 | 0.8343 | 1,995 |
| 6 | Douglas-fir | 0.8819 | 0.8862 | 0.8841 | 3,489 |
| 7 | Krummholz | 0.9423 | 0.9522 | 0.9472 | 4,015 |
Limitations
The data represents four wilderness areas in northern Colorado and may not generalize to other ecosystems, years, sensing conditions, or land-management regimes. Class frequencies are imbalanced, especially for classes 4 and 5. The evaluation uses one random holdout split and an unpruned decision tree; no calibration, pruning study, or broader hyperparameter search is included. The notebook's KNN accuracy is higher than the selected decision tree's accuracy, so the selection reflects the project's speed/accuracy tradeoff rather than the highest accuracy alone.
Source / Project
Source project: tanujranjith/ml-forest-cover-prediction-project on GitHub
Dataset: UCI Covertype, credited to Jock Blackard, DOI 10.24432/C50K5N. The UCI dataset is licensed CC BY 4.0; this repository does not redistribute the raw dataset. The GitHub source repository did not include a repository LICENSE file, so no separate model-repository license is asserted here.