我需要打印一些p
使用print
这个循环的值。
for prediction in pred:
j=0
if(prediction == 1):
print ("Titolo: " + target_playlist["song_title"][i] + ", Artista: "+ target_playlist["artist"][i] + ", Percentuali: "+ p[i])
likedSongs= likedSongs + 1
i = i +1
如果我尝试p
在循环 fow 示例之外打印
for i in range(len(p)):
print("Predicted=%s" % (p[i]))
它可以工作,但是当我p[i]
在 for 循环中放入 print 时,我遇到了类型问题。我该如何解决?
if(algoritmo_scelto==1):
pred = c.predict(target_playlist[features])
p = c.predict_proba(target_playlist[features])
if(algoritmo_scelto==2):
pred = knn.predict(target_playlist[features])
p = knn.predict_proba(target_playlist[features])
if(algoritmo_scelto==3):
pred = forest.predict(target_playlist[features])
p = forest.predict_proba(target_playlist[features])
if(algoritmo_scelto==4):
pred = k_means.predict(target_playlist[features])
p = k_means.predict_proba(target_playlist[features])
likedSongs = 0
i = 0
for prediction in pred:
j=0
if(prediction == 1):
print ("Titolo: " + target_playlist["song_title"][i] + ", Artista: "+ target_playlist["artist"][i] + ", Percentuali: "+ p[i])
likedSongs= likedSongs + 1
i = i +1
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\david\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "C:\Users\david\eclipse-workspace1\project\src\changp.py", line 179, in <lambda>
command=lambda: par())
File "C:\Users\david\eclipse-workspace1\project\src\changp.py", line 173, in par
estraiPreferite(self.entry1.get(), var.get())
File "C:\Users\david\eclipse-workspace1\project\src\changp.py", line 550, in estraiPreferite
print ("Titolo: " + target_playlist["song_title"][i] + ", Artista: "+ target_playlist["artist"][i] + ", Percentuali: "+ p[j])
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U72') dtype('<U72') dtype('<U72')