Logistic Regression - AttributeError: 'tuple' object has no attribute 'fit'

24 Views Asked by At

I'm trying to do a logistic regression, however I encountered an error.

y = train_data\["Survived"\] # target
features = \["Age", "Sex", "Pclass"\]
x = train_data\[features\] # features

from sklearn.model_selection import train_test_split # split the data into training data
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state = 16)

log_regression = "Logistic Regression", LogisticRegression(random_state=16)# random_state=42,         max_iter= 1500, n_jobs=-1

log_regression.fit(x_train, y_train)

y_pred = log_regression.predict(x_test)

acc = accuracy_score(y_test, y_pred)

AttributeError                            Traceback (most recent call last)
\<ipython-input-11-48a79c05695f\> in \<module\>
6
7 # Train the model
\----\> 8 log_regression.fit(x_train, y_train)
9
10 # Predictions on test data

AttributeError: 'tuple' object has no attribute 'fit'

I had already try to search online, how to solve it, but nothing help. Please help me, thanks a lot!

0

There are 0 best solutions below