CefasRepRes / coco_labeller

MIT License
0 stars 1 forks source link

Use the lookup table being developed to auto-populate each field #10

Open JoeRibeiro opened 3 months ago

JoeRibeiro commented 3 months ago

How could we go about this? 1: a match with WORMS. Take all the aphia IDs in our excel document and do a lookup on the species genus etc for all of those 2: For now it is okay to use the classifier's prediction to filter the aphia IDs as long as there is an accept option to copy the classifier's class to a field called verified class. THEN you get auto-populated aphia ID options based on verified class. 3: Change it so that the user gets species options based on verified class rather as well as aphia ID options. If the user selects a genus, the species options are narrowed. If the user picks the species, the aphia ID option is selected. The order should not matter. Central to this is a central_df, which is reactive. The filters applied by each human selection limits the options:

from tkinter import ttk import pandas as pd

class DataFrameApp: def init(self, root): self.root = root self.root.title("Reactive DataFrame Filter")

    self.df = pd.DataFrame({
        'Name': ['Alice', 'Bob', 'Charlie', 'David'],
        'Age': [25, 30, 35, 40],
        'City': ['New York', 'Los Angeles', 'Chicago', 'Houston']
    })

    self.create_widgets()

def create_widgets(self):
    # Filter Input
    self.filter_label = tk.Label(self.root, text="Filter by Name:")
    self.filter_label.pack()

    self.filter_entry = tk.Entry(self.root)
    self.filter_entry.pack()
    self.filter_entry.bind("<KeyRelease>", self.update_table)

    # Table
    self.tree = ttk.Treeview(self.root, columns=list(self.df.columns), show='headings')
    for col in self.df.columns:
        self.tree.heading(col, text=col)
        self.tree.column(col, anchor=tk.W)
    self.tree.pack()

    self.update_table()

def update_table(self, event=None):
    for item in self.tree.get_children():
        self.tree.delete(item)

    filter_text = self.filter_entry.get().lower()

    filtered_df = self.df[self.df['Name'].str.lower().str.contains(filter_text)]

    for index, row in filtered_df.iterrows():
        self.tree.insert('', 'end', values=row.tolist())

root = tk.Tk() app = DataFrameApp(root) root.mainloop()