class ModelFeatureStore: (source)
Undocumented
Method | all |
Undocumented |
Method | cached |
Loads the model features from a pre computed location |
Method | depends |
Returns the views and models that the model depend on to compute it's output. |
Method | feature |
Undocumented |
Method | features |
Returns the features for the given entities |
Async Method | freshness |
Undocumented |
Method | has |
Undocumented |
Method | has |
If the input features are from the same source. |
Async Method | input |
Undocumented |
Method | input |
Undocumented |
Async Method | insert |
Writes data to a source defined as a prediction source |
Method | needed |
Undocumented |
Method | predict |
Undocumented |
Async Method | prediction |
Undocumented |
Method | prediction |
Undocumented |
Method | predictions |
Undocumented |
Method | predictions |
Undocumented |
Method | process |
Undocumented |
Method | raw |
Undocumented |
Method | request |
Undocumented |
Async Method | upsert |
Upserts data to a source defined as a prediction source |
Method | using |
Undocumented |
Method | using |
Undocumented |
Method | with |
Will also load the labels for the model |
Class Variable | model |
Undocumented |
Class Variable | selected |
Undocumented |
Class Variable | store |
Undocumented |
Property | dataset |
Undocumented |
Property | location |
Undocumented |
Loads the model features from a pre computed location
```python from aligned import FileSource
store = await FileSource.json_at("features-latest.json").feature_store()
cached_features = FileSource.parquet_at("titanic_features.parquet")
- df = store.model("titanic")
- .cached_at(cached_features).to_polars()
print(df.collect()) >>> ┌──────────────┬───────┬─────────┬─────────────────────┬──────────────┐ >>> │ passenger_id ┆ is_mr ┆ is_male ┆ constant_filled_age ┆ has_siblings │ >>> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ >>> │ i32 ┆ bool ┆ bool ┆ f64 ┆ bool │ >>> ╞══════════════╪═══════╪═════════╪═════════════════════╪══════════════╡ >>> │ 1 ┆ true ┆ true ┆ 22.0 ┆ true │ >>> │ 2 ┆ false ┆ false ┆ 38.0 ┆ true │ >>> │ 3 ┆ false ┆ false ┆ 26.0 ┆ false │ >>> └──────────────┴───────┴─────────┴─────────────────────┴──────────────┘ ```
- Args:
- location (DataFileReference): _description_
- Returns:
- RetrivalJob: _description_
Returns the views and models that the model depend on to compute it's output.
```python @feature_view(name="passenger", ...) class Passenger:
passenger_id = Int32().as_entity()
age = Float()
@feature_view(name="location", ...) class Location:
location_id = String().as_entity()
location_area = Float()
@model_contract(name="some_model", ...) class SomeModel:
some_id = String().as_entity()
some_computed_metric = Int32()
- @model_contract(
name="new_model", features=[
Passenger().age, Location().location_area, SomeModel().some_computed_metric
]
) class NewModel:
...
print(store.model("new_model").depends_on()) >>> { >>> FeatureLocation(location="feature_view", name="passenger"), >>> FeatureLocation(location="feature_view", name="location"), >>> FeatureLocation(location="model", name="some_model") >>> }
```
ConvertableToRetrivalJob | RetrivalJob
, event_timestamp_column: str | None
= None) -> RetrivalJob
:
(source)
¶
Returns the features for the given entities
```python store = await FileSource.json_at("features-latest.json").feature_store()
- df = store.model("titanic")
- .features_for({"passenger_id": [1, 2, 3]}).to_polars()
print(df.collect()) >>> ┌──────────────┬───────┬─────────┬─────────────────────┬──────────────┐ >>> │ passenger_id ┆ is_mr ┆ is_male ┆ constant_filled_age ┆ has_siblings │ >>> │ --- ┆ --- ┆ --- ┆ --- ┆ --- │ >>> │ i32 ┆ bool ┆ bool ┆ f64 ┆ bool │ >>> ╞══════════════╪═══════╪═════════╪═════════════════════╪══════════════╡ >>> │ 1 ┆ true ┆ true ┆ 22.0 ┆ true │ >>> │ 2 ┆ false ┆ false ┆ 38.0 ┆ true │ >>> │ 3 ┆ false ┆ false ┆ 26.0 ┆ false │ >>> └──────────────┴───────┴─────────┴─────────────────────┴──────────────┘ ```
- Args:
- entities (dict[str, list] | RetrivalJob): The entities to fetch features for
- Returns:
- RetrivalJob: A retrival job that can be used to fetch the features
If the input features are from the same source.
This can be interesting to know in order to automatically predict over the input. E.g. predict over all data in the source.
set[ str] | None
= None, event_timestamp_column: str | None
= None) -> FeatureRequest
:
(source)
¶
Undocumented
Writes data to a source defined as a prediction source
```python @model_contract(
name="taxi_eta", features=[...] predictions_source=FileSource.parquet_at("predictions.parquet")
) class TaxiEta:
trip_id = Int32().as_entity()
duration = Int32()
...
store = FeatureStore.from_dir(".")
- await store.model("taxi_eta").insert_predictions({
- "trip_id": [1, 2, 3, ...], "duration": [20, 33, 42, ...]
})
ConvertableToRetrivalJob | RetrivalJob
) -> PredictionJob
:
(source)
¶
Undocumented
set[ str] | None
= None, model_version_as_entity: bool
= False) -> RetrivalRequest
:
(source)
¶
Undocumented
ConvertableToRetrivalJob | RetrivalJob
, event_timestamp_column: str | None
= None, model_version_as_entity: bool | None
= None) -> RetrivalJob
:
(source)
¶
Undocumented
RetrivalJob | ConvertableToRetrivalJob
) -> RetrivalJob
:
(source)
¶
Undocumented
set[ str] | None
= None, event_timestamp_column: str | None
= None) -> FeatureRequest
:
(source)
¶
Undocumented
Upserts data to a source defined as a prediction source
```python @model_contract(
name="taxi_eta", features=[...] predictions_source=FileSource.parquet_at("predictions.parquet")
) class TaxiEta:
trip_id = Int32().as_entity()
duration = Int32()
...
store = FeatureStore.from_dir(".")
- await store.model("taxi_eta").upsert_predictions({
- "trip_id": [1, 2, 3, ...], "duration": [20, 33, 42, ...]
})
FeatureSourceable | BatchDataSource
) -> ModelFeatureStore
:
(source)
¶
Undocumented
set[ FeatureReference] | None
= None) -> SupervisedModelFeatureStore
:
(source)
¶
Will also load the labels for the model
```python store = await FileSource.json_at("features-latest.json").feature_store()
- data = store.model("titanic")
- .with_labels().features_for({"passenger_id": [1, 2, 3]}).to_polars()
print(data.labels.collect(), data.input.collect()) >>> ┌──────────┐ ┌───────┬─────────┬─────────────────────┬──────────────┐ >>> │ survived │ │ is_mr ┆ is_male ┆ constant_filled_age ┆ has_siblings │ >>> │ --- │ │ --- ┆ --- ┆ --- ┆ --- │ >>> │ bool │ │ bool ┆ bool ┆ f64 ┆ bool │ >>> ╞══════════╡ ╞═══════╪═════════╪═════════════════════╪══════════════╡ >>> │ false │ │ true ┆ true ┆ 22.0 ┆ true │ >>> │ true │ │ false ┆ false ┆ 38.0 ┆ true │ >>> │ true │ │ false ┆ false ┆ 26.0 ┆ false │ >>> └──────────┘ └───────┴─────────┴─────────────────────┴──────────────┘ ```
- Returns:
- SupervisedModelFeatureStore: A new queryable feature store