+ 6
(SOLVED) [Python] Data Science Project - OLS Method
So, I didn't quite understand the task of the Coding Project in the module about the Machine Learning of Data Science course. Could someone please clarify the task and give a few hints? I don't ask for the code. I just need a normal explanation in plain English 🥲
8 Answers
+ 2
Okay, I think I remember the task – the issue form me was: There is no image showing the formula. However, I solved it like this:
https://code.sololearn.com/W6GU7ALMWfZY/?ref=app
+ 4
Lisa, I'm sorry, but I still can't do it! 😅💀😂
Here's my attempt:
https://code.sololearn.com/cujmIqI51NP6/?ref=app
Am I missing the most obvious thing ever? It gives ALMOST what I need in the first test and then throws an exception (for obvious reasons, though I don't know how I could fix it) on the second one
+ 4
Lisa
First test:
Input:
2 2
1 0
0 2
Output:
[[2. 0. ]
[0. 1.5]]
Should be:
[2. 1.5]
That's close tho.
Second test:
Input:
3 2
1 2
1 0.5
1 0.3
3 3.5 3.2
Output:
Exception: operands could not be broadcasted....... (Something because shapes are different)
And shapes of two operands are (3,4) and (4,3). So that's a transposed and a normal matrix. And how can we multiply matrices with different shapes?
Also, what is wrong with the first test?
+ 2
Lisa yep!
+ 2
Lisa that helped! But it didn't solve the problem. Anyways, I was searching through NumPy docs and found the np.matmul function. Don't know what it does, but after playing around with code I solved the problem! Thanks for helping!
+ 1
Is it Data Science course, lesson/ project 27 "Ordinary Squares"?
+ 1
What kind of exception?
Dmi think the task description asked us to round the result.
+ 1
You tried to use * for multiplying the matrice/ vectors. Rather use dot product, np.dot(a, b)