This is hard

I tried to Do the Labs (coding) but couldn’t.
I couldn’t do it at all, should I go from the beginning and and try do them?
I felt stupid like if i don’t know what to do.
I did all the quizzes fine but not the labs I have the fundamental knowledhe of programming from JS so I understand python code just fine.
How to restart the labs?
Thanks​:blush:

1 Like

This course requires solid python programming skills, but does not teach them. If you are having trouble just with the programming exercises, then you have a couple of alternatives:

  1. If your purpose in taking M4ML is to gain the math knowledge, then you can just skip the programming assignments. You can still understand the math without the programming. You will not get a certificate, but you will have the knowledge.
  2. But if your purpose in taking M4ML is to be prepared to go on and take the other courses here like MLS and DLS, please be aware that those also require python programming.

If you are in case 2), then you need to strengthen your programming skills, because you’ll hit the same problem in MLS and DLS. Since you have experience in JS, you can try spending some time reading the educational material on the python.org website and that should help.

1 Like

Hi there.
I did C1 W2 lab in MLS and did just fine but i needed the math so i came here.
Thanks

1 Like

I know loops arrays functions classes MongoDB or how to connect to a DB I have the fundamentals of coding and when I look to the code I know that that is a function and that is a loop and that is an array and so on.

1 Like

I wish if it was just like MLS where they show us the formula step by step then we write our own code, and it’s just a little bit probably 5 to 7 lines of code.
but I didn’t understand the math so I came here.

1 Like

Lets try going step by step, so we understand the issue you’re having.

Please post a screen capture image of the first thing in the programming assignment notebook that is giving you problems.

This will help us know exactly what advice to give you.

for i in range(len(M)):

    # Find the first non-zero entry in the current row (pivot)
    
    ## the first non-zero
    pivot = np.flatnonzero(M[i])[0]

# This variable stores the pivot’s column index, it starts at i, but it may change if the pivot is not in the main diagonal.

I think this is correct

    column_index = pivot
    
    ## this one i don't undrstand
   ## the rest two
    # CASE PIVOT IS ZERO
    if np.isclose(i.all(), 0): 

# PART 1: Look for rows below current row to swap, you may use the function get_index_first_non_zero_value_from_column to find a row with non zero value

        index = get_index_first_non_zero_value_from_column(M,column = pivot, starting_row = i)
        print("index",index)
        If there is a non-zero pivot 
        if index is not 0:
            # Swap rows if a non-zero entry is found below the current row
        

            # Update the pivot after swapping rows
            pivot = None

        # PART 2 - NOT GRADED. This part deals with the case where the pivot isn't in the main diagonal.
        # If no non-zero entry is found below it to swap rows, then look for a non-zero pivot outside from diagonal.
        if index is None: 
            index_new_pivot = None 
            # If there is no non-zero pivot, it is a row with zeroes, save it into the list rows_to_move so you can move it to the bottom further.
            # The reason in not moving right away is that it would mess up the indexing in the for loop.
            # The second condition i >= num_rows is to avoid taking the augmented part into consideration.
            if index_new_pivot is None or index_new_pivot >= num_rows:
                rows_to_move.append(i)
                continue
            # If there is another non-zero value outside from diagonal, it will be the pivot.
            else:
                pivot = None
                # Update the column index to agree with the new pivot position
                column_index = None

    # END HANDLING FOR PIVOT 0   

# Divide the current row by the pivot, so the new pivot will be 1. (reduced row echelon form)

    M[i] = 1/M[i][pivot] * M[i]
    print(M)

# Perform row reduction for rows below the current row

    for j in range(len(M)):
    # Get the value in the row that is below the pivot value
         value_below_pivot = M[j][column_index] * -1  # Assuming pivot is at M[i][column_index]
      # Perform row reduction using the formula:
       # row_to_reduce -> row_to_reduce - value_below_pivot * pivot_row
         M[j] = M[j] - value_below_pivot * M[i][column_index]

should I watch lectures from the begging?
and how to reset the lab?

I asked to see a screen capture image. It is very difficult to read a text copy-and-paste when the code is interpreted as Markdown formatting.

You can reset the lab by:

  • Use the File menu and rename your notebook ipynb file.
  • Use the Help menu and use “Get latest version”.
  • Use the Kernel menu and restart the kernel.

I don’t understand the exercises that’s why I cannot do them.
I don’t understand the instructions.

The instructions are quite detailed and complete. They practically wrote a book about how to do this. Is it a language problem? Maybe you could try using Google Translate to map it to your native language.

The other suggestion is that all this stuff is “real” in the sense that you can actually literally take a pencil and paper and work examples as you read the instructions. Watch what happens as you really “do it”. This is not some abstract theoretical thing: it’s real “nuts and bolts” work.

Hi.
Do you think I can go back and do the lectures again maybe that’s can help?
:blush:

1 Like

Sure, it can’t hurt, right? If you have already tried reading the instructions again and it’s not helping, maybe it would be useful to sort of “reset” and start over again with the lectures.

Thanks :blush:.