afshin-dini's picture
add num/cat column selection to the base class of plots
1a62c25
"""These are the base classes for the AI Dashboard application."""
from typing import Any
from abc import ABC, abstractmethod
class BasePlotPlugin(ABC):
"""Abstract base class for plot plugins in the AI Dashboard."""
name = "Unnamed Plot"
def __init__(self, dataframe: Any) -> None:
"""Initialize with a dataframe."""
self.dataframe = dataframe
@abstractmethod
def controls(self) -> Any:
"""Return UI controls (dropdowns)."""
raise NotImplementedError
@abstractmethod
def render(self, **kwargs: Any) -> Any:
"""Return a dcc.Graph."""
raise NotImplementedError
@abstractmethod
def register_callbacks(self, app: Any) -> Any:
"""Register Dash callbacks for this plot."""
raise NotImplementedError
def numeric_columns(self) -> Any:
"""Return list of numeric column names in the dataframe."""
return self.dataframe.select_dtypes(include=["number"]).columns.tolist()
def categorical_columns(self) -> Any:
"""Return list of categorical column names in the dataframe."""
return self.dataframe.select_dtypes(exclude=["number"]).columns.tolist()
class BaseTablePlugin(ABC):
"""Abstract base class for table plugins in the AI Dashboard."""
name = "Unnamed Table"
def __init__(self, dataframe: Any) -> None:
"""Initialize with a dataframe."""
self.dataframe = dataframe
@abstractmethod
def render(self, **kwargs: Any) -> Any:
"""Return a dash_table.DataTable."""
raise NotImplementedError
@abstractmethod
def register_callbacks(self, app: Any) -> Any:
"""Register Dash callbacks for this table."""
raise NotImplementedError