Ejemplo n.º 1
0
        def get_subsitute():
            name = t1.get()
            # Get the index of the item that matches the title
            idx = indices[name]

            # Get the pairwsie similarity scores of all items with that items
            sim_scores = list(enumerate(cosine_sim[idx]))

            # Sort the items based on the similarity scores
            def get_key(elem):
                return elem[1]

            sim_scores.sort(key=get_key, reverse=True)

            # Get the scores of the 10 most similar items
            sim_scores = sim_scores[1:11]

            # Get the items indices
            item_indices = [i[0] for i in sim_scores]

            # Return the top 10 most similar items
            #print (type( df_new['name'].iloc[item_indices]))
            df = ((df_new.iloc[item_indices].sort_values(by='price')))
            pt = Table(frame, dataframe=df)
            pt.place(x=0, y=300)
            pt.show()
Ejemplo n.º 2
0
 def get_comp():
     value = t1.get()
     df = (support_data[(support_data['name_x'] == value) |
                        (support_data['name_y'] == value)].sort_values(
                            by='support', ascending=False).head(10))
     pt = Table(frame, dataframe=df)
     pt.place(x=0, y=300)
     pt.show()