@@ -75,17 +75,17 @@ def __init__(
7575 """
7676 Initialize the AnomalyDetectionPlot component.
7777
78- Args :
79- ts_data: PySpark DataFrame with 'timestamp' and 'value' columns
80- ad_data: PySpark DataFrame with 'timestamp' and 'value' columns
81- sensor_id: Optional sensor identifier
82- title: Optional custom title
83- figsize: Figure size tuple
84- linewidth: Line width for the time series
85- anomaly_marker_size: Size of anomaly markers
86- anomaly_color: Color for anomaly points
87- ts_color: Color for time series line
88- ax: Optional existing matplotlib axis to plot on
78+ Parameters :
79+ ts_data (SparkDataFrame) : PySpark DataFrame with 'timestamp' and 'value' columns.
80+ ad_data (SparkDataFrame) : PySpark DataFrame with 'timestamp' and 'value' columns.
81+ sensor_id (str, optional): Sensor identifier used in the plot title.
82+ title (str, optional): Custom plot title. If not provided, a default title is used.
83+ figsize (tuple, optional) : Figure size as (width, height). Defaults to (18, 6).
84+ linewidth (float, optional) : Line width for time series. Defaults to 1.6.
85+ anomaly_marker_size (int, optional): Marker size for anomalies. Defaults to 70.
86+ anomaly_color (str, optional) : Color for anomaly markers. Defaults to "red".
87+ ts_color (str, optional) : Color for time series line. Defaults to "steelblue".
88+ ax (matplotlib.axes.Axes, optional): Existing matplotlib axis to plot on.
8989 """
9090 super ().__init__ ()
9191
@@ -106,7 +106,13 @@ def __init__(
106106 self ._validate_data ()
107107
108108 def _validate_data (self ) -> None :
109- """Validate that required columns exist in DataFrames."""
109+ """
110+ Validate input data format and data types.
111+
112+ Ensures that both `ts_data` and `ad_data` contain the required columns
113+ {'timestamp', 'value'}. Automatically converts timestamp columns to
114+ datetime and value columns to numeric types when necessary.
115+ """
110116 required_cols = {"timestamp" , "value" }
111117
112118 if not required_cols .issubset (self .ts_data .columns ):
@@ -146,11 +152,12 @@ def plot(self, ax: Optional[Axes] = None) -> Figure | SubFigure:
146152 """
147153 Generate the anomaly detection visualization.
148154
149- Args:
150- ax: Optional matplotlib axis to plot on. If None, creates new figure.
155+ Parameters:
156+ ax (matplotlib.axes.Axes, optional): Existing matplotlib axis to plot on.
157+ If None, a new figure and axis are created.
151158
152159 Returns:
153- matplotlib.figure. Figure: The generated figure
160+ Figure | SubFigure : The generated matplotlib figure containing the plot.
154161 """
155162 # Use provided ax or instance ax
156163 use_ax = ax if ax is not None else self .ax
@@ -214,13 +221,13 @@ def save(
214221 """
215222 Save the visualization to file.
216223
217- Args :
218- filepath (Union[str, Path]): Output file path
219- dpi (int): Dots per inch. Defaults to 150
220- **kwargs (Any): Additional arguments passed to savefig
224+ Parameters :
225+ filepath (Union[str, Path]): Output file path.
226+ dpi (int, optional ): Dots per inch for the saved figure . Defaults to 150.
227+ **kwargs (Any): Additional keyword arguments passed to `matplotlib.pyplot. savefig`.
221228
222229 Returns:
223- Path: The path to the saved file
230+ Path: Path to the saved figure file.
224231 """
225232
226233 assert self ._fig is not None , "Plot the figure before saving."
0 commit comments