Views
No views yet
StandardScaler trước khi đưa vào mô hình.[Điền R2 Test vào đây] (Ví dụ: 0.771)[Điền RMSE Test vào đây] (Ví dụ: 4.486 phút)[Điền MAE Test vào đây] (Ví dụ: 3.544 phút)[Điền MAPE Test vào đây] (Ví dụ: 15.21%)huggingface_hub hoặc joblib.1import joblib
2from huggingface_hub import hf_hub_download
3import pandas as pd
4
5# Tải mô hình XGBoost
6model_path = hf_hub_download(repo_id="your-username/Time-Delivery-Prediction-XGBoost", filename="best_xgb_model.joblib")
7model = joblib.load(model_path)
8
9# Tải bộ chuẩn hóa StandardScaler
10scaler_path = hf_hub_download(repo_id="your-username/Time-Delivery-Prediction-XGBoost", filename="scaler.joblib")
11scaler = joblib.load(scaler_path)
12
13print("Đã tải mô hình và scaler thành công!")X1 đến X17), sau đó chuẩn hóa chúng bằng scaler trước khi đưa vào model.1# Dữ liệu mẫu (chưa chuẩn hóa) cho 1 đơn hàng mới
2# Đảm bảo thứ tự cột giống với dữ liệu huấn luyện
3new_data_raw = pd.DataFrame([{
4 'X1': 30, # Delivery_person_Age
5 'X2': 4.5, # Delivery_person_Ratings
6 'X3': 12.913, # Restaurant_latitude
7 'X4': 77.683, # Restaurant_longitude
8 'X5': 13.043, # Delivery_location_latitude
9 'X6': 77.813, # Delivery_location_longitude
10 'X7': 1, # Vehicle_condition (Trung bình)
11 'X8': 1, # multiple_deliveries (1 đơn ghép)
12 'X9': 10, # Time_Waiting_minutes
13 'X10': 18, # Time_Order_Hour
14 'X11': 18, # Time_Picked_Hour
15 'X12': 2, # Road_traffic_density_Label (High)
16 'X13': 1, # Weatherconditions_Label (Ví dụ: Rainy)
17 'X14': 0, # Festival_Label (No)
18 'X15': 1, # City_Label (Ví dụ: Metropolitian)
19 'X16': 0, # Type_of_order_Label (Ví dụ: Snack)
20 'X17': 1 # Type_of_vehicle_Label (Ví dụ: Scooter)
21}])
22
23# Chuẩn hóa dữ liệu đầu vào mới
24new_data_scaled = scaler.transform(new_data_raw)
25
26# Thực hiện dự đoán
27predicted_time = model.predict(new_data_scaled)
28
29print(f"Thời gian giao hàng dự đoán: {predicted_time[0]:.2f} phút")best_xgb_model.joblib: Mô hình XGBoost đã huấn luyện.scaler.joblib: Bộ chuẩn hóa StandardScaler.README.md: File mô tả này.[Điền thông tin liên hệ của bạn vào đây, ví dụ: email, LinkedIn]