
    %g'                     :    d dl mZmZmZ d dlZd dlZd Zd Z	d Z
y)    )absolute_importdivisionprint_functionNc                 |    t        j                  | j                  |   dk(  | j                  j                        d   S )aA  Given the name of a regressor, return its (column) index in the `beta` matrix.

    Parameters
    ----------
    m: Prophet model object, after fitting.
    name: Name of the regressor, as passed into the `add_regressor` function.

    Returns
    -------
    The column index of the regressor in the `beta` matrix.
       r   )npextracttrain_component_colsindex)mnames     N/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/prophet/utilities.pyregressor_indexr      s>     ::	t$)1+A+A+G+G	 	    c                 ,   t        | j                        dkD  sJ d       g }| j                  j                         D ]  \  }}| j                  d   ddt	        | |      f   }|d   dk(  r|| j
                  z  |d   z  }n||d   z  }d| j                  z
  d	z  dd| j                  z
  d	z  z
  g}t        j                  ||
      }||d   |d   |d   t        j                  |      |d   d}|j                  |        t        j                  |      S )a1  Summarise the coefficients of the extra regressors used in the model.

    For additive regressors, the coefficient represents the incremental impact
    on `y` of a unit increase in the regressor. For multiplicative regressors,
    the incremental impact is equal to `trend(t)` multiplied by the coefficient.

    Coefficients are measured on the original scale of the training data.

    Parameters
    ----------
    m: Prophet model object, after fitting.

    Returns
    -------
    pd.DataFrame containing:
    - `regressor`: Name of the regressor
    - `regressor_mode`: Whether the regressor has an additive or multiplicative
        effect on `y`.
    - `center`: The mean of the regressor if it was standardized. Otherwise 0.
    - `coef_lower`: Lower bound for the coefficient, estimated from the MCMC samples.
        Only different to `coef` if `mcmc_samples > 0`.
    - `coef`: Expected value of the coefficient.
    - `coef_upper`: Upper bound for the coefficient, estimated from MCMC samples.
        Only to different to `coef` if `mcmc_samples > 0`.
    r   zNo extra regressors found.betaNmodeadditivestdr      )qmu)	regressorregressor_modecenter
coef_lowercoef
coef_upper)lenextra_regressorsitemsparamsr   y_scaleinterval_widthr   quantilemeanappendpd	DataFrame)	r   coefsr   r"   r   r   percentilescoef_boundsrecords	            r   regressor_coefficientsr.      s/   4 q!!"Q&D(DD&E//557 	6xx?1i#@ @A&>Z'!))#fUm3D&-'D!!!Q&Q%%%**
 kk$+6"$VnTl%a.GGDM%a.
 	V'* <<r   c                 X   i }dD ]O  }| j                   dk(  r| j                  |   d   d   ||<   +t        j                  | j                  |         ||<   Q dD ]N  }| j                   dk(  r| j                  |   d   ||<   (t        j                  | j                  |   d      ||<   P |S )a  
    Retrieve parameters from a trained model in the format used to initialize a new Stan model.
    Note that the new Stan model must have these same settings:
        n_changepoints, seasonality features, mcmc sampling
    for the retrieved parameters to be valid for the new model.

    Parameters
    ----------
    m: A trained model of the Prophet class.

    Returns
    -------
    A Dictionary containing retrieved parameters of m.
    )kr   	sigma_obsr   )deltar   )axis)mcmc_samplesr"   r   r&   )r   respnames      r   warm_start_paramsr7   O   s     C( 2>>Q%+A.CJ%1CJ	2
 # :>>Q%+CJ%q9CJ	:
 Jr   )
__future__r   r   r   numpyr   pandasr(   r   r.   r7    r   r   <module>r<      s$    A @  	 1fr   