Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Nov 22, 2023 · 0 comments
Open

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

ghost opened this issue Nov 22, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Nov 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants