JohanBeytell commited on
Commit
7126060
·
verified ·
1 Parent(s): 9db7fd2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -3
README.md CHANGED
@@ -1,3 +1,110 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ metrics:
6
+ - accuracy
7
+ - precision
8
+ - recall
9
+ - f1
10
+ - roc_auc
11
+ pipeline_tag: tabular-classification
12
+ tags:
13
+ - classification
14
+ - traffic
15
+ ---
16
+
17
+ # Model Card for Infinitode/TAPM-OPEN-ARC
18
+
19
+ Repository: https://github.com/Infinitode/OPEN-ARC/
20
+
21
+ ## Model Description
22
+
23
+ OPEN-ARC-TAP is a straightforward XGBClassifier model developed as part of Infinitode's OPEN-ARC initiative. It was developed to assess the probability of traffic accidents by analyzing various external factors.
24
+
25
+ **Architecture**:
26
+
27
+ - **XGBClassifier**: `random_state=42`, `use_label_encoder=False`, `eval_metric='logloss'`, `colsample_bytree=0.8`, `learning_rate=0.01`, `max_depth=5`, `n_estimators=100`, `scale_pos_weight=1`, `subsample=0.8`.
28
+ - **Framework**: XGBoost
29
+ - **Training Setup**: Trained without extra training params.
30
+
31
+ ## Uses
32
+
33
+ - Identifying potential accident-prone or high-risk areas.
34
+ - Enhancing preventive measures for traffic accidents and improving road safety.
35
+ - Researching traffic safety.
36
+
37
+ ## Limitations
38
+
39
+ - May produce implausible or inappropriate results when affected by extreme outlier values.
40
+ - Might offer inaccurate predictions regarding the likelihood of an accident; caution is recommended when interpreting these outputs.
41
+
42
+ ## Training Data
43
+
44
+ - Dataset: Traffic Accident Prediction 💥🚗 dataset from Kaggle.
45
+ - Source URL: https://www.kaggle.com/datasets/denkuznetz/traffic-accident-prediction
46
+ - Content: Weather conditions, road types, time of day, and other factors, along with the occurrence or absence of an accident.
47
+ - Size: 798 entries of traffic data.
48
+ - Preprocessing: Mapped all string values to numeric values and dropped missing values. SMOTE was used to balance class imbalances.
49
+
50
+ ## Training Procedure
51
+
52
+ - Metrics: accuracy, precision, recall, F1, ROC-AUC
53
+ - Train/Testing Split: 80% train, 20% testing.
54
+
55
+ ## Evaluation Results
56
+
57
+ | Metric | Value |
58
+ | ------ | ----- |
59
+ | Testing Accuracy | 85.2% |
60
+ | Testing Weighted Average Precision | 87% |
61
+ | Testing Weighted Average Recall | 85% |
62
+ | Testing Weighted Average F1 | 85% |
63
+ | Testing ROC-AUC | 82.5% |
64
+
65
+ ## How to Use
66
+
67
+ ```python
68
+ import random
69
+
70
+ def test_random_samples(model, X_test, y_test, n_samples=5):
71
+ """
72
+ Selects random samples from the test set, makes predictions, and compares with actual values.
73
+
74
+ Parameters:
75
+ - model: Trained XGBoost classifier.
76
+ - X_test: Feature set for testing.
77
+ - y_test: True labels for testing.
78
+ - n_samples: Number of random samples to test.
79
+
80
+ Returns:
81
+ None
82
+ """
83
+ # Convert X_test and y_test to DataFrame for easier indexing
84
+ X_test_df = X_test.reset_index(drop=True)
85
+ y_test_df = y_test.reset_index(drop=True)
86
+
87
+ # Pick random indices
88
+ random_indices = random.sample(range(len(X_test)), n_samples)
89
+
90
+ print("Testing on Random Samples:")
91
+ for idx in random_indices:
92
+ sample = X_test_df.iloc[idx]
93
+ true_label = y_test_df.iloc[idx]
94
+
95
+ # Predict using the model
96
+ prediction = model.predict(sample.values.reshape(1, -1))
97
+
98
+ # Output results
99
+ print(f"Sample Index: {idx}")
100
+ print(f"Features: {sample.values}")
101
+ print(f"True Label: {true_label}, Predicted Label: {prediction[0]}")
102
+ print("-" * 40)
103
+
104
+ # Example usage
105
+ test_random_samples(xgb, X_test, y_test)
106
+ ```
107
+
108
+ ## Contact
109
+
110
+ For questions or issues, open a GitHub issue or reach out at https://infinitode.netlify.app/forms/contact.