import pandas as pd from typing import List from utils import TEMP_DIR import plotly.express as px import plotly.io as pio import os from functions import scatter_chart_fig from dotenv import load_dotenv load_dotenv() root_url = os.getenv("ROOT_URL") def regression_func(independent_variables: List[str], dependent_variable: str, session_hash, session_folder, category: str='', **kwargs): print("LINEAR REGRESSION CALCULATION") print(independent_variables) print(dependent_variable) try: dir_path = TEMP_DIR / str(session_hash) / str(session_folder) chart_path = f'{dir_path}/chart.html' csv_query_path = f'{dir_path}/query.csv' df = pd.read_csv(csv_query_path) if category in df.columns: fig = scatter_chart_fig(df=df, x_column=independent_variables,y_column=dependent_variable, category=category,trendline="ols") else: fig = scatter_chart_fig(df=df,x_column=independent_variables,y_column=dependent_variable, trendline="ols") pio.write_html(fig, chart_path, full_html=False) chart_url = f'{root_url}/gradio_api/file/temp/{session_hash}/{session_folder}/chart.html' iframe = 'Please display this iframe: