Download py_test.py from abuer/modelabuer: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/abuer/modelabuer/resolve/main/py_test.py
- Command line
-
hf download hf://abuer/modelabuer/py_test.py
-
curl -L -o py_test.py https://huggingface.co/abuer/modelabuer/resolve/main/py_test.py
1.2 kB
| # ### 脚本结构介绍 | |
| # 每个脚本都主要由两个函数构成:`validate`函数和`score`函数。 | |
| import sys | |
| import pandas as pd | |
| import numpy as np | |
| from sklearn.metrics import roc_curve,auc | |
| def validate(submit_file, test_file, options=True): | |
| submission = pd.read_csv(submit_file,sep =',',dtype={'Prediction':str}) | |
| ground_truth = pd.read_csv(test_file,sep=',') | |
| #### duplicate ID | |
| if len(np.unique(submission['ID'])) != len(submission['ID']) : | |
| raise Exception('Duplicate ID in answer File!') | |
| #### ID not matched (the length of the ID column of the two files should be the same) | |
| if len(np.intersect1d(submission['ID'],ground_truth['ID'])) != len(ground_truth['ID']): | |
| raise Exception('ID column of two files not matched!') | |
| #### prediction should be decimal | |
| var = submission['Prediction'].apply(lambda x : x.isdigit()).any() | |
| if var == True: | |
| raise Exception('Prediction column only accepts float number!') | |
| return { | |
| 'code':0, | |
| 'message':'validation success' | |
| } | |
| if __name__ == '__main__': | |
| submit_file = sys.argv[1] | |
| test_file = sys.argv[2] | |
| print(validate(submit_file, test_file,options=True)) |