소스 검색

feat:添加评估结果分析脚本

zhaohaipeng 6 달 전
부모
커밋
0ac68326e7
1개의 변경된 파일6개의 추가작업 그리고 7개의 파일을 삭제
  1. 6 7
      ad/model_predict_analyse.py

+ 6 - 7
ad/model_predict_analyse.py

@@ -7,17 +7,16 @@ from hdfs import InsecureClient
 client = InsecureClient("http://master-1-1.c-7f31a3eea195cb73.cn-hangzhou.emr.aliyuncs.com:9870", user="spark")
 
 
-def read_predict(hdfs_path):
-    dir = "/dw/recommend/model/34_ad_predict_data/20241004_351_0927_1003_1000/"
-    for file in client.list(dir):
-        with client.read(dir + file, encoding="utf-8") as reador:
+def read_predict(hdfs_path: str):
+    for file in client.list(hdfs_path):
+        with client.read(hdfs_path + file, encoding="utf-8") as reador:
             with gzip.GzipFile(fileobj=reador, mode="rb") as gz_file:
-                content = gz_file.read().decode("utf-8")
-                print(f"Content of {file}:\n {content}")
+                content = gz_file.read()
+                print(f"Content of {hdfs_path + file}:\n {content}")
 
 
 def _main():
-    read_predict("")
+    read_predict("/dw/recommend/model/34_ad_predict_data/20241004_351_0927_1003_1000/")
 
 
 if __name__ == '__main__':