seg1d.Segmenter

class seg1d.Segmenter[source]

Segmentation class that exposes all algorithm parameters and attributes for advanced access and tuning of segmentation.

Additional convenience methods for adding reference and target data as numpy arrays are provided.

Results of each step of the algorithm process can be accessed through the class Attributes after running the segmentation. These can likewise be passed to the algorithms methods described in the documentation.

Examples

Simple usage of the class by directly assigning attributes using sample data included with this package.

>>> import seg1d
>>> import numpy as np
>>> 
>>> #Make an instance of the segmenter
>>> s = seg1d.Segmenter()
>>> 
>>> #retrieve the sample reference, target, and weight data
>>> s.r,s.t,s.w = seg1d.sampleData()
>>> 
>>> #set the parameters
>>> s.minW,s.maxW,s.step = 70, 150, 1
>>>
>>> np.around(s.segment(), decimals=7)
array([[207.       , 240.       ,   0.9124224],
       [342.       , 381.       ,   0.8801901],
       [ 72.       , 112.       ,   0.8776795]])
__init__()[source]

Initialization of segmentation class and parameters

Attributes:
rarray of dicts

The reference dataset

tdict

The target dataset

wdict

Weights for correlation

minWint

minimum percent to scale data

maxWint

maximum percent to scale data

stepint

step size for rolling correlation

wSizeslist

sizes to use for resampling reference (can be used instead of minW,maxW,step)

cMaxbool

use maximum in rolling correlation (default False)

cMinfloat

-1 to 1, min correlation

cAddfloat

0 to 1 or None, value to add for forcing clusters (Default 0.5)

pDNone

peak distance to use for scipy peak detection (Default None)

nCint

number of clusters for correlation results

fMode{‘w’, ‘m’, ‘s’}

keyword to use for aggregating feature correlations (default w). Options, w=weighted mean, m=mean, s=sum

fScalebool

scale the feature correlation by its weight before feature aggregation (Default True)

tSeg[]

the target data as segmented arrays

Methods

__init__() Initialization of segmentation class and parameters
add_reference(r[, copy]) Appends a reference containing one or more features to the existing reference dataset.
clear_reference() Removes any reference data currently assigned
segment() Method to run the segmentation algorithm on the current Segmenter instance
set_target(t[, copy]) Sets the target data by overiding any existing target.

Attributes

clusters Segments reduced by clustering algorithm from algorithm.cluster()
combined The averaged correlation of the rolling feature correlation and the weighting table created by algorithm.combine_corr()
corrs Rolling correlation of reference and target features created by algorithm.rolling_corr()
groups Possible segments through parsing overlapping segment locations defined by algorithm.uniques()
peaks Peaks of the correlations created by algorithm.get_peaks()
t_masked The target data as ndarray masked with the non-defined segments as NaNs.
t_segments Returns an array of segmented target data

Previous topic

Segmenter Class

Next topic

Segmenter Methods