generated from LufsX/Challenge-SVM
This commit is contained in:
@@ -90,6 +90,11 @@ def load_data(filepath):
|
||||
- np.array: 标签数据。
|
||||
"""
|
||||
data = np.loadtxt(filepath, delimiter=',', dtype=str)
|
||||
|
||||
# 检查数据的维度
|
||||
if data.ndim == 1:
|
||||
data = data.reshape(1, -1) # 如果数据是一维的,重塑为二维
|
||||
|
||||
X = data[:, :-1].astype(float) # 特征数据
|
||||
y = data[:, -1] # 标签数据
|
||||
|
||||
|
||||
Reference in New Issue
Block a user