Subsampling
Subsampler
Subsampler class.
It subsamples the data by using a subsampling method chosen among
- Static - subsamples data by taking one sample each step-samples
- WSDynamic - entropy based method with dynamic window size computed by breakpoint analysis
- WSFFTStatic - entropy based method with fixed window size computed by FFT analysis
- WSStatic - entropy base method with predefined window size
Source code in fpcmci/preprocessing/Subsampler.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
__init__(df, ss_method)
Subsampler class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df |
pd.DataFrame
|
dataframe to subsample |
required |
ss_method |
SubsamplingMethod
|
subsampling method |
required |
Source code in fpcmci/preprocessing/Subsampler.py
18 19 20 21 22 23 24 25 26 27 28 29 30 | |
plot_subsampled_data(dpi=100, show=True)
Plot dataframe sub-sampled data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dpi |
int
|
image dpi. Defaults to 100. |
100
|
show |
bool
|
if True it shows the figure and block the process. Defaults to True. |
True
|
Source code in fpcmci/preprocessing/Subsampler.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
subsample()
Runs the subsampling algorithm and returns the subsapled ndarray
Returns:
| Type | Description |
|---|---|
ndarray
|
Subsampled dataframe value |
Source code in fpcmci/preprocessing/Subsampler.py
33 34 35 36 37 38 39 40 41 | |
SubsamplingMethod
Bases: ABC
SubsamplingMethod abstract class
Source code in fpcmci/preprocessing/subsampling_methods/SubsamplingMethod.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
initialise(dataframe)
Initialise class by setting the dataframe to subsample
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe |
pd.DataFrame
|
description |
required |
Source code in fpcmci/preprocessing/subsampling_methods/SubsamplingMethod.py
22 23 24 25 26 27 28 29 | |
run()
abstractmethod
Run subsampler
Source code in fpcmci/preprocessing/subsampling_methods/SubsamplingMethod.py
32 33 34 35 36 37 | |
EntropyBasedMethod
Bases: ABC
EntropyBasedMethod abstract class
Source code in fpcmci/preprocessing/subsampling_methods/EntropyBasedMethod.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
__normalization()
Normalize entropy for each moving window
Source code in fpcmci/preprocessing/subsampling_methods/EntropyBasedMethod.py
28 29 30 31 32 33 34 | |
create_rounded_copy()
Create deepcopy of the dataframe but with rounded values
Returns:
| Type | Description |
|---|---|
pd.DataFrame
|
rounded dataframe |
Source code in fpcmci/preprocessing/subsampling_methods/EntropyBasedMethod.py
16 17 18 19 20 21 22 23 24 25 | |
dataset_segmentation()
abstractmethod
abstract method
Source code in fpcmci/preprocessing/subsampling_methods/EntropyBasedMethod.py
111 112 113 114 115 116 | |
extract_indexes()
Extract a list of indexes corresponding to the samples selected by the subsampling procedure
Source code in fpcmci/preprocessing/subsampling_methods/EntropyBasedMethod.py
98 99 100 101 102 103 104 105 106 107 108 | |
moving_window_analysis()
Compute dataframe entropy on moving windows
Source code in fpcmci/preprocessing/subsampling_methods/EntropyBasedMethod.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
WSDynamic
Bases: SubsamplingMethod, EntropyBasedMethod
Subsampling method with dynamic window size based on entropy analysis
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
__init__(window_min_size, entropy_threshold)
WSDynamic class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window_min_size |
int
|
minimun window size |
required |
entropy_threshold |
float
|
entropy threshold |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if window_min_size == None |
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
dataset_segmentation()
Segments dataset based on breakpoint analysis and a min window size
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
28 29 30 31 32 33 34 35 36 | |
run()
Run subsampler
Returns:
| Type | Description |
|---|---|
list[int]
|
indexes of the remaining samples |
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
WSDynamic
Bases: SubsamplingMethod, EntropyBasedMethod
Subsampling method with dynamic window size based on entropy analysis
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
__init__(window_min_size, entropy_threshold)
WSDynamic class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window_min_size |
int
|
minimun window size |
required |
entropy_threshold |
float
|
entropy threshold |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if window_min_size == None |
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
dataset_segmentation()
Segments dataset based on breakpoint analysis and a min window size
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
28 29 30 31 32 33 34 35 36 | |
run()
Run subsampler
Returns:
| Type | Description |
|---|---|
list[int]
|
indexes of the remaining samples |
Source code in fpcmci/preprocessing/subsampling_methods/WSDynamic.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
Static
Bases: SubsamplingMethod
Subsamples data by taking one sample each step-samples
Source code in fpcmci/preprocessing/subsampling_methods/Static.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
__init__(step)
Static class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step |
int
|
integer subsampling step |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if step == None |
Source code in fpcmci/preprocessing/subsampling_methods/Static.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
WSFFTStatic
Bases: SubsamplingMethod, EntropyBasedMethod
Subsampling method with static window size based on Fourier analysis
Source code in fpcmci/preprocessing/subsampling_methods/WSFFTStatic.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
__fourier_window()
Compute window size based on Fourier analysis performed on dataframe
Returns:
| Type | Description |
|---|---|
int
|
window size |
Source code in fpcmci/preprocessing/subsampling_methods/WSFFTStatic.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
__init__(sampling_time, entropy_threshold)
WSFFTStatic class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sampling_time |
float
|
timeseries sampling time |
required |
entropy_threshold |
float
|
entropy threshold |
required |
Source code in fpcmci/preprocessing/subsampling_methods/WSFFTStatic.py
14 15 16 17 18 19 20 21 22 23 24 | |
dataset_segmentation()
Segments dataset with a fixed window size
Source code in fpcmci/preprocessing/subsampling_methods/WSFFTStatic.py
50 51 52 53 54 55 56 57 58 | |
run()
Run subsampler
Returns:
| Type | Description |
|---|---|
list[int]
|
indexes of the remaining samples |
Source code in fpcmci/preprocessing/subsampling_methods/WSFFTStatic.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
WSStatic
Bases: SubsamplingMethod, EntropyBasedMethod
Entropy based subsampling method with static window size
Source code in fpcmci/preprocessing/subsampling_methods/WSStatic.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
__init__(window_size, entropy_threshold)
WSStatic class constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window_size |
int
|
minimun window size |
required |
entropy_threshold |
float
|
entropy threshold |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if window_size == None |
Source code in fpcmci/preprocessing/subsampling_methods/WSStatic.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
dataset_segmentation()
Segments dataset with a fixed window size
Source code in fpcmci/preprocessing/subsampling_methods/WSStatic.py
28 29 30 31 32 33 34 35 36 | |
run()
Run subsampler
Returns:
| Type | Description |
|---|---|
list[int]
|
indexes of the remaining samples |
Source code in fpcmci/preprocessing/subsampling_methods/WSStatic.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |