Finding odd one out

I am getting an error while running function.
Error:- "ValueError Traceback (most recent call last)
in ()
----> 1 odd_one_out(X)

in odd_one_out(lst)
7 min_similarity = 1.0
8 for w in lst:
----> 9 sim = cosine_similarity([keyed_vectors[w], [avg_vector]])
10
11 if sim < min_similarity:

~\Anaconda3\lib\site-packages\sklearn\metrics\pairwise.py in cosine_similarity(X, Y, dense_output)
915 # to avoid recursive import
916
–> 917 X, Y = check_pairwise_arrays(X, Y)
918
919 X_normalized = normalize(X, copy=True)

~\Anaconda3\lib\site-packages\sklearn\metrics\pairwise.py in check_pairwise_arrays(X, Y, precomputed, dtype)
105 if Y is X or Y is None:
106 X = Y = check_array(X, accept_sparse=‘csr’, dtype=dtype,
–> 107 warn_on_dtype=warn_on_dtype, estimator=estimator)
108 else:
109 X = check_array(X, accept_sparse=‘csr’, dtype=dtype,

~\Anaconda3\lib\site-packages\sklearn\utils\validation.py in check_array(array, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
431 force_all_finite)
432 else:
–> 433 array = np.array(array, dtype=dtype, order=order, copy=copy)
434
435 if ensure_2d:

ValueError: setting an array element with a sequence.
"

The error is very clear, you are setting an element of array with a sequence…
Refer this answer why this is happening and change the code accordingly…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.