API Reference¶
This page is automatically generated from the docstrings in our code.
pyecoacc.models.pipeline
¶
get_default_random_forest_pipeline()
¶
Builds a default Random Forest classification pipeline (250 trees) with ACC stats features.
Returns:
| Name | Type | Description |
|---|---|---|
Model |
Pipeline
|
A pipeline object with the default model. |
Source code in pyecoacc/models/pipeline.py
43 44 45 46 47 48 49 50 51 52 | |
make_classifier_pipeline(features, model, feature_scaler=False, feature_selector=False, k_selection=25)
¶
Make a custom classification pipeline with optional feature scaling and selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
Transformer
|
transforms the raw data into features, for example the pyecoacc ACCStatsTransformer object. |
required |
model
|
Estimator
|
the classification model to use. For example, an sklearn RandomForestClassifier object. |
required |
feature_scaler
|
bool
|
If True, applies StandardScaler to the features. Defaults to False. |
False
|
feature_selector
|
bool
|
if True, applies SelectKBest to the features. Defaults to False. |
False
|
k_selection
|
int
|
The number of top features to select. Defaults to 25. |
25
|
Returns:
| Name | Type | Description |
|---|---|---|
Model |
Pipeline
|
A pipeline object with the specified model. |
Source code in pyecoacc/models/pipeline.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 38 39 40 | |
pyecoacc.models.deep.cnn
¶
BehaviorCNNClassifier(num_classes, sequence_length, conv_filters=[32, 64, 128, 256], fc_layers=[256, 512], kernel_size=5)
¶
Bases: Module
A Convolutional Neural Network for classifying behaviors from accelerometer data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_classes
|
int
|
the number of behavior classes to predict. |
required |
sequence_length
|
int
|
the length of the input accelerometer sequence. |
required |
conv_filters
|
list
|
the number of filters in each convolutional block. Defaults to [32, 64, 128, 256]. |
[32, 64, 128, 256]
|
fc_layers
|
list
|
the size of each fully connected layer. Defaults to [256, 512]. |
[256, 512]
|
kernel_size
|
int
|
the kernel size for convolutional layers. Defaults to 5. |
5
|
Source code in pyecoacc/models/deep/cnn.py
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 | |
CNNInputReshaper
¶
Bases: BaseEstimator, TransformerMixin
Reshapes input data for CNN processing of accelerometer data. Transforms 2D input (n_samples, 3*sequence_length) into 3D output (n_samples, 3, sequence_length) for CNN input. This is used as a first step in an sklearn pipeline to generate sklearn-compatible CNN models.
make_cnn_model(sequence_length, num_behav, conv_filters=[32, 64, 128, 256], fc_layers=[256, 512], kernel_size=5, max_epoch=200, lr=0.001, l2=0.0005, verbose=1, validation=0.2, patience=50, allow_cuda=True)
¶
Generate an sklearn-compatible model from a CNN specification
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_classes
|
int
|
the number of behavior classes to predict. |
required |
sequence_length
|
int
|
the length of the input accelerometer sequence. |
required |
conv_filters
|
list
|
the number of filters in each convolutional block. Defaults to [32, 64, 128, 256]. |
[32, 64, 128, 256]
|
fc_layers
|
list
|
the size of each fully connected layer. Defaults to [256, 512]. |
[256, 512]
|
kernel_size
|
int
|
the kernel size for convolutional layers. Defaults to 5. |
5
|
max_epoch
|
int
|
Maximum number of epochs used for training the model. Defaults to 200. |
200
|
lr
|
float
|
learning rate. Defaults to .001. |
0.001
|
l2
|
float
|
regularization strength. Defaults to 5e-4. |
0.0005
|
verbose
|
int
|
specifies verbosity level. Defaults to 1. |
1
|
validation
|
float
|
fraction of data used for validation. Defaults to .2. |
0.2
|
patience
|
int
|
number of epochs to wait before early stopping. Defaults to 50. |
50
|
allow_cuda
|
bool
|
whether to use CUDA if available. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Model |
Pipeline
|
The CNN model wrapped in an sklearn Pipeline. |
Source code in pyecoacc/models/deep/cnn.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |