I'm using graphlab to print out recommendations and have my tkinter GUI which currently prints out the recommendation results in the console and I'm lost on how to get it to print in the GUI.
Class "UserID" is where i have a button that calls the "printrec" function but only prints out the recommendations in the console.
from Tkinter import *
import sqlite3
class Welcome():
def __init__(self,master):
self.master=master
self.master.geometry('170x110+100+200')
self.master.title('Welcome!')
self.label1=Label(self.master,text='Music Recommender',fg='black', bg="red").grid(row=0,column=1)
self.button1=Button(self.master,text="Enter UserID",fg='black', bg="blue", command=self.gotoUserID).grid(row=1,column=1)
self.button2=Button(self.master,text="Comparing models",fg='black', bg="blue").grid(row=2,column=1)
#self.button3=Button(self.master,text="Click to print recs",fg='red',command=self.rec).grid(row=3,column=1)
self.button4=Button(self.master,text="Exit",fg='black' , bg="blue",command=self.exit).grid(row=4,column=1)
def exit(self):
#exit button#
self.master.destroy()
def gotoUserID(self):
#USERID GUI#
root2=Toplevel(self.master)
myGUI=UserID(root2)
class UserID():
#userID class prints song recs
def __init__(self,master):
self.userRec=int()
self.master=master
self.master.geometry('400x250+100+200')
self.master.title('ID recommender')
self.label2=Label(self.master,text='Welcome to the Music Recommender',fg='red').grid(row=0,column=0)
self.label2=Label(self.master,text='Please enter UserID: ',fg='black').grid(row=3,column=0)
self.ID=Entry(self.master,textvariable=self.userRec).grid(row=3,column=1)
self.button4=Button(self.master,text="Get recommendations",fg='red',command=self.printrec).grid(row=7,column=0)
self.button5=Button(self.master,text="Exit",fg='red',command=self.exit).grid(row=9,column=0)
def printrec(self):
#currently prints song recs in console
print song_recommendations
def main():
root=Tk()
root.configure(background='blue')
myGUIWelcome=Welcome(root)
root.mainloop()
if __name__ == '__main__':
main()
This is the model im using to recommend. It uses the graphlab package.
recs_model = gl.recommender.ranking_factorization_recommender.create(plays_df, user_id="userID", item_id="songID", target="plays")
recommendations = recs_model.recommend(users=["3a613180775197cd08c154abe4e3f67af238a632"])
song_recommendations = recommendations.join(songs_df, on="songID", how="inner").sort("rank")
This is the output I want to appear in my GUI but im not sure if its possible to print an sframe like this into tkinter.
+-------------------------------+--------------------+---------------+------+
| userID | songID | score | rank |
+-------------------------------+--------------------+---------------+------+
| 3a613180775197cd08c154abe4... | SOXTUWG12AB018A2E2 | 59.1517736392 | 1 |
| 3a613180775197cd08c154abe4... | SOYBLYP12A58A79D32 | 30.0328809695 | 2 |
| 3a613180775197cd08c154abe4... | SOFVLYV12A8C145D8F | 28.9258825259 | 3 |
| 3a613180775197cd08c154abe4... | SOVWBYM12A6D4F8A22 | 28.9166185336 | 4 |
| 3a613180775197cd08c154abe4... | SOAUWYT12A81C206F1 | 27.7749540286 | 5 |
| 3a613180775197cd08c154abe4... | SODCNEE12A6310E037 | 27.7024595218 | 6 |
| 3a613180775197cd08c154abe4... | SOAIWAB12A8C13710A | 24.2139894443 | 7 |
| 3a613180775197cd08c154abe4... | SOFFXAQ12A8AE45C2E | 23.7690011935 | 8 |
| 3a613180775197cd08c154abe4... | SONDKOF12A6D4F7D70 | 22.8345548587 | 9 |
| 3a613180775197cd08c154abe4... | SOJFQWU12A8C1448C7 | 22.2914831119 | 10 |
+-------------------------------+--------------------+---------------+------+
+--------------------------------+--------------------------------+
| title | release |
+--------------------------------+--------------------------------+
| Drop The Hammer (Album Ver... | A Search For Reason |
| Up And Up (Acoustic) | Must Have Done Something Right |
| Believe In Yourself | Questions |
| Video Killed The Radio Star | Friends Reunited: Music Of... |
| Undo | Vespertine Live |
| Sorrow (1997 Digital Remaster) | The Best Of David Bowie 19... |
| Blind Date | Anchors Aweigh |
| Death Chamber | Isolation |
| Recado Falado (Metrô Da Sa... | 2 Em 1 |
| Rain On Your Parade | Rain On Your Parade |
+--------------------------------+--------------------------------+
+------------------+------+
| artistName | year |
+------------------+------+
| Kilgore | 1998 |
| Relient K | 0 |
| Us3 | 2004 |
| The Buggles | 1979 |
| Björk | 2001 |
| David Bowie | 0 |
| Bouncing Souls | 2003 |
| Fear My Thoughts | 2008 |
| Alceu Valença | 0 |
| Duffy | 0 |
+------------------+------+
[10 rows x 8 columns]
Thanks!