TypeError unsupported operand type s for CommentedMap and CommentedMap Hatam bu nas l zebilirim

0 votes
from ruamel import yaml
from scipy import spatial
import ruamel.yaml

with open('trainer.txt') as fin:
    fin.readline()
    rfr =ruamel.yaml.round_trip_load(fin)
    x= rfr['opencv_lbphfaces']['histograms']
#print(rfr['opencv_lbphfaces']['histograms'])
with open('trainer1.txt') as fin:
    fin.readline()
    rfr1 = ruamel.yaml.round_trip_load(fin)
    y= rfr1['opencv_lbphfaces']['histograms']
#print(rfr1['opencv_lbphfaces']['histograms'])

vector1 = [x]
vector2 = [y]

#print(vector1,vector2)

cosine_similarity = spatial.distance.cosine(vector1, vector2)
print(cosine_similarity)
Sep 29, 2020 in Python by anonymous
• 120 points

edited Sep 29, 2020 by Gitika 808 views

Merhaba,

özellikle hangi satırda hatayla karşılaştığınızı belirtebilir misiniz? Hata, veri türünün uyumsuzluğundan kaynaklanmaktadır. Python'daki operatörler aynı veri türünün çalışmasını destekler. Bir operatör iki farklı veri türü için kullanıldığında, bu tür bir uyumsuzluk hatası atılacaktır.

Traceback (most recent call last):

  File "C:\Users\asus\Desktop\Poje2\untitled1.py", line 21, in <module>
    cosine_similarity = spatial.distance.cosine(vector1, vector2)

  File "C:\Users\asus\anaconda3\lib\site-packages\scipy\spatial\distance.py", line 766, in cosine
    return correlation(u, v, w=w, centered=False)

  File "C:\Users\asus\anaconda3\lib\site-packages\scipy\spatial\distance.py", line 717, in correlation
    uv = np.average(u * v, weights=w)

ValueError: operands could not be broadcast together with shapes (19,) (20,)

böyle bir hatayla karşılaşıyorum

Hey dostum

iki matrisi çarpmaya çalışıyorsanız (doğrusal cebir anlamında), X.dot (y) istersiniz, ancak y matrisinden X üzerine skaler yayınlamaya çalışıyorsanız, o zaman X * y.T yapmanız gerekir.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Python

0 votes
3 answers

TypeError: unsupported operand type(s) for -: 'str' and 'str'

& is "bitwise and" operand in Python, you ...READ MORE

answered Dec 11, 2020 in Python by Rajiv
• 8,870 points
80,609 views
0 votes
0 answers

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Hi guys i have below code . ...READ MORE

Oct 30, 2019 in Python by sumanth
• 190 points
11,998 views
0 votes
1 answer

TypeError: unsupported operand type(s) for -: 'list' and 'int'

Hey, @William For me the code is working ...READ MORE

answered Mar 11, 2020 in Python by Roshni
• 10,480 points
3,494 views
+1 vote
0 answers

TypeError: unsupported operand type(s) for /: 'list' and 'list'

This is my part of code, why ...READ MORE

May 17, 2020 in Python by anonymous
• 220 points

edited May 18, 2020 by Gitika 2,896 views
0 votes
0 answers

How can I solve it? TypeError: unsupported operand type(s) for /: 'float' and 'list'

I am trying to calculate numerical integration ...READ MORE

Nov 17, 2020 in Python by asimsek
• 120 points
13,778 views
0 votes
1 answer

Test Failed: unsupported operand type(s) for -: 'tuple' and 'list'

Hi, @There, Check what are you passing.. the ...READ MORE

answered Oct 5, 2020 in Python by Gitika
• 65,770 points
2,880 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP