profit.util.variable

Module Contents

Classes

VariableGroup

Table of input, output and independent variables.

Variable

Base class for a single variable.

InputVariable

Sub class for input variables.

IndependentVariable

Sub class for independent variables.

ActiveLearningVariable

Sub class for active learning variables.

OutputVariable

Sub class for output variables.

Functions

halton([size])

uniform([start, end, size])

loguniform([start, end, size])

normal([mu, std, size])

linear([start, end, size])

independent([start, end, size])

constant([value, size])

Attributes

EXCLUDE_FROM_HALTON

profit.util.variable.EXCLUDE_FROM_HALTON = ('output', 'constant', 'uniform', 'loguniform', 'normal', 'linear', 'independent')
profit.util.variable.halton(size=(1, 1))[source]
profit.util.variable.uniform(start=0, end=1, size=None)[source]
profit.util.variable.loguniform(start=1e-06, end=1, size=None)[source]
profit.util.variable.normal(mu=0, std=1, size=None)[source]
profit.util.variable.linear(start=0, end=1, size=1)[source]
profit.util.variable.independent(start=0, end=1, size=1)[source]
profit.util.variable.constant(value=0, size=None)[source]
class profit.util.variable.VariableGroup(samples)[source]

Table of input, output and independent variables.

Parameters:

samples (int) – Samples of the training data.

samples

Samples of the training data.

Type:

int

list

List of all variables in the order of the user entry.

Type:

list

property all
Returns:

View on all variables.

Not working yet for vector output.

property as_dict

Returns: View of all variables as a dictionary.

property input

Returns: View of the input variables only. Also excluded are independent variables.

property named_input

Returns: Ndarray with dtype of the input variables.

property input_dict

Returns: Dictionary of the input variables.

property input_list

Returns: List of input variables without independent variables.

property kind_dict
property output

Returns: View on the output variables only.

property named_output

Returns: Ndarray with dtype of the output variables.

property formatted_output
property output_dict

Returns: Dictionary of the output variables.

property output_list

Returns: List of output variables.

__getitem__(item)[source]

Implements dict like behavior to get a variable by its identifier or index.

Parameters:

item (int/str) – Index or label of variable.

Returns:

Variable.

add(variables)[source]

Adds a single or a list of variables to the table. If a list is added, a common n-D halton sequence is generated and the variables are transformed according to their distribution.

Parameters:

variables (Variable/list) – Variable(s) to add.

delete_variable(columns)[source]

Deletes one or more variables from the table.

Parameters:

columns (int/list) – Columns of the table to remove.

delete_sample(rows)[source]

Deletes one or more rows of the table.

Parameters:

rows (int/list) – Rows to delete.

generate_from_halton()[source]

Generates a common halton sequence for all variables where this is possible and transforms them according to their distribution.

class profit.util.variable.Variable(name, kind, size, value=None, dtype=np.float64)[source]

Bases: profit.util.base_class.CustomABC

Base class for a single variable. To create input, independent and output variables, use the cls.create() or cls.create_from_str() methods.

name

Name of the variable.

Type:

str

kind

Distribution for input variables, ‘Output’ or ‘Independent’.

Type:

str

size

Size as (nsamples, ndim).

Type:

tuple

value

Data.

Type:

ndarray

dtype

Datatype.

Type:

dtype

property named_value

Returns: Ndarray with dtype.

labels
classmethod create_from_str(name, size, v_str)[source]

Creates a Variable instance from a string. E.g. ‘Uniform(3.4, 7.8)’

Parameters:
  • name (str) – Name of the variable.

  • size (tuple) – Size as (nsamples, ndim).

  • v_str (str) – String from which the variable is constructed.

Returns:

Variable.

classmethod create(name, kind, size, value=None, dtype=np.float64, **kwargs)[source]

Directly creates a variable from keyword entries.

Parameters:
  • name (str) – Name of the variable.

  • kind (str) – Distribution of input variables, ‘Output’ or ‘Independent’.

  • size (tuple) – Size as (nsamples, ndim).

  • kwargs (tuple/str) – Keyword arguments depending on the sub variables. E.g. constraints for input variables, a search distribution for active learning variables or dependent variables of outputs.

  • value (ndarray) – Data.

  • dtype (dtype) – Datatype.

Returns:

Variable.

as_dict()[source]

Dictionary of the variable attributes.

__getitem__(item)[source]

Implement dict like behavior to get an attribute by using square brackets.

Paramters:

item (str)

Returns:

Attribute

class profit.util.variable.InputVariable(name, kind, size, constraints=(0, 1), value=None, dtype=np.float64)[source]

Bases: Variable

Sub class for input variables.

generate_values(halton_seq=None)[source]
classmethod parse_entries(entries)[source]
create_Xpred(size, spacing=None)[source]

creates an array of suitably spaced X-values for prediction

spacing (shape: size) can be used to override the default linear spacing

class profit.util.variable.IndependentVariable(name, kind, size, constraints=(0, 1), value=None, dtype=np.float64)[source]

Bases: InputVariable

Sub class for independent variables.

class profit.util.variable.ActiveLearningVariable(name, kind, size, distr='uniform', constraints=(0, 1), value=None, dtype=np.float64)[source]

Bases: InputVariable

Sub class for active learning variables.

classmethod parse_entries(entries)[source]
generate_values(halton_seq=None)[source]
create_Xpred(size, spacing=None)[source]

creates an array of suitably spaced X-values for prediction

spacing (shape: size) can be used to override the default linear spacing

class profit.util.variable.OutputVariable(name, kind, size, dependent=(), value=None, dtype=np.float64)[source]

Bases: Variable

Sub class for output variables.

classmethod parse_entries(entries)[source]
resolve_dependent(ind)[source]

Create a Variable instance for the independent variables of vector outputs and set dependent.

Parameters:

ind (profit.util.variable.IndependentVariable or list[profit.util.variable.IndependentVariable]) – Independent variables.

as_dict()[source]

Dictionary of the variable attributes.