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 dotenv import load_dotenv load_dotenv() root_url = os.getenv("ROOT_URL") def basic_stats_function(data_list: List[str]): return def regression_func(independent_variables: List[str], dependent_variable: str, session_hash, category: str='', regression_type: str="ols"): print("LINEAR REGRESSION CALCULATION") print(independent_variables) print(dependent_variable) try: dir_path = TEMP_DIR / str(session_hash) 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 = px.scatter(df, x=independent_variables, y=dependent_variable, color=category, trendline="ols") else: fig = px.scatter(df, x=independent_variables, y=dependent_variable, trendline="ols") pio.write_html(fig, chart_path, full_html=False) chart_url = f'{root_url}/gradio_api/file/temp/{session_hash}/chart.html' iframe = '