generated from LufsX/Experiment-LogReg
This commit is contained in:
+4
-3
@@ -27,7 +27,7 @@ name = "章程鸿"
|
||||
|
||||
# 这里写自己的代码实现
|
||||
import numpy as np
|
||||
from sklearn.preprocessing import StandardScaler, MinMaxScaler
|
||||
from sklearn.preprocessing import MinMaxScaler
|
||||
from sklearn.model_selection import train_test_split
|
||||
|
||||
def sigmoid(z):
|
||||
@@ -87,7 +87,8 @@ def load_data(filepath):
|
||||
|
||||
data = np.array(data)
|
||||
labels = np.array(labels)
|
||||
target_variable = np.where((labels == 2) | (labels == 3), 0, labels)
|
||||
# 将标签二分类化,2和3为0,其余为1
|
||||
target_variable = np.where((labels == 2) | (labels == 3), 0, 1)
|
||||
|
||||
return data, target_variable
|
||||
|
||||
@@ -121,6 +122,6 @@ if __name__ == "__main__":
|
||||
# 测试模型
|
||||
final_test_accuracy = accuracy(X_test, y_test, final_weights)
|
||||
print(f"最终测试集的准确率: {final_test_accuracy:.4f}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user