更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 1m55s

This commit is contained in:
2024-10-31 16:12:20 +08:00
parent 9c457a01db
commit 9e2d26cddc
+3 -1
View File
@@ -45,6 +45,8 @@ def predict_logreg(inX, weights):
def load_data(filepath): def load_data(filepath):
data = np.genfromtxt(filepath, delimiter=',', dtype=np.float64) data = np.genfromtxt(filepath, delimiter=',', dtype=np.float64)
if len(data.shape) == 1:
data = data.reshape(1, -1)
# 处理缺失值 # 处理缺失值
data[np.isnan(data)] = 0 data[np.isnan(data)] = 0
X = data[:, :-1] X = data[:, :-1]
@@ -53,7 +55,7 @@ def load_data(filepath):
y[y == 2] = 0 y[y == 2] = 0
y[y == 3] = 0 y[y == 3] = 0
# 去掉特征 3、特征 24~28 # 去掉特征 3、特征 24~28
X = np.delete(X, [2, 23], axis=1) X = np.delete(X, [2] + list(range(22, X.shape[1])), axis=1)
return X, y return X, y
if __name__ == "__main__": if __name__ == "__main__":