FldExporter
FldExporter
¶
Bases: Exporter
Export the input values and output values of an engine to the FuzzyLite Dataset (FLD) format.
related
warning
FldExporter uses vectorization so it only works with the fuzzylite.activation.General activation method
todo
include option for non-vectorized export so other activation methods can be used
Attributes¶
Classes¶
ScopeOfValues
¶
Bases: Enum
Scope of the equally-distributed values to generate.
EachVariable
: Generates \(v\) values for each variable, resulting in a total resolution of \(-1 + \max(1, v^{\frac{1}{|I|})\) from all combinations, where \(I\) refers to the input variables.AllVariables
: Generates values for each variable such that the total resolution is \(v\).
Functions¶
__init__
¶
header
¶
to_file_from_reader
¶
Write the FuzzyLite Dataset to the file using the input values from the engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
path to the output file |
required |
engine |
Engine
|
engine to export |
required |
reader |
IO[str]
|
reader of a set of lines containing space-separated input values |
required |
skip_lines |
int
|
number of lines to skip from the beginning. |
0
|
Returns:
Type | Description |
---|---|
None
|
FuzzyLite Dataset from the engine. |
to_file_from_scope
¶
to_file_from_scope(
path: Path,
engine: Engine,
values: int = 1024,
scope: ScopeOfValues = ScopeOfValues.AllVariables,
active_variables: set[InputVariable] | None = None,
) -> None
Write the FuzzyLite Dataset from the engine to the file using the input values and their scope.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
file path |
required |
engine |
Engine
|
engine to export |
required |
values |
int
|
number of values to export |
1024
|
scope |
ScopeOfValues
|
scope of the values |
AllVariables
|
active_variables |
set[InputVariable] | None
|
set of input variables to set values for |
None
|
to_string
¶
Return a FuzzyLite Dataset from the engine using 1024 input values for all variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance |
object
|
engine to export |
required |
Returns:
Type | Description |
---|---|
str
|
FuzzyLite Dataset from the engine |
Raises:
Type | Description |
---|---|
ValueError
|
if the instance is not an Engine. |
to_string_from_reader
¶
Return a FuzzyLite Dataset from the engine using the input values from the reader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine |
Engine
|
engine to export |
required |
reader |
IO[str]
|
reader of a set of lines containing space-separated input values |
required |
skip_lines |
int
|
number of lines to skip from the beginning |
0
|
Returns:
Type | Description |
---|---|
str
|
FuzzyLite Dataset from the engine. |
to_string_from_scope
¶
to_string_from_scope(
engine: Engine,
values: int = 1024,
scope: ScopeOfValues = ScopeOfValues.AllVariables,
active_variables: set[InputVariable] | None = None,
) -> str
Return a FuzzyLite Dataset from the engine using the input values and their scope.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine |
Engine
|
engine to export |
required |
values |
int
|
number of values to export |
1024
|
scope |
ScopeOfValues
|
scope of the values |
AllVariables
|
active_variables |
set[InputVariable] | None
|
input variables to set values for |
None
|
Returns:
Type | Description |
---|---|
str
|
FuzzyLite Dataset from the engine. |
write
¶
write_from_reader
¶
Write the FuzzyLite Dataset from the engine to the writer using the input values from the reader.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine |
Engine
|
engine to export |
required |
writer |
IO[str]
|
output to write the engine |
required |
reader |
IO[str]
|
reader of a set of lines containing space-separated input values |
required |
skip_lines |
int
|
number of lines to skip from the beginning. |
0
|
write_from_scope
¶
write_from_scope(
engine: Engine,
writer: IO[str],
values: int,
scope: ScopeOfValues,
active_variables: set[InputVariable] | None = None,
) -> None
Write a FuzzyLite dataset from the engine to the writer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
engine |
Engine
|
engine to export |
required |
writer |
IO[str]
|
output to write the engine |
required |
values |
int
|
number of values to export |
required |
scope |
ScopeOfValues
|
scope of the values |
required |
active_variables |
set[InputVariable] | None
|
input variables to generate values for. |
None
|