API Reference

This page contains the API reference for all public functions in incline.

Main Trend Estimation Functions

incline.trend.compute_time_deltas(time_index)[source]

Compute time deltas from a pandas time index.

Returns:

Numeric time values (days from start) delta: Median time step for scaling

Return type:

x

Parameters:

time_index (Index)

incline.trend.naive_trend(df, column_value='value', time_column=None)[source]

naive_trend.

Gives the naive slope: look to the right, look to the left, travel one unit each, and get the average change. At the ends, we merely use the left or the right value.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

incline.trend.spline_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, s=None, use_gcv=False)[source]

spline_trend.

Interpolates time series with splines of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • function_order – spline order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • s – smoothing factor (if None, auto-estimated)

  • use_gcv – use generalized cross-validation (requires scipy>=1.10)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

A row can be 2012-01-01, “spline”, 2, 1, 0

Return type:

DataFrame

incline.trend.sgolay_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, window_length=15, delta=None)[source]

sgolay_trend.

Interpolates time series with savitzky-golay using polynomials of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • window_length – window size (default is 15, must be odd)

  • function_order – polynomial order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • delta – time step for derivative scaling (auto-computed if None)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

Sample row: 2012-01-01, “sgolay”, 2, 1, 0

Return type:

DataFrame

incline.trend.trending(df_list, column_id='id', derivative_order=1, max_or_avg='max', k=5, robust=False, trim_fraction=0.1, weighting='uniform', confidence_level=0.95, return_confidence=False)[source]

Enhanced trending analysis with robust statistics.

For each item in the list, calculate either the max, average, or robust statistic (depending on max_or_avg and robust parameters) of the Yth derivative over the last k time periods. Orders by trend strength.

Parameters:
  • df_list (list) – List of dataframes from trend estimation functions with ‘id’ column

  • column_id (str) – Column name for identifying time series

  • derivative_order (int) – Order of derivative (1 or 2)

  • max_or_avg (str) – Aggregation method (‘max’, ‘avg’, ‘median’, ‘trimmed_mean’, ‘huber’)

  • k (int) – Number of latest time periods to consider

  • robust (bool) – Use robust statistics to handle outliers

  • trim_fraction (float) – Fraction to trim for trimmed_mean (0-0.5)

  • weighting (str) – Weighting scheme (‘uniform’, ‘linear’, ‘exponential’)

  • confidence_level (float) – Confidence level for bootstrap confidence intervals

  • return_confidence (bool) – Whether to return confidence intervals and significance tests

  • Returns

  • -------

  • pd.DataFrame – DataFrame with ranking results and optional confidence metrics

incline.trend.bootstrap_derivative_ci(df, column_value='value', time_column=None, method='spline', n_bootstrap=100, confidence_level=0.95, block_size=None, **method_kwargs)[source]

Estimate confidence intervals for derivatives using block bootstrap.

This handles autocorrelation in time series by using block bootstrap.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • n_bootstrap (int) – Number of bootstrap samples

  • confidence_level (float) – Confidence level (e.g., 0.95 for 95% CI)

  • block_size (int, optional) – Block size for bootstrap. If None, uses sqrt(n)

  • **method_kwargs – Additional arguments for the trend method

  • Returns

  • -------

  • pd.DataFrame – Original results plus CI columns

Return type:

DataFrame

incline.trend.select_smoothing_parameter_cv(df, column_value='value', time_column=None, method='spline', param_name='s', param_range=None, cv_folds=5, **method_kwargs)[source]

Select smoothing parameter using cross-validation.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • param_name (str) – Parameter to optimize (‘s’ for spline, ‘window_length’ for sgolay)

  • param_range (array-like, optional) – Range of parameters to test

  • cv_folds (int) – Number of CV folds

  • Returns

  • -------

  • best_param (float) – Optimal parameter value

  • cv_results (pd.DataFrame) – CV scores for each parameter

Return type:

tuple[float, DataFrame]

Advanced Functions

incline.trend.compute_time_deltas(time_index)[source]

Compute time deltas from a pandas time index.

Returns:

Numeric time values (days from start) delta: Median time step for scaling

Return type:

x

Parameters:

time_index (Index)

incline.trend.naive_trend(df, column_value='value', time_column=None)[source]

naive_trend.

Gives the naive slope: look to the right, look to the left, travel one unit each, and get the average change. At the ends, we merely use the left or the right value.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

incline.trend.spline_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, s=None, use_gcv=False)[source]

spline_trend.

Interpolates time series with splines of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • function_order – spline order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • s – smoothing factor (if None, auto-estimated)

  • use_gcv – use generalized cross-validation (requires scipy>=1.10)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

A row can be 2012-01-01, “spline”, 2, 1, 0

Return type:

DataFrame

incline.trend.sgolay_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, window_length=15, delta=None)[source]

sgolay_trend.

Interpolates time series with savitzky-golay using polynomials of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • window_length – window size (default is 15, must be odd)

  • function_order – polynomial order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • delta – time step for derivative scaling (auto-computed if None)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

Sample row: 2012-01-01, “sgolay”, 2, 1, 0

Return type:

DataFrame

incline.trend.trending(df_list, column_id='id', derivative_order=1, max_or_avg='max', k=5, robust=False, trim_fraction=0.1, weighting='uniform', confidence_level=0.95, return_confidence=False)[source]

Enhanced trending analysis with robust statistics.

For each item in the list, calculate either the max, average, or robust statistic (depending on max_or_avg and robust parameters) of the Yth derivative over the last k time periods. Orders by trend strength.

Parameters:
  • df_list (list) – List of dataframes from trend estimation functions with ‘id’ column

  • column_id (str) – Column name for identifying time series

  • derivative_order (int) – Order of derivative (1 or 2)

  • max_or_avg (str) – Aggregation method (‘max’, ‘avg’, ‘median’, ‘trimmed_mean’, ‘huber’)

  • k (int) – Number of latest time periods to consider

  • robust (bool) – Use robust statistics to handle outliers

  • trim_fraction (float) – Fraction to trim for trimmed_mean (0-0.5)

  • weighting (str) – Weighting scheme (‘uniform’, ‘linear’, ‘exponential’)

  • confidence_level (float) – Confidence level for bootstrap confidence intervals

  • return_confidence (bool) – Whether to return confidence intervals and significance tests

  • Returns

  • -------

  • pd.DataFrame – DataFrame with ranking results and optional confidence metrics

incline.trend.bootstrap_derivative_ci(df, column_value='value', time_column=None, method='spline', n_bootstrap=100, confidence_level=0.95, block_size=None, **method_kwargs)[source]

Estimate confidence intervals for derivatives using block bootstrap.

This handles autocorrelation in time series by using block bootstrap.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • n_bootstrap (int) – Number of bootstrap samples

  • confidence_level (float) – Confidence level (e.g., 0.95 for 95% CI)

  • block_size (int, optional) – Block size for bootstrap. If None, uses sqrt(n)

  • **method_kwargs – Additional arguments for the trend method

  • Returns

  • -------

  • pd.DataFrame – Original results plus CI columns

Return type:

DataFrame

incline.trend.select_smoothing_parameter_cv(df, column_value='value', time_column=None, method='spline', param_name='s', param_range=None, cv_folds=5, **method_kwargs)[source]

Select smoothing parameter using cross-validation.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • param_name (str) – Parameter to optimize (‘s’ for spline, ‘window_length’ for sgolay)

  • param_range (array-like, optional) – Range of parameters to test

  • cv_folds (int) – Number of CV folds

  • Returns

  • -------

  • best_param (float) – Optimal parameter value

  • cv_results (pd.DataFrame) – CV scores for each parameter

Return type:

tuple[float, DataFrame]

Utility Functions

incline.trend.compute_time_deltas(time_index)[source]

Compute time deltas from a pandas time index.

Returns:

Numeric time values (days from start) delta: Median time step for scaling

Return type:

x

Parameters:

time_index (Index)

incline.trend.naive_trend(df, column_value='value', time_column=None)[source]

naive_trend.

Gives the naive slope: look to the right, look to the left, travel one unit each, and get the average change. At the ends, we merely use the left or the right value.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

incline.trend.spline_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, s=None, use_gcv=False)[source]

spline_trend.

Interpolates time series with splines of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • function_order – spline order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • s – smoothing factor (if None, auto-estimated)

  • use_gcv – use generalized cross-validation (requires scipy>=1.10)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

A row can be 2012-01-01, “spline”, 2, 1, 0

Return type:

DataFrame

incline.trend.sgolay_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, window_length=15, delta=None)[source]

sgolay_trend.

Interpolates time series with savitzky-golay using polynomials of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • window_length – window size (default is 15, must be odd)

  • function_order – polynomial order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • delta – time step for derivative scaling (auto-computed if None)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

Sample row: 2012-01-01, “sgolay”, 2, 1, 0

Return type:

DataFrame

incline.trend.trending(df_list, column_id='id', derivative_order=1, max_or_avg='max', k=5, robust=False, trim_fraction=0.1, weighting='uniform', confidence_level=0.95, return_confidence=False)[source]

Enhanced trending analysis with robust statistics.

For each item in the list, calculate either the max, average, or robust statistic (depending on max_or_avg and robust parameters) of the Yth derivative over the last k time periods. Orders by trend strength.

Parameters:
  • df_list (list) – List of dataframes from trend estimation functions with ‘id’ column

  • column_id (str) – Column name for identifying time series

  • derivative_order (int) – Order of derivative (1 or 2)

  • max_or_avg (str) – Aggregation method (‘max’, ‘avg’, ‘median’, ‘trimmed_mean’, ‘huber’)

  • k (int) – Number of latest time periods to consider

  • robust (bool) – Use robust statistics to handle outliers

  • trim_fraction (float) – Fraction to trim for trimmed_mean (0-0.5)

  • weighting (str) – Weighting scheme (‘uniform’, ‘linear’, ‘exponential’)

  • confidence_level (float) – Confidence level for bootstrap confidence intervals

  • return_confidence (bool) – Whether to return confidence intervals and significance tests

  • Returns

  • -------

  • pd.DataFrame – DataFrame with ranking results and optional confidence metrics

incline.trend.bootstrap_derivative_ci(df, column_value='value', time_column=None, method='spline', n_bootstrap=100, confidence_level=0.95, block_size=None, **method_kwargs)[source]

Estimate confidence intervals for derivatives using block bootstrap.

This handles autocorrelation in time series by using block bootstrap.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • n_bootstrap (int) – Number of bootstrap samples

  • confidence_level (float) – Confidence level (e.g., 0.95 for 95% CI)

  • block_size (int, optional) – Block size for bootstrap. If None, uses sqrt(n)

  • **method_kwargs – Additional arguments for the trend method

  • Returns

  • -------

  • pd.DataFrame – Original results plus CI columns

Return type:

DataFrame

incline.trend.select_smoothing_parameter_cv(df, column_value='value', time_column=None, method='spline', param_name='s', param_range=None, cv_folds=5, **method_kwargs)[source]

Select smoothing parameter using cross-validation.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • param_name (str) – Parameter to optimize (‘s’ for spline, ‘window_length’ for sgolay)

  • param_range (array-like, optional) – Range of parameters to test

  • cv_folds (int) – Number of CV folds

  • Returns

  • -------

  • best_param (float) – Optimal parameter value

  • cv_results (pd.DataFrame) – CV scores for each parameter

Return type:

tuple[float, DataFrame]

Function Details

Core Trend Functions

naive_trend

incline.trend.naive_trend(df, column_value='value', time_column=None)[source]

naive_trend.

Gives the naive slope: look to the right, look to the left, travel one unit each, and get the average change. At the ends, we merely use the left or the right value.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

spline_trend

incline.trend.spline_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, s=None, use_gcv=False)[source]

spline_trend.

Interpolates time series with splines of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • function_order – spline order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • s – smoothing factor (if None, auto-estimated)

  • use_gcv – use generalized cross-validation (requires scipy>=1.10)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

A row can be 2012-01-01, “spline”, 2, 1, 0

Return type:

DataFrame

sgolay_trend

incline.trend.sgolay_trend(df, column_value='value', time_column=None, function_order=3, derivative_order=1, window_length=15, delta=None)[source]

sgolay_trend.

Interpolates time series with savitzky-golay using polynomials of ‘function_order’. And then calculates the derivative_order using the smoothed function.

Parameters:
  • df – pandas dataFrame time series object

  • column_value – column name containing the values

  • time_column – column name for time values (optional)

  • window_length – window size (default is 15, must be odd)

  • function_order – polynomial order (default is 3)

  • derivative_order – (0, 1, 2, … with default as 1)

  • delta – time step for derivative scaling (auto-computed if None)

Returns:

dataframe with 6 columns:- datetime,

function_order (value of the polynomial order), smoothed_value, derivative_method, derivative_order, derivative_value.

Sample row: 2012-01-01, “sgolay”, 2, 1, 0

Return type:

DataFrame

Statistical Functions

bootstrap_derivative_ci

incline.trend.bootstrap_derivative_ci(df, column_value='value', time_column=None, method='spline', n_bootstrap=100, confidence_level=0.95, block_size=None, **method_kwargs)[source]

Estimate confidence intervals for derivatives using block bootstrap.

This handles autocorrelation in time series by using block bootstrap.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • n_bootstrap (int) – Number of bootstrap samples

  • confidence_level (float) – Confidence level (e.g., 0.95 for 95% CI)

  • block_size (int, optional) – Block size for bootstrap. If None, uses sqrt(n)

  • **method_kwargs – Additional arguments for the trend method

  • Returns

  • -------

  • pd.DataFrame – Original results plus CI columns

Return type:

DataFrame

select_smoothing_parameter_cv

incline.trend.select_smoothing_parameter_cv(df, column_value='value', time_column=None, method='spline', param_name='s', param_range=None, cv_folds=5, **method_kwargs)[source]

Select smoothing parameter using cross-validation.

Parameters:
  • df (pd.DataFrame) – Time series data

  • column_value (str) – Value column

  • time_column (str, optional) – Time column name

  • method (str) – ‘spline’ or ‘sgolay’

  • param_name (str) – Parameter to optimize (‘s’ for spline, ‘window_length’ for sgolay)

  • param_range (array-like, optional) – Range of parameters to test

  • cv_folds (int) – Number of CV folds

  • Returns

  • -------

  • best_param (float) – Optimal parameter value

  • cv_results (pd.DataFrame) – CV scores for each parameter

Return type:

tuple[float, DataFrame]

Utility Functions

compute_time_deltas

incline.trend.compute_time_deltas(time_index)[source]

Compute time deltas from a pandas time index.

Returns:

Numeric time values (days from start) delta: Median time step for scaling

Return type:

x

Parameters:

time_index (Index)