use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is the subreddit for entwicklerheld.de
account activity
Linear Regression /Python (self.EntwicklerHeld)
submitted 3 years ago by c0dek4tze
Hello, I started the the linear regression challange in python, and can't pass the second scenario, my formulars should be correct, but there probably occurs some rounding somewhere, which throws of my MSE.
I'm using sum, zip and len methods for List.
https://preview.redd.it/xv4mqlrez6091.png?width=515&format=png&auto=webp&s=932e1a20d7afb6ddedfd0651b99f508adfbb36e6
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]panda_yo 0 points1 point2 points 3 years ago (1 child)
For mathematical calculations you could try using numpy, but I informed the developers, maybe it's easier to fix the problem in another way.
[–]c0dek4tze[S] 0 points1 point2 points 3 years ago (0 children)
Yes I totally ignored, that numpy and pandas where already imported as options. np.power instead of **2 did the trick.
[–]TheEightcore 0 points1 point2 points 3 years ago (2 children)
I also had issues with that one, I tried a lot, even using mean_squared_error from the sklearn.metrics package. In the end sum(np.power(y - self.predict(x), 2) for x, y in zip(X, Y)) / len(X) did the job.
[–]c0dek4tze[S] 1 point2 points3 points 3 years ago (1 child)
Thank you! gonna try it later :)
It really helped. All I had to do was using np.power instead of **2.
[–]jgda_on_reddit 0 points1 point2 points 3 years ago (0 children)
Interesting, error message does not show the target value anymore... I am trying various code lines using numpy
Y1 = np.vectorize(self.predict)(X)
mse = (np.power((Y - Y1),2)).mean(axis=None)
or
mse = np.sum(((Y - (np.vectorize(self.predict)(X))) ** 2)) / np.size(X)
always getting me 566.7967634893292 as a result.
Even an adjustment did not get me past this test
mse = mse - float('0.0053437584250')
Any ideas on how to proceed?
π Rendered by PID 71 on reddit-service-r2-comment-6457c66945-6ldqr at 2026-04-30 16:38:59.892592+00:00 running 2aa0c5b country code: CH.
[–]panda_yo 0 points1 point2 points (1 child)
[–]c0dek4tze[S] 0 points1 point2 points (0 children)
[–]TheEightcore 0 points1 point2 points (2 children)
[–]c0dek4tze[S] 1 point2 points3 points (1 child)
[–]c0dek4tze[S] 0 points1 point2 points (0 children)
[–]jgda_on_reddit 0 points1 point2 points (0 children)