Skip to content

Help! C3_W1_Assignment Exercise 6 and Exercise 7 shows error! #3

@ghost

Description

I couldn't complete the assignment and started looking online for answers and found your notebook.

Exercise 6 shows the following error :
AttributeError Traceback (most recent call last)
Cell In[103], line 7
4 example_breed = df_test[["breed"]].loc[0]["breed"]
5 print(f"Example dog has breed {example_breed} and features: height = {example_dog['height']:.2f}, weight = {example_dog['weight']:.2f}, bark_days = {example_dog['bark_days']:.2f}, ear_head_ratio = {example_dog['ear_head_ratio']:.2f}\n")
----> 7 print(f"Probability of these features if dog is classified as breed 0: {prob_of_X_given_C([*example_dog], FEATURES, 0, train_params)}")
8 print(f"Probability of these features if dog is classified as breed 1: {prob_of_X_given_C([*example_dog], FEATURES, 1, train_params)}")
9 print(f"Probability of these features if dog is classified as breed 2: {prob_of_X_given_C([*example_dog], FEATURES, 2, train_params)}")

Cell In[102], line 33, in prob_of_X_given_C(X, features, breed, params_dict)
29 match feature:
30 # You can add add as many case statements as you see fit
31 case "height" | "weight":
32 # Compute the relevant pdf given the distribution and the estimated parameters
---> 33 probability_f = pdf_gaussian(x, params.mu, params.sigma)
35 case "bark_days":
36 # Compute the relevant pdf given the distribution and the estimated parameters
37 probability_f = pdf_binomial(x, params.n, params.p)

AttributeError: 'dict' object has no attribute 'mu'

Exercise 7 shows the following error:
TypeError Traceback (most recent call last)
Cell In[99], line 3
1 # Test your function
----> 3 example_pred = predict_breed([*example_dog], FEATURES, train_params, train_class_probs, example_breed)
4 print(f"Example dog has breed {example_breed} and Naive Bayes classified it as {example_pred}")

TypeError: predict_breed() takes 4 positional arguments but 5 were given

Thank you for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions