ribs.archives.ArchiveDataFrame¶
- class ribs.archives.ArchiveDataFrame(*args, **kwargs)[source]¶
A modified
DataFrame
for archive data.As this class inherits from
DataFrame
, it has the same methods, attributes, and arguments (even though the arguments shown here are*args
and**kwargs
). However, this class adds methods that make it convenient to work with elites. This documentation only lists these additional methods and attributes.Example
This object is created by
as_pandas()
(i.e. users typically do not create it on their own):df = archive.as_pandas()
To iterate through every
Elite
, use:for elite in df.iterelites(): elite.solution elite.objective ...
There are also methods to access the solutions, objectives, etc. of all elites in the archive. For instance, the following is an array where entry
i
contains the measures of thei
’th elite in the DataFrame:df.measures_batch()
Warning
Accessing
batch
methods (e.g.measures_batch()
) always creates a copy, so the following will copy the measures 3 times:df.measures_batch()[0] df.measures_batch().mean() df.measures_batch().median()
Thus, if you need to use the method several times, we recommend storing it first, like so:
measures_batch = df.measures_batch() measures_batch[0] measures_batch.mean() measures_batch.median()
Note
After saving an ArchiveDataFrame to a CSV, loading it with
pandas.read_csv()
will load aDataFrame
. To load a CSV as an ArchiveDataFrame, pass theDataFrame
fromread_csv
to ArchiveDataFrame:df = ArchiveDataFrame(pd.read_csv("file.csv"))
Note
All the
batch
methods “align” with each other – i.e.measures_batch()[i]
corresponds toindex_batch()[i]
,metadata_batch()[i]
,objective_batch()[i]
, andsolution_batch()[i]
.Methods
Array with solutions of all elites.
Array with objective values of all elites.
Array with measures of all elites.
Array with indices of all elites.
Array with metadata of all elites.
Iterator which outputs every
Elite
in the ArchiveDataFrame.Attributes
- index_batch()[source]¶
Array with indices of all elites.
None if there are no indices in the
ArchiveDataFrame
.- Returns
See above.
- Return type
(n,) numpy.ndarray
- iterelites()[source]¶
Iterator which outputs every
Elite
in the ArchiveDataFrame.Data which is unavailable will be turned into None. For example, if there are no solution columns, then
elite.solution
will be None.
- measures_batch()[source]¶
Array with measures of all elites.
None if there are no measures in the
ArchiveDataFrame
.- Returns
See above.
- Return type
(n, measure_dim) numpy.ndarray
- metadata_batch()[source]¶
Array with metadata of all elites.
None if there is no metadata (e.g. if
include_metadata=False
inas_pandas()
).- Returns
See above.
- Return type
(n,) numpy.ndarray
- objective_batch()[source]¶
Array with objective values of all elites.
None if there are no objectives in the
ArchiveDataFrame
.- Returns
See above.
- Return type
(n,) numpy.ndarray
- solution_batch()[source]¶
Array with solutions of all elites.
None if there are no solutions (e.g. if
include_solutions=False
inas_pandas()
).- Returns
See above.
- Return type
(n, solution_dim) numpy.ndarray