or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-forecasting.mddiagnostics.mdholidays.mdindex.mdplotting.mdserialization.mdutilities.md

utilities.mddocs/

0

# Utilities

1

2

Helper functions for analyzing regressor coefficients, extracting model parameters, and supporting advanced Prophet model introspection and warm-starting capabilities.

3

4

## Capabilities

5

6

### Regressor Analysis

7

8

Functions for analyzing the impact and coefficients of external regressors.

9

10

```python { .api }

11

def regressor_coefficients(m):

12

"""

13

Summarize regressor coefficients with confidence intervals.

14

15

Parameters:

16

- m: Prophet, fitted Prophet model with regressors

17

18

Returns:

19

- DataFrame with regressor names, coefficients, and confidence intervals

20

"""

21

22

def regressor_index(m, name):

23

"""

24

Get the column index of a regressor in the beta matrix.

25

26

Parameters:

27

- m: Prophet, fitted Prophet model

28

- name: str, name of the regressor

29

30

Returns:

31

- int, column index of the regressor in model parameters

32

"""

33

```

34

35

### Model Parameter Extraction

36

37

Extract parameters for warm-starting new models or advanced analysis.

38

39

```python { .api }

40

def warm_start_params(m):

41

"""

42

Retrieve parameters from a fitted model for warm-starting a new model.

43

44

Parameters:

45

- m: Prophet, fitted Prophet model

46

47

Returns:

48

- dict, dictionary of parameters that can be used to initialize a new model

49

"""

50

```

51

52

## Usage Examples

53

54

### Regressor Coefficient Analysis

55

56

```python

57

from prophet import Prophet

58

from prophet.utilities import regressor_coefficients, regressor_index

59

60

# Create model with regressors

61

model = Prophet()

62

model.add_regressor('temperature')

63

model.add_regressor('humidity')

64

65

# Fit model with regressor data

66

model.fit(df_with_regressors)

67

68

# Analyze regressor coefficients

69

coeffs = regressor_coefficients(model)

70

print(coeffs)

71

# Output shows coefficient estimates and confidence intervals

72

73

# Get specific regressor index

74

temp_idx = regressor_index(model, 'temperature')

75

print(f"Temperature regressor is at index: {temp_idx}")

76

```

77

78

### Model Parameter Transfer

79

80

```python

81

from prophet.utilities import warm_start_params

82

83

# Train initial model

84

model1 = Prophet()

85

model1.fit(training_data)

86

87

# Extract parameters for warm start

88

params = warm_start_params(model1)

89

90

# Create new model with similar configuration

91

model2 = Prophet(

92

changepoint_prior_scale=model1.changepoint_prior_scale,

93

seasonality_prior_scale=model1.seasonality_prior_scale

94

)

95

96

# The warm start parameters can be used to initialize

97

# the new model's internal state for faster fitting

98

model2.fit(extended_training_data)

99

```

100

101

### Advanced Model Introspection

102

103

```python

104

# Examine all regressor effects

105

if model.extra_regressors:

106

print("Model has external regressors:")

107

for name, regressor_info in model.extra_regressors.items():

108

idx = regressor_index(model, name)

109

print(f" {name}: index {idx}, mode {regressor_info['mode']}")

110

111

# Get coefficient summary

112

coeff_summary = regressor_coefficients(model)

113

print("\nRegressor Coefficients:")

114

print(coeff_summary)

115

else:

116

print("Model has no external regressors")

117

```