-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a full ML example and pushing it into the docs
- Loading branch information
1 parent
6863cad
commit 278508a
Showing
2 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""This Script creates a full AWS ML Pipeline with SageWorks | ||
DataSource: | ||
- abalone_data | ||
FeatureSet: | ||
- abalone_features | ||
Model: | ||
- abalone-regression | ||
Endpoint: | ||
- abalone-regression-end | ||
""" | ||
import logging | ||
from sageworks.api.data_source import DataSource | ||
from sageworks.api.feature_set import FeatureSet | ||
from sageworks.api.model import Model, ModelType | ||
from sageworks.api.endpoint import Endpoint | ||
|
||
# Setup the logger | ||
log = logging.getLogger("sageworks") | ||
|
||
if __name__ == "__main__": | ||
|
||
# Create the abalone_data DataSource | ||
ds = DataSource("s3://sageworks-public-data/common/abalone.csv") | ||
|
||
# Now create a FeatureSet | ||
ds.to_features("abalone_features") | ||
|
||
# Create the abalone_regression Model | ||
fs = FeatureSet("abalone_features") | ||
fs.to_model( | ||
ModelType.REGRESSOR, | ||
name="abalone-regression", | ||
target_column="class_number_of_rings", | ||
tags=["abalone", "regression"], | ||
description="Abalone Regression Model", | ||
) | ||
|
||
# Create the abalone_regression Endpoint | ||
model = Model("abalone-regression") | ||
model.to_endpoint(name="abalone-regression-end", tags=["abalone", "regression"]) | ||
|
||
# Now we'll run inference on the endpoint | ||
endpoint = Endpoint("abalone-regression-end") | ||
|
||
# Get a DataFrame of data (not used to train) and run predictions | ||
athena_table = fs.get_training_view_table() | ||
df = fs.query(f"SELECT * FROM {athena_table} where training = 0") | ||
results = endpoint.predict(df) | ||
print(results[["class_number_of_rings", "prediction"]]) | ||
|