orbit/template/ktr.py [1586:1676]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            BaseSamplingParameters.LEVEL.value
        )
        levs = np.squeeze(levs, 0)
        out = {
            date_col: date_array,
            BaseSamplingParameters.LEVEL.value: levs,
        }

        return pd.DataFrame(out)

    @orbit_style_decorator
    def plot_lev_knots(
        self,
        training_meta,
        point_method,
        point_posteriors,
        posterior_samples,
        path=None,
        is_visible=True,
        title="",
        fontsize=16,
        markersize=250,
        figsize=(16, 8),
    ):
        """Plot the fitted level knots along with the actual time series.
         Parameters
         ----------
         path : str; optional
             path to save the figure
         is_visible : boolean
             whether we want to show the plot. If called from unittest, is_visible might = False.
         title : str; optional
             title of the plot
         fontsize : int; optional
             fontsize of the title
         markersize : int; optional
             knot marker size
         figsize : tuple; optional
             figsize passed to `matplotlib.pyplot.figure()`
        Returns
         -------
             matplotlib axes object
        """
        date_col = training_meta[TrainingMetaKeys.DATE_COL.value]
        date_array = training_meta[TrainingMetaKeys.DATE_ARRAY.value]
        response = training_meta[TrainingMetaKeys.RESPONSE.value]

        levels_df = self.get_levels(
            training_meta, point_method, point_posteriors, posterior_samples
        )
        knots_df = self.get_level_knots(
            training_meta, point_method, point_posteriors, posterior_samples
        )

        fig, ax = plt.subplots(1, 1, figsize=figsize)
        ax.plot(
            date_array,
            response,
            color=OrbitPalette.BLUE.value,
            lw=1,
            alpha=0.7,
            label="actual",
        )
        ax.plot(
            levels_df[date_col],
            levels_df[BaseSamplingParameters.LEVEL.value],
            color=OrbitPalette.BLACK.value,
            lw=1,
            alpha=0.8,
            label=BaseSamplingParameters.LEVEL.value,
        )
        ax.scatter(
            knots_df[date_col],
            knots_df[BaseSamplingParameters.LEVEL_KNOT.value],
            color=OrbitPalette.GREEN.value,
            lw=1,
            s=markersize,
            marker="^",
            alpha=0.8,
            label=BaseSamplingParameters.LEVEL_KNOT.value,
        )
        ax.legend()
        ax.grid(True, which="major", c="grey", ls="-", lw=1, alpha=0.5)
        ax.set_title(title, fontsize=fontsize)
        if path:
            fig.savefig(path)
        if is_visible:
            plt.show()
        else:
            plt.close()
        return ax
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



orbit/template/ktrlite.py [549:639]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            BaseSamplingParameters.LEVEL.value
        )
        levs = np.squeeze(levs, 0)
        out = {
            date_col: date_array,
            BaseSamplingParameters.LEVEL.value: levs,
        }

        return pd.DataFrame(out)

    @orbit_style_decorator
    def plot_lev_knots(
        self,
        training_meta,
        point_method,
        point_posteriors,
        posterior_samples,
        path=None,
        is_visible=True,
        title="",
        fontsize=16,
        markersize=250,
        figsize=(16, 8),
    ):
        """Plot the fitted level knots along with the actual time series.
         Parameters
         ----------
         path : str; optional
             path to save the figure
         is_visible : boolean
             whether we want to show the plot. If called from unittest, is_visible might = False.
         title : str; optional
             title of the plot
         fontsize : int; optional
             fontsize of the title
         markersize : int; optional
             knot marker size
         figsize : tuple; optional
             figsize passed to `matplotlib.pyplot.figure()`
        Returns
         -------
             matplotlib axes object
        """
        date_col = training_meta[TrainingMetaKeys.DATE_COL.value]
        date_array = training_meta[TrainingMetaKeys.DATE_ARRAY.value]
        response = training_meta[TrainingMetaKeys.RESPONSE.value]

        levels_df = self.get_levels(
            training_meta, point_method, point_posteriors, posterior_samples
        )
        knots_df = self.get_level_knots(
            training_meta, point_method, point_posteriors, posterior_samples
        )

        fig, ax = plt.subplots(1, 1, figsize=figsize)
        ax.plot(
            date_array,
            response,
            color=OrbitPalette.BLUE.value,
            lw=1,
            alpha=0.7,
            label="actual",
        )
        ax.plot(
            levels_df[date_col],
            levels_df[BaseSamplingParameters.LEVEL.value],
            color=OrbitPalette.BLACK.value,
            lw=1,
            alpha=0.8,
            label=BaseSamplingParameters.LEVEL.value,
        )
        ax.scatter(
            knots_df[date_col],
            knots_df[BaseSamplingParameters.LEVEL_KNOT.value],
            color=OrbitPalette.GREEN.value,
            lw=1,
            s=markersize,
            marker="^",
            alpha=0.8,
            label=BaseSamplingParameters.LEVEL_KNOT.value,
        )
        ax.legend()
        ax.grid(True, which="major", c="grey", ls="-", lw=1, alpha=0.5)
        ax.set_title(title, fontsize=fontsize)
        if path:
            fig.savefig(path)
        if is_visible:
            plt.show()
        else:
            plt.close()
        return ax
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



