—> 48 probability = estimate_probabilities(word, n_gram, n_gram_counts, n_plus1_gram_counts, len(unique_words), k=1)

—> 20 vocabulary = vocabulary + [end_token, unknown_token]

21 vocabulary_size = len(vocabulary)

22

TypeError: unsupported operand type(s) for +: ‘dict’ and ‘list’

Share a screenshot of the complete error

Hello @skinx.learning

to calculate probability, instructions given were

Estimate the probability of the word given the n-gram

using the n-gram counts, n-plus1-gram counts,

vocabulary size, and smoothing constant

in your recalled probability code line, for unique words you are using incorrect codes, using a len of unique words is creating the error as the grader cell already has a argument recalled for unique words as

vocabulary_size: number of unique words in the vocabulary

In your error description only the solution is also mentioned. replace len(unique_words with right argument call and you are not suppose to assign k any value to the code line.

Regards

DP

I have replaced len(unique word) with vocabulary_size already but the error still the same.

Share the error now you are getting after the correction

Share screenshot of codes related to estimated probabilities and calculate perplexity by personal DM. Click on my name and then message.

Regards

DP

Ok I got reason behind your issue,

because you used estimated probabilities to calculate probability which used vocabulary codes, you are ending up with this error.

You are suppose to use the grader cell UNQ_C9 recall function **estimate_probability** and not **estimate_probablities** to calculate the probability in the calculate perplexity.

UNQ_C9 GRADED FUNCTION: estimate_probability ###

def estimate_probability(word, previous_n_gram,

Also while recalling probability in calculate perplexity you do not need to recall k=k, just call it as k

Regards

DP

Thank you so much for the helpful information!