File size: 3,417 Bytes
7126060
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
language:
- en
metrics:
- accuracy
- precision
- recall
- f1
- roc_auc
pipeline_tag: tabular-classification
tags:
- classification
- traffic
---

# Model Card for Infinitode/TAPM-OPEN-ARC

Repository: https://github.com/Infinitode/OPEN-ARC/

## Model Description

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.

**Architecture**:

- **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`.
- **Framework**: XGBoost
- **Training Setup**: Trained without extra training params.

## Uses

- Identifying potential accident-prone or high-risk areas.
- Enhancing preventive measures for traffic accidents and improving road safety.
- Researching traffic safety.

## Limitations

- May produce implausible or inappropriate results when affected by extreme outlier values.  
- Might offer inaccurate predictions regarding the likelihood of an accident; caution is recommended when interpreting these outputs.

## Training Data

- Dataset: Traffic Accident Prediction 💥🚗 dataset from Kaggle.
- Source URL: https://www.kaggle.com/datasets/denkuznetz/traffic-accident-prediction
- Content: Weather conditions, road types, time of day, and other factors, along with the occurrence or absence of an accident.
- Size: 798 entries of traffic data.
- Preprocessing: Mapped all string values to numeric values and dropped missing values. SMOTE was used to balance class imbalances.

## Training Procedure

- Metrics: accuracy, precision, recall, F1, ROC-AUC
- Train/Testing Split: 80% train, 20% testing.

## Evaluation Results

| Metric | Value |
| ------ | ----- |
| Testing Accuracy | 85.2% |
| Testing Weighted Average Precision | 87% |
| Testing Weighted Average Recall | 85% |
| Testing Weighted Average F1 | 85% |
| Testing ROC-AUC | 82.5% |

## How to Use

```python
import random

def test_random_samples(model, X_test, y_test, n_samples=5):
    """
    Selects random samples from the test set, makes predictions, and compares with actual values.
    
    Parameters:
    - model: Trained XGBoost classifier.
    - X_test: Feature set for testing.
    - y_test: True labels for testing.
    - n_samples: Number of random samples to test.
    
    Returns:
    None
    """
    # Convert X_test and y_test to DataFrame for easier indexing
    X_test_df = X_test.reset_index(drop=True)
    y_test_df = y_test.reset_index(drop=True)

    # Pick random indices
    random_indices = random.sample(range(len(X_test)), n_samples)
    
    print("Testing on Random Samples:")
    for idx in random_indices:
        sample = X_test_df.iloc[idx]
        true_label = y_test_df.iloc[idx]
        
        # Predict using the model
        prediction = model.predict(sample.values.reshape(1, -1))
        
        # Output results
        print(f"Sample Index: {idx}")
        print(f"Features: {sample.values}")
        print(f"True Label: {true_label}, Predicted Label: {prediction[0]}")
        print("-" * 40)

# Example usage
test_random_samples(xgb, X_test, y_test)
```

## Contact

For questions or issues, open a GitHub issue or reach out at https://infinitode.netlify.app/forms/contact.