alpbench.benchmark.BenchmarkConnector¶
Classes
Benchmark Connector |
|
|
This class is a custom JSON encoder that is used to encode the parameters of a learner or query strategy. |
|
Data File Benchmark Connector |
|
MySQL Benchmark Connector |
- class alpbench.benchmark.BenchmarkConnector.BenchmarkConnector[source]¶
Bases:
ABCBenchmark Connector
This abstract class defines the interface for a benchmark connector. A benchmark connector is responsible for storing and loading all data related to the active learning benchmark. This includes the active learning setting and scenario as well as the learner and query strategy with all used parameters. The data is stored in a database or file and can be accessed by the respective methods of this class.
- abstract load_learner(learner_id)[source]¶
Abstract method that loads the learner with the specified ID from the database.
- abstract load_learner_by_name(learner_name)[source]¶
Abstract method that loads the learner with the specified name from the database.
- abstract load_or_create_learner(learner_name, obj)[source]¶
Abstract method that loads the learner with the specified parameters from the database. If the learner does not exist yet, it is created and then returned to the invoker.
- abstract load_or_create_query_strategy(query_strategy_name, obj)[source]¶
Abstract method that loads the query strategy with the specified parameters from the database. If the query strategy does not exist yet, it is created and then returned to the invoker.
- abstract load_or_create_scenario(openml_id, test_split_seed, train_split_seed, seed, setting_id)[source]¶
Abstract method that loads the scenario with the specified parameters from the database. If the scenario does not exist yet, it is created and then returned to the invoker.
- abstract load_or_create_setting(name, labeled_train_size, train_type, test_size, number_of_iterations, number_of_queries, factor)[source]¶
Abstract method that loads the setting with the specified parameters from the database. If the setting does not exist yet, it is created and then returned to the invoker.
- abstract load_query_strategy(query_strategy_id)[source]¶
Abstract method that loads the query strategy with the specified ID from the database.
- abstract load_query_strategy_by_name(query_strategy_name)[source]¶
Abstract method that loads the query strategy with the specified name from the database.
- abstract load_scenario(scenario_id)[source]¶
Abstract method that loads the scenario with the specified ID from the database.
- class alpbench.benchmark.BenchmarkConnector.CustomEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoderThis class is a custom JSON encoder that is used to encode the parameters of a learner or query strategy.
- class alpbench.benchmark.BenchmarkConnector.DataFileBenchmarkConnector(learner_file=None, query_strategy_file=None, scenario_file=None, setting_file=None)[source]¶
Bases:
BenchmarkConnectorData File Benchmark Connector
This class is an implementation of the BenchmarkConnector interface that stores all data in files. This involves the Active Learning Setting and Scenario as well as the Learner and query Strategy with all used parameters. The data is stored in JSON files and can be accessed by the respective methods of this class.
- Parameters:
- load_learner(learner_id)[source]¶
This method loads the learner with the specified ID from the database.
- load_learner_by_name(learner_name)[source]¶
This method loads the learner with the specified name from the database.
- load_or_create_learner(learner_name, obj)[source]¶
This method checks whether the specified learner already exists in the database. If not, the specified setting is added to the database and then also returned to the invoker.
- load_or_create_query_strategy(query_strategy_name, obj)[source]¶
This method checks whether the specified query strategy already exists in the database. If not, the specified query strategy including its parameterization is added to the database and then also returned to the invoker.
- load_or_create_scenario(openml_id, test_split_seed, train_split_seed, seed, setting_id)[source]¶
This method loads the scenario with the specified parameters from the database. If the scenario does not exist yet, it is created and then returned to the invoker.
- Parameters:
- Returns:
the loaded or created scenario
- Return type:
- load_or_create_setting(name, labeled_train_size, train_type, test_size, number_of_iterations, number_of_queries, factor)[source]¶
This method checks whether the specified setting already exists. If so, it just fetches the data from the database and returns an instance. If not, the specified setting is added to the database and then also returned.
- Parameters:
- Returns:
the loaded or created setting
- Return type:
- load_query_strategy(query_strategy_id)[source]¶
This method loads the query strategy with the specified ID from the database.
- load_query_strategy_by_name(query_strategy_name)[source]¶
This method loads the query strategy with the specified name from the database.
- load_scenario(scenario_id)[source]¶
This method loads the scenario with the specified ID from the database.
- Parameters:
scenario_id (int) – ID of the scenario to load
- Returns:
the loaded scenario
- Return type:
- load_setting(setting_id)[source]¶
This method loads the setting with the specified ID from the database.
- Parameters:
setting_id (int) – ID of the setting to load
- Returns:
the loaded setting
- Return type:
- load_setting_by_name(setting_name)[source]¶
This method loads the setting with the specified name from the database.
- Parameters:
setting_name (str) – name of the setting to load
- Returns:
the loaded setting
- Return type:
- base_folder = 'db_alpbench/'¶
- learner_file = 'db_alpbench/learner.json'¶
- query_strategy_file = 'db_alpbench/query_strategy.json'¶
- scenario_file = 'db_alpbench/scenario.json'¶
- setting_file = 'db_alpbench/setting.json'¶
- class alpbench.benchmark.BenchmarkConnector.MySQLBenchmarkConnector(host, user, password, database, use_ssl)[source]¶
Bases:
BenchmarkConnectorMySQL Benchmark Connector
This class is an implementation of the BenchmarkConnector interface that stores all data in a MySQL database. This involves the Active Learning Setting and Scenario as well as the Learner and query Strategy with all used parameters. The data is stored in MySQL tables and can be accessed by the respective methods of this class.
- Parameters:
- con¶
connection to the MySQL database
- Type:
mysql.connector.connection.MySQLConnection
- load_learner(learner_id)[source]¶
This method loads the learner with the specified ID from the database.
- load_learner_by_name(learner_name)[source]¶
This method loads the learner with the specified name from the database.
- load_or_create_learner(learner_name, obj)[source]¶
This method checks whether the specified learner already exists in the database. If not, the specified setting is added to the database and then also returned to the invoker.
- load_or_create_query_strategy(query_strategy_name, obj)[source]¶
This method checks whether the specified query strategy already exists in the database. If not, the specified query strategy including its parameterization is added to the database and then also returned to the invoker.
- load_or_create_scenario(openml_id, test_split_seed, train_split_seed, seed, setting_id)[source]¶
This method loads the scenario with the specified parameters from the database. If the scenario does not exist yet, it is created and then returned to the invoker.
- Parameters:
- Returns:
the loaded or created scenario
- Return type:
- load_or_create_setting(name, labeled_train_size, train_type, test_size, number_of_iterations, number_of_queries, factor)[source]¶
This method checks whether the specified setting already exists. If so, it just fetches the data from the database and returns an instance. If not, the specified setting is added to the database and then also returned to the invoker.
- Parameters:
- Returns:
the loaded or created setting
- Return type:
- load_query_strategy(query_strategy_id)[source]¶
This method loads the query strategy with the specified ID from the database.
- load_query_strategy_by_name(query_strategy_name)[source]¶
This method loads the query strategy with the specified name from the database.
- load_scenario(scenario_id)[source]¶
This method loads the scenario with the specified ID from the database.
- Parameters:
scenario_id (int) – ID of the scenario to load
- Returns:
the loaded scenario
- Return type:
- load_setting(setting_id)[source]¶
This method loads the setting with the specified ID from the database.
- Parameters:
setting_id (int) – ID of the setting to load
- Returns:
the loaded setting
- Return type:
- load_setting_by_name(setting_name)[source]¶
This method loads the setting with the specified name from the database.
- Parameters:
setting_name (str) – name of the setting to load
- Returns:
the loaded setting
- Return type:
- learner_table = 'salt_learner'¶
- query_strategy_table = 'salt_query_strategy'¶
- scenario_table = 'salt_scenario'¶
- setting_table = 'salt_setting'¶