Python 3.x 总是获得1的精度如何修复?

Python 3.x 总是获得1的精度如何修复?,python-3.x,scikit-learn,classification,logistic-regression,Python 3.x,Scikit Learn,Classification,Logistic Regression,我试图在我的数据集上应用逻辑回归,但它给出的准确度为1 df = pd.read_csv("train.csv", header=0) df = df[["PassengerId", "Survived", "Sex", "Age", "Embarked"]] df.dropna(inplace=True) X = df[["Sex", "Age"]] X_train = np.array(X) Y = df["Survived"] Y_train = np.array(Y) clf =

我试图在我的数据集上应用逻辑回归,但它给出的准确度为1

df = pd.read_csv("train.csv", header=0)

df = df[["PassengerId", "Survived", "Sex", "Age", "Embarked"]]
df.dropna(inplace=True)

X = df[["Sex", "Age"]]
X_train = np.array(X)

Y = df["Survived"]
Y_train = np.array(Y)

clf = LogisticRegression()
clf.fit(X_train, Y_train)

df1 = pd.read_csv("test.csv", header=0)
df1 = df1[["PassengerId", "Survived", "Sex", "Age", "Embarked"]]
df1.dropna(inplace=True)

X = df1[["Sex", "Age"]]
X_test = np.array(X)

Y = df1["Survived"]
Y_test = np.array(Y)
X_test = X_test.astype(float)
Y_test = Y_test.astype(float)
#to convert string data to float
accuracy = clf.score(X_test, Y_test)
print("Accuracy = ", accuracy)
我希望输出介于0和1之间,但总是得到1.0