pdstools.adm.Reports ==================== .. py:module:: pdstools.adm.Reports Classes ------- .. autoapisummary:: pdstools.adm.Reports.Reports Module Contents --------------- .. py:class:: Reports(datamart: pdstools.adm.ADMDatamart.ADMDatamart) Bases: :py:obj:`pdstools.utils.namespaces.LazyNamespace` .. py:attribute:: dependencies :value: ['yaml'] .. py:attribute:: dependency_group :value: 'healthcheck' .. py:attribute:: datamart .. py:method:: model_reports(model_ids: Union[str, List[str]], *, name: Optional[str] = None, title: str = 'ADM Model Report', disclaimer: str = '', subtitle: str = '', output_dir: Optional[os.PathLike] = None, only_active_predictors: bool = True, output_type: str = 'html', keep_temp_files: bool = False, verbose: bool = False, progress_callback: Optional[Callable[[int, int], None]] = None, model_file_path: Optional[os.PathLike] = None, predictor_file_path: Optional[os.PathLike] = None, qmd_file: Optional[os.PathLike] = None, size_reduction_method: Optional[Literal['strip', 'cdn']] = 'cdn') -> pathlib.Path Generates model reports for Naive Bayes ADM models. :param model_ids: The model ID (or list of model IDs) to generate reports for. :type model_ids: Union[str,List[str]] :param name: The (base) file name of the report. :type name: str, optional :param title: Title to put in the report, uses a default string if not given. :type title: str, optional :param subtitle: Subtitle to put in the report, empty if not given. :type subtitle: str, optional :param disclaimer: Disclaimer blub to put in the report, empty if not given. :type disclaimer: str, optional :param output_dir: The directory for the output. If None, uses current working directory. :type output_dir: Union[str, Path, None], optional :param only_active_predictors: Whether to only include active predictor details. :type only_active_predictors: bool, default=True :param output_type: The type of the output file (e.g., "html", "pdf"). :type output_type: str, default='html' :param keep_temp_files: If True, the temporary directory with temp files will not be deleted after report generation. :type keep_temp_files: bool, optional :param verbose: If True, prints detailed logs during execution. :type verbose: bool, optional :param progress_callback: A callback function to report progress. Used only in the Streamlit app. The function should accept two integers: the current progress and the total. :type progress_callback: Callable[[int, int], None], optional :param model_file_path: Optional name of the actual model data file, so it does not get copied :type model_file_path: Union[str, Path, None], optional :param predictor_file_path: Optional name of the actual predictor data file, so it does not get copied :type predictor_file_path: Union[str, Path, None], optional :param qmd_file: Optional path to the Quarto file to use for the model report. If None, defaults to "ModelReport.qmd". :type qmd_file: Union[str, Path, None], optional :param size_reduction_method: When None will fully embed all resources into the HTML output. When "cdn" will pass this on to Quarto and Plotly so Javascript libraries will be loaded from the internet. When "strip" the HTML will be post-processed to remove duplicate Javascript that would otherwise get embedded multiple times. :type size_reduction_method: Optional[Literal["strip", "cdn"]], default="cdn" :returns: The path to the generated report file. :rtype: Path :raises ValueError: If there's an error in report generation or invalid parameters. :raises FileNotFoundError: If required files are not found. :raises subprocess.SubprocessError: If there's an error in running external commands. .. py:method:: health_check(name: Optional[str] = None, title: str = 'ADM Model Overview', subtitle: str = '', disclaimer: str = '', output_dir: Optional[os.PathLike] = None, *, query: Optional[pdstools.utils.types.QUERY] = None, output_type: str = 'html', keep_temp_files: bool = False, verbose: bool = False, prediction=None, model_file_path: Optional[os.PathLike] = None, predictor_file_path: Optional[os.PathLike] = None, prediction_file_path: Optional[os.PathLike] = None, qmd_file: Optional[os.PathLike] = None, size_reduction_method: Optional[Literal['strip', 'cdn']] = 'cdn') -> pathlib.Path Generates Health Check report for ADM models, optionally including predictor and prediction sections. :param name: The (base) file name of the report. :type name: str, optional :param title: Title to put in the report, uses a default string if not given. :type title: str, optional :param subtitle: Subtitle to put in the report, empty if not given. :type subtitle: str, optional :param disclaimer: Disclaimer blub to put in the report, empty if not given. :type disclaimer: str, optional :param query: Optional extra filter on the datamart data :type query: QUERY, optional :param output_dir: The directory for the output. If None, uses current working directory. :type output_dir: Union[str, Path, None], optional :param output_type: The type of the output file (e.g., "html", "pdf"). :type output_type: str, default='html' :param keep_temp_files: If True, the temporary directory with temp files will not be deleted after report generation. :type keep_temp_files: bool, optional :param verbose: If True, prints detailed logs during execution. :type verbose: bool, optional :param prediction: Optional Prediction object to include in the health check. If provided without prediction_file_path, the prediction data will be automatically cached to a temporary file. :type prediction: Prediction, optional :param model_file_path: Optional name of the actual model data file, so it does not get copied :type model_file_path: Union[str, Path, None], optional :param predictor_file_path: Optional name of the actual predictor data file, so it does not get copied :type predictor_file_path: Union[str, Path, None], optional :param prediction_file_path: Optional name of the actual predictions data file. If not provided but prediction object is given, the data will be automatically cached from the prediction object. :type prediction_file_path: Union[str, Path, None], optional :param qmd_file: Optional path to the Quarto file to use for the health check report. If None, defaults to "HealthCheck.qmd". :type qmd_file: Union[str, Path, None], optional :param size_reduction_method: When None will fully embed all resources into the HTML output. When "cdn" will pass this on to Quarto and Plotly so Javascript libraries will be loaded from the internet. When "strip" the HTML will be post-processed to remove duplicate Javascript that would otherwise get embedded multiple times. :type size_reduction_method: Optional[Literal["strip", "cdn"]], default="cdn" :returns: The path to the generated report file. :rtype: Path :raises ValueError: If there's an error in report generation or invalid parameters. :raises FileNotFoundError: If required files are not found. :raises subprocess.SubprocessError: If there's an error in running external commands. .. py:method:: excel_report(name: Union[pathlib.Path, str] = Path('Tables.xlsx'), predictor_binning: bool = False) -> tuple[Optional[pathlib.Path], list[str]] Export raw data to an Excel file. This method exports the last snapshots of model_data, predictor summary, and optionally predictor_binning data to separate sheets in an Excel file. If a specific table is not available or too large, it will be skipped without causing the export to fail. :param name: The path where the Excel file will be saved. Defaults to Path("Tables.xlsx"). :type name: Union[Path, str], optional :param predictor_binning: If True, include predictor_binning data in the export. This is the last snapshot of the raw data, so it can be big. Defaults to False. :type predictor_binning: bool, optional :returns: A tuple containing: - The path to the created Excel file if the export was successful, None if no data was available - A list of warning messages (empty if no warnings) :rtype: tuple[Union[Path, None], list[str]]