striatum.storage package¶
Submodules¶
striatum.storage.model module¶
Model storage
-
class
striatum.storage.model.MemoryModelStorage¶ Bases:
striatum.storage.model.ModelStorageStore the model in memory.
Methods
get_model()save_model(model)-
get_model()¶
-
save_model(model)¶
-
-
class
striatum.storage.model.ModelStorage¶ Bases:
objectThe object to store the model.
Methods
get_model()Get model save_model()Save model -
get_model()¶ Get model
-
save_model()¶ Save model
-
striatum.storage.history module¶
History storage
-
class
striatum.storage.history.History(history_id, context, recommendations, created_at, rewards=None, rewarded_at=None)¶ Bases:
objectaction/reward history entry.
Parameters: history_id : int
context : {dict of list of float, None}
recommendations : {Recommendation, list of Recommendation}
created_at : datetime
rewards : {float, dict of float, None}
rewarded_at : {datetime, None}
Methods
update_reward(rewards, rewarded_at)Update reward_time and rewards. -
update_reward(rewards, rewarded_at)¶ Update reward_time and rewards.
Parameters: rewards : {float, dict of float, None}
rewarded_at : {datetime, None}
-
-
class
striatum.storage.history.HistoryStorage¶ Bases:
objectThe object to store the history of context, recommendations and rewards.
Methods
add_history(context, recommendations[, rewards])Add a history record. add_reward(history_id, rewards)Add reward to a history record. get_history(history_id)Get the previous context, recommendations and rewards with history_id. get_unrewarded_history(history_id)Get the previous unrewarded context, recommendations and rewards with history_id. -
add_history(context, recommendations, rewards=None)¶ Add a history record.
Parameters: context : {dict of list of float, None}
recommendations : {Recommendation, list of Recommendation}
rewards : {float, dict of float, None}
-
add_reward(history_id, rewards)¶ Add reward to a history record.
Parameters: history_id : int
The history id of the history record to retrieve.
rewards : {float, dict of float, None}
-
get_history(history_id)¶ Get the previous context, recommendations and rewards with history_id.
Parameters: history_id : int
The history id of the history record to retrieve.
Returns: history: History
-
get_unrewarded_history(history_id)¶ Get the previous unrewarded context, recommendations and rewards with history_id.
Parameters: history_id : int
The history id of the history record to retrieve.
Returns: history: History
-
-
class
striatum.storage.history.MemoryHistoryStorage¶ Bases:
striatum.storage.history.HistoryStorageHistoryStorage that store all data in memory
Methods
add_history(context, recommendations[, rewards])Add a history record. add_reward(history_id, rewards)Add reward to a history record. get_history(history_id)Get the previous context, recommendations and rewards with history_id. get_unrewarded_history(history_id)Get the previous unrewarded context, recommendations and rewards with history_id. -
add_history(context, recommendations, rewards=None)¶ Add a history record.
Parameters: context : {dict of list of float, None}
recommendations : {Recommendation, list of Recommendation}
rewards : {float, dict of float, None}
-
add_reward(history_id, rewards)¶ Add reward to a history record.
Parameters: history_id : int
The history id of the history record to retrieve.
rewards : {float, dict of float, None}
-
get_history(history_id)¶ Get the previous context, recommendations and rewards with history_id.
Parameters: history_id : int
The history id of the history record to retrieve.
Returns: history: History
-
get_unrewarded_history(history_id)¶ Get the previous unrewarded context, recommendations and rewards with history_id.
Parameters: history_id : int
The history id of the history record to retrieve.
Returns: history: History
-
Module contents¶
Storage classes