pywatts.core package

Submodules

pywatts.core.base module

class pywatts.core.base.Base(name: str)

Bases: abc.ABC

This is the base class of the modules. It manages the basic functionality of modules. BaseTransformer and BaseEstimator inherit from this class.

Parameters:name (str) – Name of the module
fit(**kwargs)

Fit the model, e.g. optimize parameters such that model(x) = y

Parameters:kwargs – key word arguments as input. If the key word starts with target, then it is a target variable.
Returns:
get_min_data()
get_params() → Dict[str, object]

Get params :return: Dict with params

inverse_transform(**kwargs) → xarray.core.dataarray.DataArray

Performs the inverse transformation if available. Note for developers of modules: if this method is implemented the flag “self.has_inverse_transform” must be set to True in the constructor. I.e. self.has_inverse_transform = True (must be called after “super().__init__(name)”)

Parameters:x – key word arguments as input. Note that it is not allowed to use key words that starts with target here, since this are target variables. And this function shall not fit any models against a target variable.
Returns:The transformed input
classmethod load(load_information: Dict[KT, VT])

Uses the data in load_information for restoring the state of the module.

Parameters:load_information (Dict) – The data needed for restoring the state of the module
Returns:The restored module
Return type:Base
predict_proba(*kwargs) → xr.DataArray

Performs the probabilistic transformation if available. Note for developers of modules: if this method is implemented, the flag “self.has_predict_proba” must be set to True in the constructor. I.e. self.has_inverse_transform = True (must be called after “super().__init__(name)”)

Parameters:x – key word arguments as input. Note that it is not allowed to use key words that starts with target here, since this are target variables. And this function shall not fit any models against a target variable.
Returns:The transformed input
refit(**kwargs)

This method refits the module. If not overwritten it is the same as fit. :param kwargs: key word arguments as input. If the key word starts with target, then it is a target variable.

save(fm: pywatts.core.filemanager.FileManager) → Dict[KT, VT]

Saves the modules and the state of the module and returns a dictionary containing the relevant information.

Parameters:fm (FileManager) – the filemanager which can be used by the module for saving information about the module.
Returns:A dictionary containing the information needed for restoring the module

:rtype:Dict

set_params(**kwargs)

Set params :return:

transform(**kwargs) → xr.DataArray

Transforms the input.

Parameters:x – key word arguments as input. Note that it is not allowed to use key words that starts with target here, since this are target variables. And this function shall not fit any models against a target variable.
Returns:The transformed input
class pywatts.core.base.BaseEstimator(name: str)

Bases: pywatts.core.base.Base, abc.ABC

The base class for all estimator modules.

Parameters:name (str) – The name of the module
classmethod load(load_information) → pywatts.core.base.BaseEstimator

Uses the data in load_information for restoring the state of the module.

Parameters:load_information (Dict) – The data needed for restoring the state of the module
Returns:The restored module
Return type:BaseEstimator
save(fm: pywatts.core.filemanager.FileManager) → Dict[KT, VT]

Saves the modules and the state of the module and returns a dictionary containing the relevant information.

Parameters:fm (FileManager) – the filemanager which can be used by the module for saving information about the module.
Returns:A dictionary containing the information needed for restoring the module

:rtype:Dict

class pywatts.core.base.BaseTransformer(name: str)

Bases: pywatts.core.base.Base, abc.ABC

The base class for all transformer modules. It provides a dummy fit method.

fit(**kwargs)

Dummy method of fit, which does nothing :return:

pywatts.core.base_step module

class pywatts.core.base_step.BaseStep(input_steps: Optional[Dict[str, BaseStep]] = None, targets: Optional[Dict[str, BaseStep]] = None, condition=None, computation_mode=<ComputationMode.Default: 4>, name='BaseStep')

Bases: abc.ABC

The base class of all steps. :param input_steps: The input steps :type input_steps: Optional[Dict[str, BaseStep]] :param targets: The target steps :type targets: Optional[Dict[str, BaseStep]] :param condition: A function which evaluates to False or True for detecting if the module should be executed. :type condition: Callable :param computation_mode: The computation mode for this module :type computation_mode: ComputationMode

further_elements(counter: pandas._libs.tslibs.timestamps.Timestamp) → bool

Checks if there exist at least one data for the time after counter.

Parameters:counter (pd.Timestamp) – The timestampe for which it should be tested if there exist further data after it.
Returns:True if there exist further data
Return type:bool
get_json(fm: pywatts.core.filemanager.FileManager) → Dict[KT, VT]

Returns a dictionary containing all information needed for restoring the step.

Parameters:fm (FileManager) – The filemanager which can be used by the step for storing the state of the step.
Returns:A dictionary containing all information needed for restoring the step.
Return type:Dict
get_result(start: pandas._libs.tslibs.timestamps.Timestamp, end: Optional[pandas._libs.tslibs.timestamps.Timestamp], buffer_element: str = None, return_all=False, minimum_data=(0, Timedelta('0 days 00:00:00')))

This method is responsible for providing the result of this step. Therefore, this method triggers the get_input and get_target data methods. Additionally, it triggers the computations and checks if all data are processed.

Parameters:
  • start (pd.Timedstamp) – The start date of the requested results of the step
  • end (Optional[pd.Timestamp]) – The end date of the requested results of the step (exclusive)
  • buffer_element (str) – if the buffer of the step contains multiple results, this determines the result which is returned.
  • return_all (bool) – Flag that indicates if all results in the buffer should be returned.
Returns:

The resulting data or None if no data are calculated

classmethod load(stored_step: dict, inputs, targets, module, file_manager)

Restores the step.

Parameters:
  • stored_step – Information about the stored step
  • inputs – The input steps of the step which should be restored
  • targets – The target steps of the step which should be restored
  • module – The module which is contained by this step
  • file_manager – The filemanager of the step
Returns:

The restored step.

reset(keep_buffer=False)

Resets all information of the step concerning a specific run. :param keep_buffer: Flag indicating if the buffer should be resetted too.

set_run_setting(run_setting: pywatts.core.run_setting.RunSetting)

Sets the computation mode of the step for the current run. Note that after reset the all mode is restored. Moreover, setting the computation_mode is only possible if the computation_mode is not set explicitly while adding the corresponding module to the pipeline.

Parameters:computation_mode (ComputationMode) – The computation mode which should be set.

pywatts.core.base_summary module

class pywatts.core.base_summary.BaseSummary(name: str)

Bases: pywatts.core.base.Base, abc.ABC

This is the base class of the modules. It manages the basic functionality of modules. BaseTransformer and BaseEstimator inherit from this class.

Parameters:name (str) – Name of the module
fit(**kwargs)

Dummy method of fit, which does nothing :return:

classmethod load(load_information: Dict[KT, VT])

Uses the data in load_information for restoring the state of the module.

Parameters:load_information (Dict) – The data needed for restoring the state of the module
Returns:The restored module
Return type:Base
save(fm: pywatts.core.filemanager.FileManager) → Dict[KT, VT]

Saves the modules and the state of the module and returns a dictionary containing the relevant information.

Parameters:fm (FileManager) – the filemanager which can be used by the module for saving information about the module.
Returns:A dictionary containing the information needed for restoring the module
Return type:Dict
transform(file_manager: pywatts.core.filemanager.FileManager, **kwargs) → pywatts.core.summary_object.SummaryObject

Transform method. Here the summary should be calculated. :param file_manager: The filemanager, it can be used to store data that corresponds to the summary as a file. :type: file_manager: FileManager :param kwargs: The input data for which a summary should be calculated. :type kwargs: xr.DataArray :return: A markdown formatted string that contains the summary. :rtype: SummaryObject

pywatts.core.computation_mode module

class pywatts.core.computation_mode.ComputationMode

Bases: enum.IntEnum

Enum which contains the different computation modes of step.

Default = 4
FitTransform = 3
Refit = 5
Train = 2
Transform = 1

pywatts.core.condition_object module

pywatts.core.either_or_step module

class pywatts.core.either_or_step.EitherOrStep(input_steps)

Bases: pywatts.core.base_step.BaseStep

This step merges the result of multiple input steps, by choosing the first step in the input list which contains data for the current data.

Parameters:input_step (List[BaseStep]) – The input_steps for the either_or_step
classmethod load(stored_step: dict, inputs, targets, module, file_manager)

Load the Either or step from a stored step.

Parameters:
  • stored_step – Information about the stored either or step
  • inputs – the input steps
  • targets – Does not exist for eitherOr
  • module – Does not exist for either or step
  • file_manager – The filemanager used for saving informations.
Returns:

The restored eitherOrStep

pywatts.core.filemanager module

class pywatts.core.filemanager.FileManager(path, time_mode=True)

Bases: object

This class is responsible for managing files in pyWATTS. It ensures that all files for one pipeline run are in the same folder. Moreover, it appends a timestamp to the corresponding path

Parameters:
  • path (str) – Root path for the results of the pipeline
  • time_mode (bool) – If true, then a subfolder with the current time is created
get_path(filename: str, path=None)

Returns a path to file. This path is in the folder of the corresponding pipeline run. Moreover it is ensured that no data are overwritten.

Parameters:
  • filename (str) – Name of the file to write
  • path – Optional path extension to the file.
Returns:

The path, where the results should be stored.

pywatts.core.inverse_step module

class pywatts.core.inverse_step.InverseStep(module: pywatts.core.base.Base, input_steps: Dict[str, pywatts.core.base_step.BaseStep], file_manager, *, targets: Optional[Dict[str, BaseStep]] = None, computation_mode=<ComputationMode.Default: 4>, callbacks: List[Union[pywatts.callbacks.base_callback.BaseCallback, Callable[[Dict[str, xarray.core.dataarray.DataArray]], None]]] = [], condition=None, batch_size: None = None, refit_conditions=[], retrain_batch=Timedelta('1 days 00:00:00'), lag=Timedelta('1 days 00:00:00'))

Bases: pywatts.core.step.Step

This step calls the inverse_transform method of the corresponding module.

Parameters:
  • module (Base) – The module which is wrapped by the step-
  • input_steps (Step) – The input_step of the module.
  • file_manager (FileManager) – The file_manager which is used for storing data.
  • target (Optional[Step]) – The step against which’s output the module of the current step should be fitted. (Default: None)
  • computation_mode (ComputationMode) – The computation mode which should be for this step. (Default: ComputationMode.Default)
  • callbacks (List[Union[BaseCallback, Callable[[Dict[str, xr.DataArray]], None]]]) – Callbacks to use after results are processed.
  • condition (Callable[xr.DataArray, xr.DataArray, bool]) – A callable which checks if the step should be executed with the current data.

pywatts.core.pipeline module

Module containing a pipeline

class pywatts.core.pipeline.Pipeline(path: Optional[str] = '.', batch: Optional[pandas._libs.tslibs.timedeltas.Timedelta] = None, name='Pipeline')

Bases: pywatts.core.base.BaseTransformer

The pipeline class is the central class of pyWATTS. It is responsible for * The interaction with the user * starting the execution of the pipeline * loading and saving the pipeline

Parameters:
  • path (str) – The path where the results of the pipeline should be stored (Default: “.”)
  • batch (Optional[pd.Timedelta]) – If specified then the pipeline does not process the whole data per step. Instead it processes only the data in the given interval. (Default: None)
add(*, module: pywatts.core.base_step.BaseStep, input_ids: List[int] = None, target_ids: List[int] = None)

Add a new module with all of it’s inputs to the pipeline.

Parameters:
  • target_ids – The target determines the module which provides the target value.
  • module – The module which should be added
  • input_ids – A list of modules, whose input is needed for this steps
Returns:

None

draw()

Should draw a graph of the pipeline Draws the graph with the names of th modules :return:

static from_folder(load_path, file_manager_path=None)

Loads the pipeline from the pipeline.json in the specified folder .. warning:

Sometimes from_folder use unpickle for loading modules. Note that this is not safe.
Consequently, load only pipelines you trust with `from_folder`.
For more details about pickling see https://docs.python.org/3/library/pickle.html
Parameters:
  • load_path (str) – path to the pipeline.json
  • file_manager_path (str) – path for the results and outputs
get_params() → Dict[str, object]

Returns the parameter of a pipeline module :return: Dictionary containing information about this module :rtype: Dict

classmethod load(load_information)

Loads the pipeline. Note You should not call this method from outside of pyWATTS. If you want to store your pipeline then you should use from_folder.

refit(start, end)

Refits all steps inside of the pipeline. :param start: The date of the first data used for retraining. :param end: The date of the last data used for retraining.

save(fm: pywatts.core.filemanager.FileManager)

Saves the pipeline. Note You should not call this method from outside of pyWATTS. If you want to store your pipeline then you should use to_folder.

set_params(batch=None)

Set params of pipeline module.

Parameters:batch (Optional[pd.Timedelta]) – The time period length for which in each online learning step the pipeline should be executed.
test(data: Union[pandas.core.frame.DataFrame, xarray.core.dataset.Dataset], summary: bool = True, summary_formatter: pywatts.core.summary_formatter.SummaryFormatter = <pywatts.core.summary_formatter.SummaryMarkdown object>, online_start=None)

Executes all modules in the pipeline in the correct order. This method call only transform on every module if the ComputationMode is Default. I.e. if no computationMode is specified during the addition of the module to the pipeline.

Parameters:
  • data – dataset which should be processed by the data
  • summary (bool) – A flag indicating if an additional summary should be returned or not.
  • summary_formatter (SummaryFormatter) – Determines the format of the summary.
Returns:

The result of all end points of the pipeline

Return type:

Dict[xr.DataArray]

to_folder(path: Union[str, pathlib.Path])

Saves the pipeline in pipeline.json in the specified folder.

Parameters:path – path of the folder
Returns:None
train(data: Union[pandas.core.frame.DataFrame, xarray.core.dataset.Dataset], summary: bool = True, summary_formatter: pywatts.core.summary_formatter.SummaryFormatter = <pywatts.core.summary_formatter.SummaryMarkdown object>)

Executes all modules in the pipeline in the correct order. This method calls fit and transform on each module if the ComputationMode is Default. I.e. if no computationMode is specified during the addition of the module to the pipeline.

Parameters:
  • data – dataset which should be processed by the data
  • summary (bool) – A flag indicating if an additional summary should be returned or not.
  • summary_formatter (SummaryFormatter) – Determines the format of the summary.
Returns:

The result of all end points of the pipeline

Return type:

Dict[xr.DataArray]

transform(**x) → xarray.core.dataarray.DataArray

Transform the input into output, by performing all the step in this pipeline. Moreover, this method collects the results of the last steps in this pipeline.

Note, this method is necessary for enabling subpipelining.

Parameters:x (xr.DataArray) – The input data

:return:The transformed data :rtype: xr.DataArray

pywatts.core.pipeline_step module

class pywatts.core.pipeline_step.PipelineStep(module: pywatts.core.base.Base, input_steps: Dict[str, pywatts.core.base_step.BaseStep], file_manager, *, targets: Optional[Dict[str, BaseStep]] = None, computation_mode=<ComputationMode.Default: 4>, callbacks: List[Union[pywatts.callbacks.base_callback.BaseCallback, Callable[[Dict[str, xarray.core.dataarray.DataArray]], None]]] = [], condition=None, batch_size: None = None, refit_conditions=[], retrain_batch=Timedelta('1 days 00:00:00'), lag=Timedelta('1 days 00:00:00'))

Bases: pywatts.core.step.Step

This step is necessary for subpipelining. Since it contains functionality for adding a pipeline as a subpipeline to a other pipeline.

Parameters:
  • module (Pipeline) – The module which is wrapped by the step-
  • input_step (Step) – The input_step of the module.
  • file_manager (FileManager) – The file_manager which is used for storing data.
  • target (Optional[Step]) – The step against which’s output the module of the current step should be fitted. (Default: None)
  • computation_mode (ComputationMode) – The computation mode which should be for this step. (Default: ComputationMode.Default)
  • callbacks (List[Union[BaseCallback, Callable[[Dict[str, xr.DataArray]], None]]]) – Callbacks to use after results are processed.
  • condition (Callable[xr.DataArray, xr.DataArray, bool]) – A callable which checks if the step should be executed with the current data.
reset(keep_buffer=False)

Resets all information of the step concerning a specific run. Furthermore, it resets also all steps of the subpipeline.

set_run_setting(run_setting: pywatts.core.run_setting.RunSetting)

Sets the run settings of the step for the current run. Note that after reset old setting is restored. Moreover, setting the computation_mode is only possible if the computation_mode is not set explicitly while adding the corresponding module to the pipeline. Moreover, it sets also the computation_mode of all steps in the subpipeline.

Parameters:computation_mode (ComputationMode) – The computation mode which should be set.

pywatts.core.probabilistic_step module

class pywatts.core.probabilistic_step.ProbablisticStep(module: pywatts.core.base.Base, input_steps: Dict[str, pywatts.core.base_step.BaseStep], file_manager, *, targets: Optional[Dict[str, BaseStep]] = None, computation_mode=<ComputationMode.Default: 4>, callbacks: List[Union[pywatts.callbacks.base_callback.BaseCallback, Callable[[Dict[str, xarray.core.dataarray.DataArray]], None]]] = [], condition=None, batch_size: None = None, refit_conditions=[], retrain_batch=Timedelta('1 days 00:00:00'), lag=Timedelta('1 days 00:00:00'))

Bases: pywatts.core.step.Step

This step calls the inverse_transform method of the corresponding module.

Parameters:
  • module (Base) – The module which is wrapped by the step-
  • input_step (Step) – The input_step of the module.
  • file_manager (FileManager) – The file_manager which is used for storing data.
  • target (Optional[Step]) – The step against which’s output the module of the current step should be fitted. (Default: None)
  • computation_mode (ComputationMode) – The computation mode which should be for this step. (Default: ComputationMode.Default)
  • plot (bool) – Flag if the result of this step should be plotted.
  • to_csv (bool) – Flag if the result of this step should be written in a csv file.
  • summary (bool) – Flag if the summary of the result of this step should be printed.
  • condition (Callable[xr.DataArray, xr.DataArray, bool]) – A callable which checks if the step should be executed with the current data.

pywatts.core.result_step module

class pywatts.core.result_step.ResultStep(input_steps, buffer_element: str)

Bases: pywatts.core.base_step.BaseStep

This steps fetch the correct column if the previous step provides data with multiple columns as output

get_json(fm: pywatts.core.filemanager.FileManager) → Dict[KT, VT]

Returns all information for restoring the resultStep.

get_result(start: pandas._libs.tslibs.timestamps.Timestamp, end: Optional[pandas._libs.tslibs.timestamps.Timestamp], buffer_element: str = None, return_all=False, minimum_data=(0, Timedelta('0 days 00:00:00')))

Returns the specified result of the previous step.

classmethod load(stored_step: dict, inputs, targets, module, file_manager)

Load a stored ResultStep.

Parameters:
  • stored_step – Informations about the stored step
  • inputs – The input step of the stored step
  • targets – The target step of the stored step
  • module – The module wrapped by this step
Returns:

Step

pywatts.core.run_setting module

class pywatts.core.run_setting.RunSetting(computation_mode: pywatts.core.computation_mode.ComputationMode, summary_formatter: pywatts.core.summary_formatter.SummaryFormatter = <pywatts.core.summary_formatter.SummaryMarkdown object>, online_start=None, return_summary=False)

Bases: object

The RunSetting contains the setting which is specific to one run.

Parameters:
  • computation_mode (ComputationMode) – The computation mode for the specific run.
  • summary_formatter (SummaryFormatter) – The formatter which formats the summary data.
clone() → pywatts.core.run_setting.RunSetting

Clones the current RunSetting. :return: The cloned RunSetting. :rtype: RunSetting

load()

Create a RunSetting from a Dict. :return: The loaded RunSetting :rtype: RunSetting

save() → Dict[KT, VT]

Saves the RunSetting as JSON. :return: A dict which contains all information needed for restoring the RunSetting :rtype: Dict

update(run_setting: pywatts.core.run_setting.RunSetting) → pywatts.core.run_setting.RunSetting

Updates and returns a new run_setting. Note The existing run_settings stay unchanged.

Parameters:run_setting (RunSetting) – The run_setting which should be combined with this RunSetting.
Returns:The new RunSetting
Return type:RunSetting

pywatts.core.start_step module

class pywatts.core.start_step.StartStep(index: str)

Bases: pywatts.core.base_step.BaseStep

Start Step of the pipeline.

further_elements(counter)

Checks if there exist at least one data for the time after counter.

Parameters:counter (pd.Timestamp) – The timestamp for which it should be tested if there exist further data after it.
Returns:True if there exist further data
Return type:bool
get_json(fm: pywatts.core.filemanager.FileManager) → Dict[KT, VT]

Returns all information that are needed for restoring the start step

classmethod load(stored_step: dict, inputs, targets, module, file_manager)

A classmethod which reloads a previously stored step.

Parameters:
  • stored_step
  • inputs
  • targets
  • module
Returns:

pywatts.core.step module

class pywatts.core.step.Step(module: pywatts.core.base.Base, input_steps: Dict[str, pywatts.core.base_step.BaseStep], file_manager, *, targets: Optional[Dict[str, BaseStep]] = None, computation_mode=<ComputationMode.Default: 4>, callbacks: List[Union[pywatts.callbacks.base_callback.BaseCallback, Callable[[Dict[str, xarray.core.dataarray.DataArray]], None]]] = [], condition=None, batch_size: None = None, refit_conditions=[], retrain_batch=Timedelta('1 days 00:00:00'), lag=Timedelta('1 days 00:00:00'))

Bases: pywatts.core.base_step.BaseStep

This step encapsulates modules and manages all information for executing a pipeline step. Including fetching the input from the input and target step.

Parameters:
  • module (Base) – The module which is wrapped by the step-
  • input_step (Step) – The input_step of the module.
  • file_manager (FileManager) – The file_manager which is used for storing data.
  • target (Optional[Step]) – The step against which’s output the module of the current step should be fitted. (Default: None)
  • computation_mode (ComputationMode) – The computation mode which should be for this step. (Default: ComputationMode.Default)
  • callbacks (List[Union[BaseCallback, Callable[[Dict[str, xr.DataArray]], None]]]) – Callbacks to use after results are processed.
  • condition (Callable[xr.DataArray, xr.DataArray, bool]) – A callable which checks if the step should be executed with the current data.
  • refit_conditions (List[Union[BaseCondition, Callable]]) – A List of Callables of BaseConditions, which contains a condition that indicates if the module should be trained or not
  • lag (pd.Timedelta) – Needed for online learning. Determines what data can be used for retraining. E.g., when 24 hour forecasts are performed, a lag of 24 hours is needed, else the retraining would use future values as target values.
  • retrain_batch (pd.Timedelta) – Needed for online learning. Determines how much data should be used for retraining.
get_json(fm: pywatts.core.filemanager.FileManager)

Returns a dictionary containing all information needed for restoring the step.

Parameters:fm (FileManager) – The filemanager which can be used by the step for storing the state of the step.
Returns:A dictionary containing all information needed for restoring the step.
Return type:Dict
get_result_step(item: str)
classmethod load(stored_step: Dict[KT, VT], inputs, targets, module, file_manager)

Load a stored step.

Parameters:
  • stored_step – Informations about the stored step
  • inputs – The input step of the stored step
  • targets – The target step of the stored step
  • module – The module wrapped by this step
Returns:

Step

refit(start: pandas._libs.tslibs.timestamps.Timestamp, end: pandas._libs.tslibs.timestamps.Timestamp)

Refits the module of the step. :param start: The date of the first data used for retraining. :param end: The date of the last data used for retraining.

pywatts.core.step_factory module

class pywatts.core.step_factory.StepFactory

Bases: object

A factory for creating the appropriate step for the current sitation.

create_step(module: pywatts.core.base.Base, kwargs: Dict[str, Union[pywatts.core.step_information.StepInformation, Tuple[pywatts.core.step_information.StepInformation, ...]]], use_inverse_transform: bool, use_predict_proba: bool, callbacks: List[Union[pywatts.callbacks.base_callback.BaseCallback, Callable[[Dict[str, xarray.core.dataarray.DataArray]], None]]], condition, batch_size, computation_mode, refit_conditions, retrain_batch, lag)

Creates a appropriate step for the current situation.

Parameters:
  • module – The module which should be added to the pipeline
  • kwargs – The input steps for the current step
  • targets – The target steps for the currrent step
  • use_inverse_transform – Should inverse_transform be called instead of transform
  • use_predict_proba – Should probabilistic_transform be called instead of transform
  • callbacks – Callbacks to use after results are processed.
  • condition – A function returning True or False which indicates if the step should be performed
  • batch_size – The size of the past time range which should be used for relearning the module
  • computation_mode – The computation mode of the step
  • refit_conditions – A List of methods or Base Conditions for determining if the step should be fitted at a specific timestamp.
  • retrain_batch – Determines how much past data should be used for relearning.
  • lag – Needed for online learning. Determines what data can be used for retraining. E.g., when 24 hour forecasts are performed, a lag of 24 hours is needed, else the retraining would use future values as target values.
Returns:

StepInformation

create_summary(module: pywatts.core.base_summary.BaseSummary, kwargs: Dict[str, Union[pywatts.core.step_information.StepInformation, Tuple[pywatts.core.step_information.StepInformation, ...]]]) → pywatts.core.step_information.SummaryInformation

pywatts.core.step_information module

class pywatts.core.step_information.StepInformation(step: pywatts.core.base_step.BaseStep, pipeline)

Bases: object

This steps contains information necesary for creating a pipeline and steps by the step factory

Parameters:
  • step – The step
  • pipeline – The pipeline
class pywatts.core.step_information.SummaryInformation(step, pipeline)

Bases: object

pywatts.core.summary_formatter module

class pywatts.core.summary_formatter.SummaryFormatter

Bases: abc.ABC

SummaryFormatter is responsible for formatting the SummaryObjects according to the output file.

create_summary(summaries: List[pywatts.core.summary_object.SummaryObject], fm: pywatts.core.filemanager.FileManager)

This method is responsible for creating and storing the summaries according to the output file. :param summaries: The summaries that should be stored. :type summaries: List[SummaryObject] :param fm: The pyWATTS filemanager. :type fm: FileManager

class pywatts.core.summary_formatter.SummaryJSON

Bases: pywatts.core.summary_formatter.SummaryFormatter

SummaryJSON is a SummaryFormatter that save the SummaryObjects according as json file.

create_summary(summaries: List[pywatts.core.summary_object.SummaryObject], fm: pywatts.core.filemanager.FileManager)

This method is responsible for creating and storing the summaries as json file. :param summaries: The summaries that should be stored. :type summaries: List[SummaryObject] :param fm: The pyWATTS filemanager. :type fm: FileManager

class pywatts.core.summary_formatter.SummaryMarkdown

Bases: pywatts.core.summary_formatter.SummaryFormatter

SummaryMarkdown is a SummaryFormatter that save the SummaryObjects according as markdown file.

create_summary(summaries: List[pywatts.core.summary_object.SummaryObject], fm: pywatts.core.filemanager.FileManager)

This method is responsible for creating and storing the summaries as markdown file. :param summaries: The summaries that should be stored. :type summaries: List[SummaryObject] :param fm: The pyWATTS filemanager. :type fm: FileManager

pywatts.core.summary_object module

class pywatts.core.summary_object.SummaryCategory

Bases: enum.IntEnum

Category for Summaries.

FitTime = 3
Summary = 1
TransformTime = 2
class pywatts.core.summary_object.SummaryObject(name: str, category: pywatts.core.summary_object.SummaryCategory = <SummaryCategory.Summary: 1>, additional_information: str = '')

Bases: abc.ABC

A SummaryObject contains the results of a Summary Module.

Parameters:
  • name (str) – Name of the summary object. Is also the headline in the resulting summary file.
  • category (SummaryCategory) – The category of the SummaryObject. Determines the section in the final summary file of the result of this summary object.
  • additional_information (str) – A string containing additional information that should be stored in the summary.
set_kv(key, value)

This method sets a value in this summary information. :param key: the key of the value. :param value: the value

class pywatts.core.summary_object.SummaryObjectList(name: str, category: pywatts.core.summary_object.SummaryCategory = <SummaryCategory.Summary: 1>, additional_information: str = '')

Bases: pywatts.core.summary_object.SummaryObject

A SummaryObjectList contains the results of a Summary Module. In the resulting file the summary of this object will be saved as list.

Parameters:
  • name (str) – Name of the summary object. Is also the headline in the resulting summary file.
  • category (SummaryCategory) – The category of the SummaryObject. Determines the section in the final summary file of the result of this summary object.
  • additional_information (str) – A string containing additional information that should be stored in the summary.
class pywatts.core.summary_object.SummaryObjectTable(name: str, category: pywatts.core.summary_object.SummaryCategory = <SummaryCategory.Summary: 1>, additional_information: str = '')

Bases: pywatts.core.summary_object.SummaryObject

A SummaryObjectList contains the results of a Summary Module. In the resulting file the summary of this object will be saved as table.

Parameters:
  • name (str) – Name of the summary object. Is also the headline in the resulting summary file.
  • category (SummaryCategory) – The category of the SummaryObject. Determines the section in the final summary file of the result of this summary object.
  • additional_information (str) – A string containing additional information that should be stored in the summary.

pywatts.core.summary_step module

class pywatts.core.summary_step.SummaryStep(module: pywatts.core.base_summary.BaseSummary, input_steps: Dict[str, pywatts.core.base_step.BaseStep], file_manager)

Bases: pywatts.core.step.Step

This step encapsulates modules and manages all information for executing a pipeline step. Including fetching the input from the input and target step.

Parameters:
  • module (Base) – The module which is wrapped by the step-
  • input_step (Step) – The input_step of the module.
  • file_manager (FileManager) – The file_manager which is used for storing data.
get_json(fm: pywatts.core.filemanager.FileManager)

Returns a dictionary containing all information needed for restoring the step.

Parameters:fm (FileManager) – The filemanager which can be used by the step for storing the state of the step.
Returns:A dictionary containing all information needed for restoring the step.
Return type:Dict
get_summary(start, end) → pywatts.core.summary_object.SummaryObject

Calculates a summary for the input data. :return: The summary as markdown formatted string :rtype: Str

classmethod load(stored_step: dict, inputs, targets, module, file_manager)

Load a stored step.

Parameters:
  • stored_step – Informations about the stored step
  • inputs – The input step of the stored step
  • targets – The target step of the stored step
  • module – The module wrapped by this step
Returns:

Step

pywatts.core.template module

class pywatts.core.template.Template(name: str)

Bases: pywatts.core.base.BaseEstimator

Template for a estimator For a transformer replace the base class BaseEstimator with BaseTransformer and delete the fit method

Parameters:name (str) – The name of the module

Add further parameters of the module

fit(x: xarray.core.dataarray.DataArray, y: xarray.core.dataarray.DataArray)

Fit the model, e.g. optimize parameters such that model(x) = y

Parameters:
  • x (xarray.Dataset) – input
  • y (xarray.Dataset) – target
get_params() → Dict[str, object]

Returns all parameters in a dict

Returns:Dict with params
Return type:Dict
inverse_transform(x: xarray.core.dataarray.DataArray) → xarray.core.dataarray.DataArray

Inverse transform, necessary, for example, for methods for that can perform the inverse of the transform, e.g., Scaler.

Note if you implement this method, the flag “self.has_inverse_transform” must be set to true in the constructor

Parameters:x (xarray.Dataset) – the input
Returns:The transformed input
Return type:xarray.Dataset
predict_proba(x: xarray.core.dataarray.DataArray) → xarray.core.dataarray.DataArray

Probabilistic transform, necessary, for example, for methods for probabilist forecasts.

Note if you implement this method, the flag “self.has_predict_proba” must be set to true in the constructor

Parameters:x (xarray.Dataset) – the input
Returns:The transformed input
Return type:xarray.Dataset
set_params(**kwargs)

This method sets the parameters. If there is no parameter, write pass in the method’s body.

Parameters:Parameter1 (The type of Parameter 1) – Parameter1 is responsible for …

transform(x: Optional[xarray.core.dataarray.DataArray]) → xarray.core.dataarray.DataArray

Transforms the input

Parameters:x (xarray.Dataset) – the input
Returns:The transformed input
Return type:xarray.Dataset

Module contents