BizIntel_AI / tools /visuals.py
mgbam's picture
Create visuals.py
bf400de verified
raw
history blame
800 Bytes
import pandas as pd
import plotly.express as px
def histogram_tool(file_path: str, column: str):
df = pd.read_csv(file_path)
fig = px.histogram(df, x=column, nbins=30, title=f"Histogram – {column}", template="plotly_dark")
return fig
def scatter_matrix_tool(file_path: str, cols: list[str]):
df = pd.read_csv(file_path)
fig = px.scatter_matrix(df[cols], title="Scatter‑Matrix", template="plotly_dark")
return fig
def corr_heatmap_tool(file_path: str):
df = pd.read_csv(file_path).select_dtypes("number")
corr = df.corr(numeric_only=True)
fig = px.imshow(
corr,
color_continuous_scale="RdBu",
title="Correlation Heat‑map",
aspect="auto",
labels=dict(color="ρ"),
template="plotly_dark",
)
return fig