pypiscikit-learn95% confidence\u2191 87

sklearn Logistic Regression "ValueError: Found array with dim 3. Estimator expected <= 2."

Full error message
I attempt to solve this problem 6 in this notebook. The question is to train a simple model on this data using 50, 100, 1000 and 5000 training samples by using the LogisticRegression model from sklearn.linear_model.

lr = LogisticRegression()
lr.fit(train_dataset,train_labels)

This is the code i trying to do and it give me the error.

ValueError: Found array with dim 3. Estimator expected <= 2.

Any idea?

scikit-learn expects 2d num arrays for the training dataset for a fit function. The dataset you are passing in is a 3d array you need to reshape the array into a 2d. nsamples, nx, ny = train_dataset.shape d2_train_dataset = train_dataset.reshape((nsamples,nx*ny))

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/133bc0d10dc1491b5012e289e153e8ee6b88dcf8846ec25c48d1493e0e2d1530
hash \u00b7 133bc0d10dc1491b5012e289e153e8ee6b88dcf8846ec25c48d1493e0e2d1530
sklearn Logistic Regression &quot;ValueError: Found array wi… — DepScope fix | DepScope