Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import pandas as pd | |
| import bm25s | |
| from rapidfuzz import fuzz | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| # 1. Load the Data | |
| abt_df = pd.read_csv("Abt.csv", encoding='latin1') #.rename(columns={'id': 'idAbt', 'name': 'name_A'}) | |
| buy_df = pd.read_csv("Buy.csv", encoding='latin1') #.rename(columns={'id': 'idBuy', 'name': 'name_B'}) | |
| print("Abt Missing Data:") | |
| print(abt_df.isnull().sum()) | |
| print("\nBuy Missing Data:") | |
| print(buy_df.isnull().sum()) | |
| # Calculate string lengths | |
| abt_df['name_length'] = abt_df['name'].str.len() | |
| buy_df['name_length'] = buy_df['name'].str.len() | |
| def generate_plot(): | |
| fig = plt.figure() | |
| plt.hist(abt_df['name_length'], alpha=0.5, label='Abt') | |
| plt.hist(buy_df['name_length'], alpha=0.5, label='Buy') | |
| plt.legend() | |
| return fig # Return the figure, DO NOT use plt.show() | |
| # Then in your Gradio layout: | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Welcome to the Product Matcher") | |
| with gr.Row(): | |
| my_plot = gr.Plot(value=generate_plot()) # Gradio handles the drawing | |
| print(f"Abt Price Range: ${abt_df['price'].min()} to ${abt_df['price'].max()}") | |
| print(f"Buy Price Range: ${buy_df['price'].min()} to ${buy_df['price'].max()}") |