How to use
To load and use this traffic prediction model in Python:
import joblib
from huggingface_hub import hf_hub_download
import pandas as pd
repo_id = "Waleed74/traffic-prediction-pk"
# Download model & encoder
model_path = hf_hub_download(repo_id=repo_id, filename="traffic_classifier.pkl")
encoder_path = hf_hub_download(repo_id=repo_id, filename="target_encoder.pkl")
# Load them
model = joblib.load(model_path)
target_encoder = joblib.load(encoder_path)
feature_names = model.feature_names_in_
print("Feature names:", feature_names)
# Example input row
row = [
18, # Time
2, # Day of the week
320, # CarCount
150, # BikeCount
20, # BusCount
10, # TruckCount
500, # Total
0 # Traffic Situation
]
df = pd.DataFrame([row], columns=feature_names)
prediction = model.predict(df)
predicted_label = target_encoder.inverse_transform(prediction)[0]
print("Predicted Traffic Status:", predicted_label)
- Downloads last month
- -