Package: changepoint-cython
changepoint_cythonA cython version of the changepoint and  changepoint.np R package, seehttps://github.com/cran/changepointandhttps://github.com/cran/changepoint.np.Implemented algorithms:Binary Segmentation, PELT, and Segmentation Neigborhood: monovariate and multivariate time series.Non parametric PELT: monovariate variate.Model implemented for the monovariate case :Normal (mean, variance, or mean and variance).Poisson (mean and variance).Exponential (mean and variance).Model implemented for the multivariate case :Normal (mean).Working on Windows/Linux and python3.xInstallPyPISource available onhttps://pypi.org/project/changepoint-cython/pipinstallchangepoint-cythonFrom sourceDownload and run:pip3install-rrequirements.txt
pip3install.TestsSynthetic examplespython3test_segmentation.py

python3test_segmentation_multiple.pyTest on well bore dataSee notebook "segmentation example on well log data.ipynb"importpandasaspdimportnumpyasnpimportlasiofrompychangepointsimportcython_pelt,algo_changepointsLoading and cleaning datawell_log_las=lasio.read('./data/2120913D.las')well_log_df=well_log_las.df()list_var=['GR','NPOR','RHOZ','PEFZ']well_log_data=well_log_df[list_var]well_log_data=well_log_data[well_log_data>-1]well_log_data.dropna(inplace=True)well_log_data=well_log_data[well_log_data.index>6542]Segmentation with PELT for multivariate time series.penalty_value=5min_segment_size=20model='mbic_mean'list_cpts,nb_cpts=algo_changepoints.pelt_multiple(well_log_data,penalty_value,min_segment_size,model)DocumentationPELTInputs:data: data as pandas dataframe,penalty_value: double, penalty value, (BIC penalty),min_segment_size: int, minimum segment size,model: str, statistical model (see cost_function.pxd).Outputs:list_cpts: array of the postion of the change-points,nb_cpts: number of chnagepoint.Usage:frompychangepointsimportalgo_changepointspenalty_value=5min_segment_size=20model='mbic_mean'list_cpts,nb_cpts=algo_changepoints.pelt(data,penalty_value,min_segment_size,model)For the multivariate case, call pelt_multiple:frompychangepointsimportalgo_changepointspenalty_value=5min_segment_size=20model='mbic_mean'list_cpts,nb_cpts=algo_changepoints.pelt_multiple(data,penalty_value,min_segment_size,model)NP PELTInputs:data: as pandas dataframe,penalty_value: double, penalty value, (BIC penalty),min_segment_size: int, minimum segment size,nquantiles: int, number of quantiles,method: str, cost functioon (optional, only one implemented).Outputs:list_cpts, array of the postion of the change-pointsnb_cpts, number of chnagepoint.Usage:frompychangepointsimportalgo_changepointspenalty_value=5min_segment_size=20model='mbic_nonparametric_ed'nquantiles=10list_cpts,nb_cpts=algo_changepoints.np_pelt(data,penalty_value,min_segment_size,nquantiles,method=model)Binary SegmentationInputs:data: pandas dataframe,Q: int, number of changepoints,min_segment_size: int, minimum segment size,statistical model, str (see cost_function.pxd).Output:array of the postion of the change-points,Usage:frompychangepointsimportalgo_changepointsQ=5min_segment_size=20model='mbic_mean'list_cpts=algo_changepoints.binseg(data,Q,minseg,method)For the multivariate case, call binseg_multiple:frompychangepointsimportalgo_changepointsQ=5min_segment_size=20model='mbic_mean'list_cpts=algo_changepoints.binseg_multiple(data,Q,minseg,method)Segmentation neighborhoodInputs:data: pandas dataframe,Q: int, number of changepoints,statistical model, str (see cost_function.pxd).Output:array of the postion of the change-points,Usage:frompychangepointsimportalgo_changepointsQ=5model='mbic_mean'list_cpts=algo_changepoints.segneigh(data,Q,method)For the multivariate case, call segneigh_multiple:frompychangepointsimportalgo_changepointsQ=5model='mbic_mean'list_cpts=algo_changepoints.segneigh_multiple(data,Q,method)