Warning in programming assignment of week 3


note: the warning described here does not occur in any graded code cell. I just report it here because

  • warnings just do not make a quality impression
  • the warning has to do with array dimensions, which is a focus of this weeks course stuff, so this should be implemented without warning IMHO

Versions that I am using:

sklearn-Version: 0.24.1
Python-Version : 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]

The following code:

clf = sklearn.linear_model.LogisticRegressionCV();
clf.fit(X.T, Y.T);

results in the following warning:

C:\Users\Mkleine\anaconda3\lib\site-packages\sklearn\utils\validation.py:63: 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().
return f(*args, **kwargs)

This can be fixed by changing the above code to:

clf = sklearn.linear_model.LogisticRegressionCV();
clf.fit(X.T, Y.T.ravel());

In the coursera environment, the warning does not appear, probably because this kind of warning is disabled generally or due to version differences. Versions in this environment are:

sklearn-Version: 0.22.2.post1
Python-Version : 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 23:03:20)
[GCC 7.3.0]

Best regards

Hey @Matthias_Kleine,
It’s not practically possible to update the Coursera Environments, to keep them up-to-date with the latest Python packages, since the Python packages are very dynamic in nature, and update very frequently. Therefore, the labs are meant to run in Coursera Environments, and not for your local machines.

If you want to run them in your local machine and get the same outputs as in the Coursera Environment, you might either have to make some changes to your code, or set up a local environment with the same package versions in your local machine.

Rest assured, when the Coursera Environments will be updated with the latest package versions, all possible errors and warnings due to the same, will be eliminated.


Sure, it’s actually not meant to be an accusation, but something that the deeplearning.ai team might take on some todo list for an appropriate time.


Hey @Matthias_Kleine,
We assure you that we haven’t taken this as an accusation, but a valuable feedback from a concerned learner, and let me assure you personally, that fixing warnings and bugs will be on the top of the priority list of the DeepLearning.AI team whenever the Coursera environments will be updated. Happy Learning :nerd_face:


But as Elemento says, the point is that you are running this locally, so it’s probably a “versionitis” problem. It’s literally impossible for the course staff to create the assignments in such a way that they will be trouble free if run with some arbitrary set of versions of all the required packages from now until any and every point in the future. The world of python packages is incredibly dynamic and APIs do sometimes change in incompatible ways.

How would one approach solving that problem? The only way I can think of would be to package the assignments in a completely different form, e.g. a VM or Docker Image that is prepackaged with the appropriate versions.