StaticProcessEngine
Bases: BaseProcessor
Concrete implementation for preprocessing a periodontal dataset for ML.
This class extends BaseProcessor
and provides specific implementations
for imputing missing values, creating tooth-related features, and generating
outcome variables tailored for periodontal data analysis.
Inherits
BaseProcessor
: Provides core data processing methods and abstract method definitions for required preprocessing steps.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
behavior
|
bool
|
If True, includes behavioral columns in processing. Defaults to False. |
False
|
verbose
|
bool
|
Enables verbose logging of data processing steps if True. Defaults to True. |
True
|
Attributes:
Name | Type | Description |
---|---|---|
behavior |
bool
|
Indicates whether to include behavior columns in processing. |
verbose |
bool
|
Flag to enable or disable verbose logging. |
Methods:
Name | Description |
---|---|
impute_missing_values |
Impute missing values specifically for periodontal data. |
create_tooth_features |
Generate tooth-related features, leveraging domain knowledge of periodontal data. |
create_outcome_variables |
Create variables representing clinical outcomes. |
process_data |
Execute a full processing pipeline including cleaning, imputing, scaling, and feature creation. |
Inherited Methods
load_data
: Load processed data from the specified path and file.save_data
: Save processed data to the specified path and file.
Example
from periomod.data import StaticProcessEngine
engine = StaticProcessEngine()
df = engine.load_data(path="data/raw/raw_data.xlsx")
df = engine.process_data(df)
engine.save_data(df=df, path="data/processed/processed_data.csv")
Source code in periomod/data/_preprocessing.py
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 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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
__init__(behavior=False, verbose=True)
¶
Initializes the StaticProcessEngine.
Source code in periomod/data/_preprocessing.py
77 78 79 80 81 |
|
create_outcome_variables(df)
staticmethod
¶
Adds outcome variables to the DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
The input DataFrame. |
required |
Returns:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
The DataFrame with new outcome variables. |
Source code in periomod/data/_preprocessing.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
create_tooth_features(df, neighbors=True, patient_id=True)
¶
Creates side_infected, tooth_infected, and infected_neighbors columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
The input dataframe containing patient data. |
required |
neighbors
|
bool
|
Compute the count of adjacent infected teeth. Defaults to True. |
True
|
patient_id
|
bool
|
Flag to indicate whether 'id_patient' is required when creating the 'tooth_infected' column. If True, 'id_patient' is included in the grouping; otherwise, it is not. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
The dataframe with additional tooth-related features. |
Source code in periomod/data/_preprocessing.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
impute_missing_values(df)
staticmethod
¶
Imputes missing values in the DataFrame.
Imputation rules exist for a predefined set of variables. The method will only impute the columns present in the dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
The DataFrame with missing values. |
required |
Returns:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
The DataFrame with imputed missing values. |
Source code in periomod/data/_preprocessing.py
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 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 154 155 156 |
|
process_data(df)
¶
Processes dataset with data cleaning, imputation and transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
The input DataFrame. |
required |
Returns:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
The imputed Dataframe with added feature and target columns. |
Source code in periomod/data/_preprocessing.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|