ParameterHistory

class glotaran.parameter.parameter_history.ParameterHistory[source]

Bases: object

A class representing a history of parameters.

Attributes Summary

number_of_records

Return the number of records in the history.

parameter_labels

Return the labels of the parameters in the history.

parameters

Return the parameters in the history.

Methods Summary

append

Append Parameters to the history.

from_csv

Create a history from a csv file.

from_dataframe

Create a history from a pandas data frame.

get_parameters

Get parameters for a history index.

loader

Create a history from a csv file.

to_csv

Write a ParameterHistory to a CSV file.

to_dataframe

Create a data frame from the history.

Methods Documentation

append(parameters: Parameters, current_iteration: int = 0)[source]

Append Parameters to the history.

Parameters:
  • parameters (Parameters) – The group to append.

  • current_iteration (int) – Current iteration of the optimizer.

Raises:

ValueError – Raised if the parameter labels differs from previous.

classmethod from_csv(path: str) ParameterHistory[source]

Create a history from a csv file.

Parameters:

path (str) – The path to the csv file.

Returns:

The created history.

Return type:

ParameterHistory

classmethod from_dataframe(history_df: DataFrame) ParameterHistory[source]

Create a history from a pandas data frame.

Parameters:

history_df (pd.DataFrame) – The source data frame.

Returns:

The created history.

Return type:

ParameterHistory

get_parameters(index: int) ndarray[source]

Get parameters for a history index.

Parameters:

index (int) – The history index.

Returns:

The parameter values at the history index as array.

Return type:

np.ndarray

classmethod loader(path: str) ParameterHistory

Create a history from a csv file.

Parameters:

path (str) – The path to the csv file.

Returns:

The created history.

Return type:

ParameterHistory

property number_of_records: int

Return the number of records in the history.

Returns:

The number of records.

Return type:

int

property parameter_labels: list[str]

Return the labels of the parameters in the history.

Returns:

A list of parameter labels.

Return type:

list[str]

property parameters: list[ndarray]

Return the parameters in the history.

Returns:

A list of parameters in the history.

Return type:

list[np.ndarray]

to_csv(file_name: str | PathLike[str], delimiter: str = ',')[source]

Write a ParameterHistory to a CSV file.

Parameters:
  • file_name (str) – The path to the CSV file.

  • delimiter (str) – The delimiter of the CSV file.

to_dataframe() DataFrame[source]

Create a data frame from the history.

Returns:

The created data frame.

Return type:

pd.DataFrame