C2_W1_Lab03_CoffeeRoasting_Numpy

Hi Guys,
I am curious that in the below screenshot code, we have not given any Xlables, Ylables, titles, etc, how is it populated?

Hi @Ch_Venkatesh66

It is a function that was created for this assignment, The code of it is

def plt_roast(X,Y):
    Y = Y.reshape(-1,)
    colormap = np.array(['r', 'b'])
    fig, ax = plt.subplots(1,1,)
    ax.scatter(X[Y==1,0],X[Y==1,1], s=70, marker='x', c='red', label="Good Roast" )
    ax.scatter(X[Y==0,0],X[Y==0,1], s=100, marker='o', facecolors='none', 
               edgecolors=dlc["dldarkblue"],linewidth=1,  label="Bad Roast")
    tr = np.linspace(175,260,50)
    ax.plot(tr, (-3/85) * tr + 21, color=dlc["dlpurple"],linewidth=1)
    ax.axhline(y=12,color=dlc["dlpurple"],linewidth=1)
    ax.axvline(x=175,color=dlc["dlpurple"],linewidth=1)
    ax.set_title(f"Coffee Roasting", size=16)
    ax.set_xlabel("Temperature \n(Celsius)",size=12)
    ax.set_ylabel("Duration \n(minutes)",size=12)
    ax.legend(loc='upper right')
    plt.show()

The implementation of it is in the lab_coffee_utils.py, You can download it and get all the functions in this file, This thread is about how to download files in your PC

Cheers,
Abdelrahman

1 Like

Thank you very much.

Hi mentor
could you please help me to understand what those 2 lines codes highlighted are doing?

Why we don’t set yhat=0 instead in the first line code?

image

Thanks
Christina

Hi @Christina_Fan

The first highlighted line of code is we create new list with dimensions like the prediction list dimension and we set the initial value = 0
about second highlighted line of code is we check where the values of prediction is larger than or equal 0.5 it retyurn true and other wise return flase, we change the type form boollean to integer so that true will be 1 and false will be zeros…the 2 codes are same but different implementation with different proberties

Since “predictions” is a vector, the comparison is performed for each element, and compared to the threshold. The result will be True or False, cast as an integer (1 or 0), with yhat having the same shape as predictions.

Thanks to both of your detailed explanation. Greatly appreciated :slight_smile:

You alluded the file lab_coffee_utils.py file in your response, does it mean we(students) are expected to understand all the supplementary .py files provided in the Lab?

I felt I can follow the content of the lectures so far, but I struggle to understand the codes in the .py files :frowning: Any suggestion or advice would be much appreciated!

Not required, but it’s a good opportunity for extra learning.

Thank you Tom. To be able to build a neural network model in practice or for work in the future, I assume I need to be able to write those codes as shown in those .py files? I assume those py files are the building block for AI models?

The .py files usually only contain utilities that draw plots and import datasets.
The working parts of the ML solutions are in the notebook.

I understand, but in reality we need both parts to be able to build a ML model and make it work, correct? I feel I learnt ML solutions but have little understanding around datasets… what are your advice on what I need to learn about datasets?

Sorry, your question about datasets is overly broad. What are you asking specifically?

Otherwise, all I can say is that you can’t create a model without a set of data.

Sorry, I meant what specific knowledge/skillsets I need to have or course I need to learn about datasets in addition to the current ML specialization. In real world, I assume as a ML engineer need to have knowledge on ML solutions and knowledge on datasets. I am not currently a ML engineer but I am hoping to get become a ML engineer by gaining those skillsets required.

Sorry, but I do not know what you mean by “knowledge on datasets”. So I’ll try out a few thoughts.

When you are working in machine learning, generally the dataset is going to be provided for you. Collecting a new dataset from scratch is extremely slow, tedious, and expensive. Someone else does that.

Your job starts when you have the dataset and someone asks you to solve a problem using it.

Once you have a dataset, you pretty much only have to import it into your machine learning environment, do a little preprocessing (like normalization of the features), and the split it into training, validation, and test sets.

There are off-the-shelf tools for all of that. You don’t have to write that code yourself. The “pandas” package is commonly used. You’ll see that either in the MLS courses, or certainly in the Deep Learning Specialization courses.

This is great, thank you for clarifying this for me Tom. May I ask another dumb question - what are the most critical skillsets that a ML engineer needs to have generally? Thank you!

Sorry, there’s no quick and complete answer to that.