from datetime import datetime from utils.operate_csv import * from algs.alg0.utils.mama_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())