C2_W2_Assignment - Excercise 4

Hi all,

i am having issue with the assignment C2_W2 - Excercise 4.

Below is my code:

def pred_sklearn(X, lr_sklearn):
  # mentor edit: code removed

I get the exact output as expected, but i fail 2 out of 4 tests. The test description hint to the shape of the output:

Test case “extra_check”. Wrong shape of pred_sklearn output.
Expected: (4, 1).
Got: (3, 1).
Test case “extra_check”. Wrong output of pred_sklearn for X = [-5 0 1 5].

Could somebody point me to the cause for this error?

Many thanks in advance!

Best,

Matteo

1 Like

Hi there,

You have a 2D array and you need to make it with 4 dimensions it says, but you are only making it with 3 dimensions. So you need one more dimensions expansion as far as I can think of.

1 Like

Hi @gent.spah,

thanks for the hint.

I don’t see any indication that i should get to 4 dimensions adding 2 with np.newaxis, the instructions generically states

and the coding suggests only one dimension to be added.

Furthermore, the name of the variable is misleading as it’s being called X_2D.

I tried anyway to add an additional dimension to X_2D with the following code:

Now if i call the function:

I get the error:

Am i getting something wrong?

Thanks!

Matteo

1 Like

I just read expected (4, 1) above but I am not familiar with this specialization, thought that might be helpful. Perhaps a mentor of this specialization could have more insight.

1 Like

Thanks Gent.

@AeryB, are you familiar with the M4ML_C2_W2 Assignment?

Do you have any other contact that can help me?

1 Like

Hi @Matteo_Egidi

Well, what you coded at first looks like a valid solution from my pov.
However, FYI, I am not a mentor for C2.

Hello @lucas.coutinho, please look into this problem.
Or if you suggest, I’d try and help.


Leaving that aside, sharing screenshots for possible solutions goes against the Honor code. I will suggest you remove them.


Best!

1 Like

HI @AeryB ,

Thanks for the reply.

I copied and pasted codes, didn’t share any screenshot.

Is that also against the code? How can we get help on the code if we cannot share bits of it?

Best,

Matteo

1 Like

Yes, it still does. Here, the Honor code!

Well, for this specific case, I’d say that you connect with mentors.

If the problem is less serious than this, say, problem understanding the process, you may explain it with words. Sometimes, depending upon the situation, you might even ask mathematically.

Now, if the problem is really severe, you should talk with the course lead.

Clear, sorry again for that.

How can I connect w mentors directly?

Did you ever try sending private messages?

If no, then give it a try. After pressing their ptofile pic or visiting their profile, you’ll see the message button.

Here,

1 Like

Totally missed that!
Thanks for the suggestion.

Cheers,

Matteo

1 Like

@Isaak_Kamau, @jonrico,

If anyone of you are here, please help.

Hi @Matteo_Egidi.

Note: Please refrain from posting your code, as it is against the Honor code.

You did everything correctly except for one thing. Remember that when you write a function with inputs/arguments, you intend to use and process its inputs in order to get an output. In this case, did you use all the inputs? And did you use some variable (e.g. X_pred) which is not the desired input?

I hope this helps. I was trying to answer your question without explicitly giving you the solution.

Let me know if you need further help. You can send me a PM. Thank you.

2 Likes

HI @jonrico ,

that makes sense :slight_smile:

Thaks a lot for steering me to the right path!

Cheers,

Matteo

ps @yjcb22 here is the main thread, just been solved! thanks all for your help.

1 Like

yes @Matteo_Egidi I sent you a message! :wink:

Why do we need to increase the dimension of X?

hint X_2D assignment is in-correct you are increasing the size of in-correct variable.

Look at how you are passing the name of the vector to the function!

The thread is over a year old, and has been resolved.