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 the model has produced. |
Method | filter |
Undocumented |
Async Method | freshness |
Undocumented |
Method | has |
Undocumented |
Method | has |
If the input features are from the same source. |
Method | input |
The input features to load, based on the input features in a model. |
Method | input |
Returns the features to pass into a model |
Async Method | input |
Undocumented |
Method | input |
Undocumented |
Async Method | insert |
Writes data to a source defined as a output source |
Async Method | insert |
Writes data to a source defined as a output source |
Method | needed |
Undocumented |
Async Method | overwrite |
Overwrites data to a source defined as a output source |
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 output source |
Async Method | upsert |
Upserts data to a source defined as a output source |
Method | using |
Makes it possible to define which model to use for predictions. |
Method | using |
Undocumented |
Method | using |
Undocumented |
Method | with |
Will also load the labels for the model |
Class Variable | model |
Undocumented |
Class Variable | model |
Undocumented |
Class Variable | selected |
Undocumented |
Class Variable | store |
Undocumented |
Property | dataset |
Undocumented |
Property | location |
Undocumented |
Property | source |
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:
- RetrievalJob: _description_
Returns the views and models that the model depend on to compute it's output.
- Examples:
```python @data_contract(name="passenger", ...) class Passenger:
passenger_id = Int32().as_entity()
age = Float()
@data_contract(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") >>> } ```
ConvertableToRetrievalJob | RetrievalJob
, event_timestamp_column: str | None
= None, model_version_as_entity: bool | None
= None) -> RetrievalJob
:
(source)
¶
Returns the features the model has produced.
```python store = await FileSource.json_at("contracts.json").feature_store()
- df = store.model("titanic")
- .features_for({"passenger_id": [1, 2, 3]}).to_polars()
print(df.collect()) >>> ┌──────────────┬──────────────┐ >>> │ passenger_id ┆ will_survive │ >>> │ --- ┆ --- │ >>> │ i32 ┆ bool │ >>> ╞══════════════╪══════════════╡ >>> │ 1 ┆ true │ >>> │ 2 ┆ true │ >>> │ 3 ┆ false │ >>> └──────────────┴──────────────┘ ```
- Args:
- entities (dict[str, list] | RetrievalJob): The entities to fetch features for
- Returns:
- RetrievalJob: A retrieval 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.
ConvertableToRetrievalJob | RetrievalJob
, event_timestamp_column: str | None
= None) -> RetrievalJob
:
(source)
¶
Returns the features to pass into a model
```python store = await FileSource.json_at("contracts.json").feature_store()
- df = store.model("titanic")
- .input_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] | RetrievalJob): The entities to fetch features for
- Returns:
- RetrievalJob: A retrieval job that can be used to fetch the features
set[ str] | None
= None, event_timestamp_column: str | None
= None) -> FeatureRequest
:
(source)
¶
Undocumented
Writes data to a source defined as a output source
```python @model_contract(
name="taxi_eta", features=[...] output_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({
- "trip_id": [1, 2, 3, ...], "duration": [20, 33, 42, ...]
})
ConvertableToRetrievalJob | RetrievalJob
):
(source)
¶
Writes data to a source defined as a output source
```python @model_contract(
name="taxi_eta", features=[...] output_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, ...]
})
Overwrites data to a source defined as a output source
```python @model_contract(
name="taxi_eta", features=[...] output_source=FileSource.parquet_at("predictions.parquet")
) class TaxiEta:
trip_id = Int32().as_entity()
duration = Int32()
...
store = FeatureStore.from_dir(".")
- await store.model("taxi_eta").overwrite({
- "trip_id": [1, 2, 3, ...], "duration": [20, 33, 42, ...]
})
ConvertableToRetrievalJob | RetrievalJob
) -> PredictionJob
:
(source)
¶
Undocumented
set[ str] | None
= None, model_version_as_entity: bool
= False) -> RetrievalRequest
:
(source)
¶
Undocumented
ConvertableToRetrievalJob | RetrievalJob
, event_timestamp_column: str | None
= None, model_version_as_entity: bool | None
= None) -> RetrievalJob
:
(source)
¶
Undocumented
RetrievalJob | ConvertableToRetrievalJob
) -> RetrievalJob
:
(source)
¶
Undocumented
set[ str] | None
= None, event_timestamp_column: str | None
= None) -> FeatureRequest
:
(source)
¶
Undocumented
Upserts data to a source defined as a output source
```python @model_contract(
name="taxi_eta", features=[...] output_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({
- "trip_id": [1, 2, 3, ...], "duration": [20, 33, 42, ...]
})
ConvertableToRetrievalJob | RetrievalJob
):
(source)
¶
Upserts data to a source defined as a output source
```python @model_contract(
name="taxi_eta", features=[...] output_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, ...]
})
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