Hi

I’m working on the final portfolio project for the Machine Learning Engineering Module.

I’m trying to fit the training data to a Logistic Regression equation. I keep getting a message saying:

C:\Users\njaro\anaconda3\Lib\site-packages\sklearn\utils\validation.py:1143: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().

y = column_or_1d(y, warn=True)

C:\Users\njaro\anaconda3\Lib\site-packages\sklearn\linear_model_logistic.py:458: ConvergenceWarning: lbfgs failed to converge (status=1):

STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.

Increase the number of iterations (max_iter) or scale the data as shown in:

6.3. Preprocessing data — scikit-learn 1.4.2 documentation

Please also refer to the documentation for alternative solver options:

1.1. Linear Models — scikit-learn 1.4.2 documentation

Here’s some of the previous code:

arr1 = df[‘Salary’]

series_obj = pd.Series(arr1)

arr1 = series_obj.values

reshape_arr1 = arr1.reshape((-1, 1))

arr2 = df[‘Age’]

series_obj2 = pd.Series(arr2)

arr2 = series_obj2.values

reshape_arr2 = arr2.reshape((-1, 1))

salary_age = LogisticRegression()

X = reshape_arr1

y = reshape_arr2

min_max_scaler = preprocessing.MinMaxScaler()

X_train_minmax = min_max_scaler.fit_transform(X_train)

X_test_minmax = min_max_scaler.transform(X_test)

X_train_minmax, X_test, y_train, y_test = train_test_split(X, y, random_state=10, test_size=0.20)

salary_age.fit(X_train_minmax, y_train)