Date: 2025-12-02
Usage:
# enable model auto update, the default is false
lgbm-auto-update: true
# model auto update interval, the default is 72 (hours)
lgbm-update-interval: 72
# model update url
lgbm-url: "https://github.com/vernesong/mihomo/releases/download/LightGBM-Model/Model.bin"
profile:
#smart-collector-size: data collection file size, the default is 100 (MB)
smart-collector-size: 100
proxy-groups:
- name: Smart Group
type: smart
# policy-priority: <1 means lower priority, >1 means higher priority, the default is 1, pattern support regex and string
policy-priority: "Premium:0.9;SG:1.3"
# uselightgbm: use LightGBM model predict weight
uselightgbm: false
# collectdata: collect datas for model training
collectdata: false
# sample-rate: data acquisition rate, desirable values are 0-1, the default is 1
sample-rate: 1
# prefer-asn: force and lookup asn first when nodes select, the default is false
prefer-asn: true
...- LightGBM for weight prediction (option: uselightgbm: true),need Model.bin file exist HomeDir (.config/mihomo/Model.bin) or use in OpenClash: (/etc/openclash/Model.bin)
- Data collection function to facilitate for yourself-training of weight prediction models (option: collectdata: true), path in HomeDir (.config/mihomo/smart_weight_data.csv) or (/etc/openclash/smart_weight_data.csv) in OpenClash
- If you need to train the model yourself, you could use feature transforms and must training by LightGBM version 3.3.5
Api:
# Show proxy weight
curl -H 'Authorization: Bearer ${secret}' -X GET http://${controller-api}/group/${groupname}/weights
curl -H 'Authorization: Bearer ${secret}' -X GET http://${controller-api}/group/weights
# Flush cache data
curl -H 'Authorization: Bearer ${secret}' -X POST http://${controller-api}/cache/smart/flush
curl -H 'Authorization: Bearer ${secret}' -X POST http://${controller-api}/cache/smart/flush/${configname}
# Block(degrade) connections - node result to forceing choice another best
curl -H 'Authorization: Bearer ${secret}' -X DELETE http://${controller-api}/connections/smart/${id}
# LightGBM model upgrade
curl -H 'Authorization: Bearer ${secret}' -X POST http://${controller-api}/upgrade/lgbmPredicting performance (Large)
RMSE: 0.112809 MAE: 0.062751 R²: 0.915383
train_time=2025-11-29 19:57:01
rmse=0.112809
mae=0.062751
r2=0.915383
objective=regression;metric=rmse;verbosity=-1;boosting_type=gbdt;num_leaves=192;learning_rate=0.01;max_depth=12;max_bin=127;num_boost_round=1800;early_stopping_rounds=200;min_child_samples=2747;bagging_fraction=0.5102150110362053;feature_fraction=0.5023982332952471;lambda_l1=1.8479748799662192;lambda_l2=1.9936393011625715;min_split_gain=0.017478239767799095;bagging_freq=15;device=gpu;num_threads=2;gpu_use_dp=False;gpu_platform_id=0;gpu_device_id=0
data_shape=(2775498, 27)
weight_min=0.175958
weight_max=1.800000
weight_mean=1.029399
weight_std=0.387806
