Skip to content

Commit

Permalink
Update 2 tutorial files
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Aug 24, 2024
1 parent 09778c2 commit b25a492
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 411 deletions.
36 changes: 36 additions & 0 deletions docs/book/user-guide/starter-guide-2/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,39 @@ if __name__ == "__main__":
Copy this code into a new file and name it `run.py`. Then run it with your command line:


```python
from zenml import pipeline, step

@step
def load_data() -> dict:
"""Simulates loading of training data and labels."""

training_data = [[1, 2], [3, 4], [5, 6]]
labels = [0, 1, 0]

return {'features': training_data, 'labels': labels}

@step
def train_model(data: dict) -> None:
"""
A mock 'training' process that also demonstrates using the input data.
In a real-world scenario, this would be replaced with actual model fitting logic.
"""
total_features = sum(map(sum, data['features']))
total_labels = sum(data['labels'])

print(f"Trained model using {len(data['features'])} data points. "
f"Feature sum is {total_features}, label sum is {total_labels}")

@pipeline
def simple_ml_pipeline():
"""Define a pipeline that connects the steps."""
dataset = load_data()
train_model(dataset)

if __name__ == "__main__":
run = simple_ml_pipeline()
# You can now use the `run` object to see steps, outputs, etc.
```


Loading

0 comments on commit b25a492

Please sign in to comment.