{"id":1052,"hash":"133bc0d10dc1491b5012e289e153e8ee6b88dcf8846ec25c48d1493e0e2d1530","pattern":"sklearn Logistic Regression &quot;ValueError: Found array with dim 3. Estimator expected &lt;= 2.&quot;","full_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.\n\nlr = LogisticRegression()\nlr.fit(train_dataset,train_labels)\n\nThis is the code i trying to do and it give me the error.\n\nValueError: Found array with dim 3. Estimator expected <= 2.\n\nAny idea?","ecosystem":"pypi","package_name":"scikit-learn","package_version":null,"solution":"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.\n\nnsamples, nx, ny = train_dataset.shape\nd2_train_dataset = train_dataset.reshape((nsamples,nx*ny))","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/34972142/sklearn-logistic-regression-valueerror-found-array-with-dim-3-estimator-expec","votes":87,"created_at":"2026-04-19T04:52:13.805747+00:00","updated_at":"2026-04-19T04:52:13.805747+00:00"}