File size: 1,977 Bytes
117b368 6806c9f 117b368 |
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 |
from datetime import datetime
from utils.operate_csv import *
from utils.utils import *
from utils.app import *
# 从csv评估模型调优结果并将数据存入log
def eval_model_csv(csv_file_path='./data/temp/temp.csv'):
scores_predict = get_field_values(csv_file_path, "fashion_score_predict")
scores_true = get_field_values(csv_file_path, "fashion_score_true")
result = calculate_loss(scores_predict, scores_true)
data = count_model_csv(csv_file_path)
result.update(data)
result['date'] = datetime.now().strftime("%Y-%m-%d")
result['source'] = csv_file_path
append_to_csv(result, './data/suanfamama-fashion-guangzhou-dataset/log.csv')
# 从数据库评估模型调优结果并将数据存入log
def eval_model():
data = app_get_user()
scores_predict = [row["fashion_score_predict"] for row in data if "fashion_score_predict" in row]
scores_true = [row["fashion_score_true"] for row in data if "fashion_score_true" in row]
result = calculate_loss(scores_predict, scores_true)
result['date'] = datetime.now().strftime("%Y-%m-%d")
result['source'] = 'users'
append_to_csv(result, './data/suanfamama-fashion-guangzhou-dataset/log.csv')
# 计算需要统计的字段
def count_model_csv(csv_file_path='./data/temp/temp.csv'):
field_names = ['type', 'upper_garment', 'lower_garment', 'headgear',
'sock', 'shoe', 'accessory', 'backpack', 'scene',
'action', 'countenance', 'base_model']
results = {}
for field_name in field_names:
data = get_field_values(csv_file_path, field_name)
result = count_words_in_strings(data)
results[field_name] = result
return results
if __name__ == '__main__':
# eval_model_csv() # 从csv评估模型调优结果
# eval_model # 从数据库评估模型调优结果
print(datetime.now())
eval_model_csv("./data/suanfamama-fashion-guangzhou-dataset/20240731.csv")
print(datetime.now())
|