Machine Learning Engineering


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\ 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\ ConvergenceWarning: lbfgs failed to converge (status=1):

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), y_train)

It seems like you’re encountering some issues with your machine learning project. The warning messages you’re getting suggest that there might be a problem with the shape of your data or the convergence of your model. Have you tried reshaping your data or adjusting the number of iterations for the logistic regression model? You may also want to consider scaling your data using preprocessing techniques. Don’t forget to check the documentation for alternative solver options as well. Good luck with your project!