chore: delete load data function

需要全部自己实现😋
This commit is contained in:
2024-10-24 11:50:08 +08:00
parent 86193e0ef1
commit 8ee9f4a545
2 changed files with 13 additions and 23 deletions
+13 -13
View File
@@ -91,16 +91,6 @@ def evaluate_knn(
return 0.0
def load_data(file_path):
"""
加载 TSV 格式数据文件。
"""
data = np.loadtxt(file_path, delimiter="\t")
features = data[:, :-1]
labels = data[:, -1].astype(int)
return features, labels
def upload_score(name, id, score_data):
"""
上传成绩到服务器。
@@ -135,23 +125,33 @@ def upload_score(name, id, score_data):
def main(name, id):
user_code_file = "function.py" # 代码文件
user_function_name = "classify0" # KNN 函数名
user_load_data_functionname = "load_data" # 加载数据函数名
# 加载训练集和测试集
train_file = "datingTrainSet2.tsv"
test_file = "datingTestSet2.tsv"
train_data, train_labels = load_data(train_file)
test_data, test_labels = load_data(test_file)
# 加载自定义函数
log_details = []
try:
user_func = load_user_function(user_code_file, user_function_name)
user_load_data_func = load_user_function(
user_code_file, user_load_data_functionname
)
except Exception as e:
log_details.append(f"加载自定义函数时出错: {e}")
print("\n".join(log_details))
return
try:
train_data, train_labels = user_load_data_func(train_file)
test_data, test_labels = user_load_data_func(test_file)
except Exception as e:
print(f"加载数据集时出错: {e}")
print("请检查 load_dataset 函数是否正确!")
print("本次评测无效,记录不做提交!")
return
# 记录评估时间
start_time = time.time()
-10
View File
@@ -90,16 +90,6 @@ def evaluate_knn(
return 0.0
# def load_data(file_path):
# """
# 加载 TSV 格式数据文件。
# """
# data = np.loadtxt(file_path, delimiter="\t")
# features = data[:, :-1]
# labels = data[:, -1].astype(int)
# return features, labels
def upload_score(name, id, score_data):
"""
上传成绩到服务器。