Create Listener
Two ways to define listener​
- Listener
- model.to_linstener
from superduper import Listener
db.apply(
Listener(
key='key_name',
model=model,
select=select,
)
)
db.apply(model.to_listener(key='key_name', select=select))
Data passed into the model​
- Single Field
- Multiple fields(*args)
- Multiple fields(*kwargs)
# Model predict function definition: model.predict(x)
# Data example in database: {"key_name": 10}
# Then the listener will call model.predict(10)
from superduper import Listener
db.apply(
Listener(
key='key_name',
model=model,
select=select,
)
)
# Model predict function definition: model.predict(x1, x2)
# Data example in database: {"key_name_1": 10, "key_name_2": 100}
# Then the listener will call model.predict(10, 100)
from superduper import Listener
db.apply(
Listener(
key=['key_name_1', 'key_name_2'],
model=model,
select=select,
)
)
# Model predict function definition: model.predict(x1, x2)
# Data example in database: {"key_name_1": 10, "key_name_2": 100}
# Then the listener will call model.predict(x1=10, x2=100)
from superduper import Listener
db.apply(
Listener(
key={"key_name_1": "x1", "key_name_2": "x2"},
model=model,
select=select,
)
)