基于flask打造的深度学习API,帮助你快速发布部署神经网络, 实现训练或测试模型, 框架目前支持多种机器学习与深度学习模型的构建。
模型 | 接口 |
---|---|
随机森林 | http://127.0.0.1:5000/model/random_forest |
XGBoost | http://127.0.0.1:5000/model/xgboost |
K-Means | http://127.0.0.1:5000/model/k_means |
KNN | http://127.0.0.1:5000/model/knn |
POST参数 | 具体值 |
---|---|
dataset | 数据集文件名(str) |
parameter | 模型的入参(dict) |
模型的入参(dict) | 具体值 |
---|---|
predict | 预测的属性(表格字段名) |
learning_rate | 学习率(1 - 0.01) |
test_data_ratio | 测试集的比例(1 - 0.01) |
batch_size | batch大小(512 - 16) |
Endpoint:
Method: POST
Type: RAW
URL: http://127.0.0.1:5000/model/xgboost
Body:
{
"dataset": "diabetes_binary_health_indicators_BRFSS2015.csv",
"parameter": {
"predict": "Diabetes_binary",
"learning_rate": 0.1
}
}
Endpoint:
Method: GET
Type: RAW
URL: http://127.0.0.1:5000/model/predict
{
"model": "D:/SourceCode/PythonCode/DeepLearningAPI/saves/test.model",
"data": {
"HighBP": 1,
"HighChol": 1,
"CholCheck": 1,
"BMI": 30,
"Smoker": 1,
"Stroke": 1,
"HeartDiseaseorAttack": 1,
"PhysActivity": 1,
"Fruits": 0,
"Veggies": 0,
"HvyAlcoholConsump": 0,
"AnyHealthcare": 1,
"NoDocbcCost": 0,
"GenHlth": 4,
"MentHlth": 0,
"PhysHlth": 20,
"DiffWalk": 1,
"Sex": 1,
"Age": 68,
"Education": 3,
"Income": 1
}
}
{
"data": {
"HighBP": 1,
"HighChol": 1,
"CholCheck": 1,
"BMI": 30,
"Smoker": 1,
"Stroke": 1,
"HeartDiseaseorAttack": 1,
"PhysActivity": 1,
"Fruits": 0,
"Veggies": 0,
"HvyAlcoholConsump": 0,
"AnyHealthcare": 1,
"NoDocbcCost": 0,
"GenHlth": 4,
"MentHlth": 0,
"PhysHlth": 20,
"DiffWalk": 1,
"Sex": 1,
"Age": 7,
"Education": 3,
"Income": 1
}
}
{
"data": {
"0": {
"precision": 0.0,
"recall": 0.0,
"f1-score": 0.0,
"support": 0
},
"1": {
"precision": 1.0,
"recall": 0.6443878633566731,
"f1-score": 0.783741935483871,
"support": 14139
},
"accuracy": 0.6443878633566731,
"macro avg": {
"precision": 0.5,
"recall": 0.32219393167833654,
"f1-score": 0.3918709677419355,
"support": 14139
},
"weighted avg": {
"precision": 1.0,
"recall": 0.6443878633566731,
"f1-score": 0.783741935483871,
"support": 14139
}
}
}
Endpoint:
Method: POST
Type: RAW
URL: http://127.0.0.1:5000/dataset
Body:
{
"name": "test.csv",
"data": [
{
"address": "华山路31号",
"addressExtend": "屯溪老街"
},
{
"address": "金城镇 珠山82号",
"addressExtend": "101"
}
]
}
precision recall f1-score support
0 0.88 0.97 0.93 43552
1 0.56 0.21 0.31 7184
accuracy 0.86 50736
macro avg 0.72 0.59 0.62 50736
weighted avg 0.84 0.86 0.84 50736
precision recall f1-score support
0 0.88 0.97 0.92 43552
1 0.53 0.24 0.33 7184
accuracy 0.86 50736
macro avg 0.71 0.60 0.63 50736
weighted avg 0.84 0.86 0.84 50736
precision recall f1-score support
<=50K 0.92 0.82 0.87 4942
>50K 0.58 0.79 0.67 1571
accuracy 0.81 6513
macro avg 0.75 0.80 0.77 6513
weighted avg 0.84 0.81 0.82 6513