Features
categorical
CategoricalInput
Bases: Input
Base class for all categorical input features.
Attributes:
Name | Type | Description |
---|---|---|
categories |
List[str]
|
Names of the categories. |
allowed |
List[bool]
|
List of bools indicating if a category is allowed within the optimization. |
Source code in bofire/data_models/features/categorical.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 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 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
__str__()
Returns the number of categories as str
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Number of categories |
Source code in bofire/data_models/features/categorical.py
347 348 349 350 351 352 353 354 |
|
fixed_value(transform_type=None)
Returns the categories to which the feature is fixed, None if the feature is not fixed
Returns:
Type | Description |
---|---|
Union[List[str], List[float], None]
|
List[str]: List of categories or None |
Source code in bofire/data_models/features/categorical.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
from_dummy_encoding(values)
Convert points back from dummy encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
DataFrame
|
Dummy-hot encoded values. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If one-hot columns not present in |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Series with categorical values. |
Source code in bofire/data_models/features/categorical.py
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 |
|
from_onehot_encoding(values)
Converts values back from one-hot encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
DataFrame
|
One-hot encoded values. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If one-hot columns not present in |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Series with categorical values. |
Source code in bofire/data_models/features/categorical.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
from_ordinal_encoding(values)
Convertes values back from ordinal encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Ordinal encoded series. |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Series with categorical values. |
Source code in bofire/data_models/features/categorical.py
280 281 282 283 284 285 286 287 288 289 290 291 |
|
generate_allowed(allowed, info)
classmethod
Generates the list of allowed categories if not provided.
Source code in bofire/data_models/features/categorical.py
37 38 39 40 41 42 43 |
|
get_allowed_categories()
Returns the allowed categories.
Returns:
Type | Description |
---|---|
list of str: The allowed categories |
Source code in bofire/data_models/features/categorical.py
97 98 99 100 101 102 103 104 105 106 |
|
get_forbidden_categories()
Returns the non-allowed categories
Returns:
Type | Description |
---|---|
List[str]: List of the non-allowed categories |
Source code in bofire/data_models/features/categorical.py
160 161 162 163 164 165 166 167 |
|
get_possible_categories(values)
Return the superset of categories that have been used in the experimental dataset and that can be used in the optimization
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Series with the values for this feature |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of possible categories |
Source code in bofire/data_models/features/categorical.py
169 170 171 172 173 174 175 176 177 178 179 180 |
|
is_fixed()
Returns True if there is only one allowed category.
Returns:
Type | Description |
---|---|
bool
|
[bool]: True if there is only one allowed category |
Source code in bofire/data_models/features/categorical.py
61 62 63 64 65 66 67 68 69 70 |
|
sample(n, seed=None)
Draw random samples from the feature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
number of samples. |
required |
seed
|
int
|
random seed. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Series
|
pd.Series: drawn samples. |
Source code in bofire/data_models/features/categorical.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
to_dummy_encoding(values)
Converts values to a dummy-hot encoding, dropping the first categorical level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Series to be transformed. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Dummy-hot transformed data frame. |
Source code in bofire/data_models/features/categorical.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
to_onehot_encoding(values)
Converts values to a one-hot encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Series to be transformed. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: One-hot transformed data frame. |
Source code in bofire/data_models/features/categorical.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
to_ordinal_encoding(values)
Converts values to an ordinal integer based encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Series to be transformed. |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Ordinal encoded values. |
Source code in bofire/data_models/features/categorical.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
validate_candidental(values)
Method to validate the suggested candidates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with candidates |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when not all values for a feature are one of the allowed categories |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The passed dataFrame with candidates |
Source code in bofire/data_models/features/categorical.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
validate_experimental(values, strict=False)
Method to validate the experimental dataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with experiments |
required |
strict
|
bool
|
Boolean to distinguish if the occurrence of fixed features in the dataset should be considered or not. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
when an entry is not in the list of allowed categories |
ValueError
|
when there is no variation in a feature provided by the experimental data |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: A dataFrame with experiments |
Source code in bofire/data_models/features/categorical.py
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 |
|
CategoricalOutput
Bases: Output
Source code in bofire/data_models/features/categorical.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
|
validate_objective_categories()
Validates that objective categories match the output categories
Raises:
Type | Description |
---|---|
ValueError
|
when categories do not match objective categories |
Returns:
Type | Description |
---|---|
self |
Source code in bofire/data_models/features/categorical.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
|
continuous
ContinuousInput
Bases: NumericalInput
Base class for all continuous input features.
Attributes:
Name | Type | Description |
---|---|---|
bounds |
Tuple[float, float]
|
A tuple that stores the lower and upper bound of the feature. |
stepsize |
float
|
Float indicating the allowed stepsize between lower and upper. Defaults to None. |
local_relative_bounds |
Tuple[float, float]
|
A tuple that stores the lower and upper bounds relative to a reference value. Defaults to None. |
Source code in bofire/data_models/features/continuous.py
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 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 |
|
__str__()
Method to return a string of lower and upper bound
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
String of a list with lower and upper bound |
Source code in bofire/data_models/features/continuous.py
169 170 171 172 173 174 175 176 |
|
round(values)
Round values to the stepsize of the feature. If no stepsize is provided return the provided values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
The values that should be rounded. |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The rounded values |
Source code in bofire/data_models/features/continuous.py
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 |
|
sample(n, seed=None)
Draw random samples from the feature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
number of samples. |
required |
seed
|
int
|
random seed. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Series
|
pd.Series: drawn samples. |
Source code in bofire/data_models/features/continuous.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
validate_candidental(values)
Method to validate the suggested candidates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with candidates |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when non numerical values are passed |
ValueError
|
when values are larger than the upper bound of the feature |
ValueError
|
when values are lower than the lower bound of the feature |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The passed dataFrame with candidates |
Source code in bofire/data_models/features/continuous.py
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 |
|
ContinuousOutput
Bases: Output
The base class for a continuous output feature
Attributes:
Name | Type | Description |
---|---|---|
objective |
objective
|
objective of the feature indicating in which direction it should be optimized. Defaults to |
Source code in bofire/data_models/features/continuous.py
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 |
|
descriptor
CategoricalDescriptorInput
Bases: CategoricalInput
Class for categorical input features with descriptors
Attributes:
Name | Type | Description |
---|---|---|
categories |
List[str]
|
Names of the categories. |
allowed |
List[bool]
|
List of bools indicating if a category is allowed within the optimization. |
descriptors |
List[str]
|
List of strings representing the names of the descriptors. |
values |
List[List[float]]
|
List of lists representing the descriptor values. |
Source code in bofire/data_models/features/descriptor.py
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 |
|
fixed_value(transform_type=None)
Returns the categories to which the feature is fixed, None if the feature is not fixed
Returns:
Type | Description |
---|---|
Union[List[str], List[float], None]
|
List[str]: List of categories or None |
Source code in bofire/data_models/features/descriptor.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
from_descriptor_encoding(values)
Converts values back from descriptor encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
DataFrame
|
Descriptor encoded dataframe. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If descriptor columns not found in the dataframe. |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Series with categorical values. |
Source code in bofire/data_models/features/descriptor.py
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 |
|
from_df(key, df)
classmethod
Creates a feature from a dataframe
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
The name of the feature |
required |
df
|
DataFrame
|
Categories as rows and descriptors as columns |
required |
Returns:
Name | Type | Description |
---|---|---|
_type_ |
description |
Source code in bofire/data_models/features/descriptor.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
to_descriptor_encoding(values)
Converts values to descriptor encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Values to transform. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Descriptor encoded dataframe. |
Source code in bofire/data_models/features/descriptor.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
to_df()
Tabular overview of the feature as DataFrame
Returns:
Type | Description |
---|---|
pd.DataFrame: tabular overview of the feature as DataFrame |
Source code in bofire/data_models/features/descriptor.py
124 125 126 127 128 129 130 131 132 |
|
validate_experimental(values, strict=False)
Method to validate the experimental dataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with experiments |
required |
strict
|
bool
|
Boolean to distinguish if the occurrence of fixed features in the dataset should be considered or not. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
when an entry is not in the list of allowed categories |
ValueError
|
when there is no variation in a feature provided by the experimental data |
ValueError
|
when no variation is present or planned for a given descriptor |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: A dataFrame with experiments |
Source code in bofire/data_models/features/descriptor.py
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 |
|
validate_values(v, info)
classmethod
Validates the compatibility of passed values for the descriptors and the defined categories
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v
|
List[List[float]]
|
Nested list with descriptor values |
required |
values
|
Dict
|
Dictionary with attributes |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when values have different length than categories |
ValueError
|
when rows in values have different length than descriptors |
ValueError
|
when a descriptor shows no variance in the data |
Returns:
Type | Description |
---|---|
List[List[float]]: Nested list with descriptor values |
Source code in bofire/data_models/features/descriptor.py
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 |
|
ContinuousDescriptorInput
Bases: ContinuousInput
Class for continuous input features with descriptors
Attributes:
Name | Type | Description |
---|---|---|
lower_bound |
float
|
Lower bound of the feature in the optimization. |
upper_bound |
float
|
Upper bound of the feature in the optimization. |
descriptors |
List[str]
|
Names of the descriptors. |
values |
List[float]
|
Values of the descriptors. |
Source code in bofire/data_models/features/descriptor.py
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 |
|
to_df()
Tabular overview of the feature as DataFrame
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: tabular overview of the feature as DataFrame |
Source code in bofire/data_models/features/descriptor.py
52 53 54 55 56 57 58 59 60 61 62 63 |
|
validate_list_lengths()
Compares the length of the defined descriptors list with the provided values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Dict
|
Dictionary with all attributes |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when the number of descriptors does not math the number of provided values |
Returns:
Name | Type | Description |
---|---|---|
Dict |
Dict with the attributes |
Source code in bofire/data_models/features/descriptor.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
discrete
DiscreteInput
Bases: NumericalInput
Feature with discretized ordinal values allowed in the optimization.
Attributes:
Name | Type | Description |
---|---|---|
key(str) |
key of the feature. |
|
values(List[float]) |
the discretized allowed values during the optimization. |
Source code in bofire/data_models/features/discrete.py
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 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 |
|
lower_bound
property
Lower bound of the set of allowed values
upper_bound
property
Upper bound of the set of allowed values
from_continuous(values)
Rounds continuous values to the closest discrete ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
DataFrame
|
Dataframe with continuous entries. |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Series with discrete values. |
Source code in bofire/data_models/features/discrete.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
sample(n, seed=None)
Draw random samples from the feature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
number of samples. |
required |
seed
|
int
|
random seed. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Series
|
pd.Series: drawn samples. |
Source code in bofire/data_models/features/discrete.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
validate_candidental(values)
Method to validate the provided candidates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
suggested candidates for the feature |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Raises error when one of the provided values is not contained in the list of allowed values. |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: _uggested candidates for the feature |
Source code in bofire/data_models/features/discrete.py
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 |
|
validate_values_unique(values)
classmethod
Validates that provided values are unique.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
List[float]
|
List of values |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when values are non-unique. |
ValueError
|
when values contains only one entry. |
ValueError
|
when values is empty. |
Returns:
Type | Description |
---|---|
List[values]: Sorted list of values |
Source code in bofire/data_models/features/discrete.py
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 |
|
feature
Feature
Bases: BaseModel
The base class for all features.
Source code in bofire/data_models/features/feature.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
__lt__(other)
Method to compare two models to get them in the desired order. Return True if other is larger than self, else False. (see FEATURE_ORDER)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other
|
The other class to compare to self |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the other class is larger than self, else False |
Source code in bofire/data_models/features/feature.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Input
Bases: Feature
Base class for all input features.
Source code in bofire/data_models/features/feature.py
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 |
|
fixed_value(transform_type=None)
abstractmethod
Method to return the fixed value in case of a fixed feature.
Returns:
Type | Description |
---|---|
Union[None, List[str], List[float]]
|
Union[None,str,float]: None in case the feature is not fixed, else the fixed value. |
Source code in bofire/data_models/features/feature.py
57 58 59 60 61 62 63 64 65 66 67 |
|
get_bounds(transform_type=None, values=None, reference_value=None)
abstractmethod
Returns the bounds of an input feature depending on the requested transform type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transform_type
|
Optional[TTransform]
|
The requested transform type. Defaults to None. |
None
|
values
|
Optional[Series]
|
If values are provided the bounds are returned taking the most extreme values for the feature into account. Defaults to None. |
None
|
reference_value
|
Optional[float]
|
If a reference value is provided, then the local bounds based on a local search region are provided. Currently only supported for continuous inputs. For more details, it is referred to https://www.merl.com/publications/docs/TR2023-057.pdf. |
None
|
Returns:
Type | Description |
---|---|
Tuple[List[float], List[float]]
|
Tuple[List[float], List[float]]: List of lower bound values, list of upper bound values. |
Source code in bofire/data_models/features/feature.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
is_fixed()
abstractmethod
Indicates if a variable is set to a fixed value.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if fixed, els False. |
Source code in bofire/data_models/features/feature.py
48 49 50 51 52 53 54 55 |
|
sample(n, seed=None)
abstractmethod
Sample a series of allowed values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
Number of samples |
required |
seed
|
int
|
random seed. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Sampled values. |
Source code in bofire/data_models/features/feature.py
98 99 100 101 102 103 104 105 106 107 108 109 |
|
validate_candidental(values)
abstractmethod
Abstract method to validate the suggested candidates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with candidates |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The passed dataFrame with candidates |
Source code in bofire/data_models/features/feature.py
86 87 88 89 90 91 92 93 94 95 96 |
|
validate_experimental(values, strict=False)
abstractmethod
Abstract method to validate the experimental dataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with experiments |
required |
strict
|
bool
|
Boolean to distinguish if the occurrence of fixed features in the dataset should be considered or not. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The passed dataFrame with experiments |
Source code in bofire/data_models/features/feature.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
Output
Bases: Feature
Base class for all output features.
Attributes:
Name | Type | Description |
---|---|---|
key(str) |
Key of the Feature. |
Source code in bofire/data_models/features/feature.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
validate_experimental(values)
abstractmethod
Abstract method to validate the experimental Series
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with values for the outcome |
required |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: The passed dataFrame with experiments |
Source code in bofire/data_models/features/feature.py
146 147 148 149 150 151 152 153 154 155 156 |
|
get_encoded_name(feature_key, option_name)
Get the name of the encoded column. Option could be the category or the descriptor name.
Source code in bofire/data_models/features/feature.py
169 170 171 |
|
molecular
CategoricalMolecularInput
Bases: CategoricalInput
, MolecularInput
Source code in bofire/data_models/features/molecular.py
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 |
|
from_descriptor_encoding(transform_type, values)
Converts values back from descriptor encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
DataFrame
|
Descriptor encoded dataframe. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If descriptor columns not found in the dataframe. |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: Series with categorical values. |
Source code in bofire/data_models/features/molecular.py
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 |
|
validate_smiles(categories)
classmethod
Validates that categories are valid smiles. Note that this check can only be executed when rdkit is available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
categories
|
List[str]
|
List of smiles |
required |
Raises:
Type | Description |
---|---|
ValueError
|
when string is not a smiles |
Returns:
Type | Description |
---|---|
List[str]: List of the smiles |
Source code in bofire/data_models/features/molecular.py
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 |
|
MolecularInput
Bases: Input
Source code in bofire/data_models/features/molecular.py
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 |
|
get_bounds(transform_type, values, reference_value=None)
Calculates the lower and upper bounds for the feature based on the given transform type and values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transform_type
|
AnyMolFeatures
|
The type of transformation to apply to the data. |
required |
values
|
Series
|
The actual data over which the lower and upper bounds are calculated. |
required |
reference_value
|
Optional[str]
|
The reference value for the transformation. Not used here. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Tuple[List[float], List[float]]
|
Tuple[List[float], List[float]]: A tuple containing the lower and upper bounds of the transformed data. |
Raises:
Type | Description |
---|---|
NotImplementedError
|
Raised when |
Source code in bofire/data_models/features/molecular.py
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 |
|
to_descriptor_encoding(transform_type, values)
Converts values to descriptor encoding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
Values to transform. |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Descriptor encoded dataframe. |
Source code in bofire/data_models/features/molecular.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
numerical
NumericalInput
Bases: Input
Abstract base class for all numerical (ordinal) input features.
Source code in bofire/data_models/features/numerical.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 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 |
|
fixed_value(transform_type=None)
Method to get the value to which the feature is fixed
Returns:
Name | Type | Description |
---|---|---|
Float |
Union[None, List[float]]
|
Return the feature value or None if the feature is not fixed. |
Source code in bofire/data_models/features/numerical.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
from_unit_range(values)
Convert from unit range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
values to transform from. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
if the feature is fixed raise a value error. |
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
pd.Series: description |
Source code in bofire/data_models/features/numerical.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
is_fixed()
Method to check if the feature is fixed
Returns:
Name | Type | Description |
---|---|---|
Boolean |
True when the feature is fixed, false otherwise. |
Source code in bofire/data_models/features/numerical.py
87 88 89 90 91 92 93 94 |
|
to_unit_range(values, use_real_bounds=False)
Convert to the unit range between 0 and 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
values to be transformed |
required |
use_real_bounds
|
bool
|
if True, use the bounds from the actual values else the bounds from the feature. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If lower_bound == upper bound an error is raised |
Returns:
Type | Description |
---|---|
Union[Series, ndarray]
|
pd.Series: transformed values. |
Source code in bofire/data_models/features/numerical.py
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 |
|
validate_candidental(values)
Validate the suggested candidates for the feature.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
suggested candidates for the feature |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Error is raised when one of the values is not numerical. |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: the original provided candidates |
Source code in bofire/data_models/features/numerical.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
validate_experimental(values, strict=False)
Method to validate the experimental dataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
Series
|
A dataFrame with experiments |
required |
strict
|
bool
|
Boolean to distinguish if the occurrence of fixed features in the dataset should be considered or not. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
when a value is not numerical |
ValueError
|
when there is no variation in a feature provided by the experimental data |
Returns:
Type | Description |
---|---|
Series
|
pd.Series: A dataFrame with experiments |
Source code in bofire/data_models/features/numerical.py
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 |
|