Imagine youâre learning to cook a complex dish like beef wellington. You wouldnât want to just be handed a list of ingredients and told âfigure it out.â Instead, youâd want a step-by-step recipe that shows you exactly how to prepare each component, when to combine them, and what the final result should look like.
This is exactly what Notebook-Based Workflows provide for agricultural machine learning. Instead of wrestling with complex algorithms and data processing on your own, you get interactive, guided tutorials that walk you through complete analysis scenarios from start to finish.
Letâs say youâre an agricultural researcher who wants to create a soil carbon map for a farm. Without guided workflows, youâd face these challenges:
Notebook-Based Workflows solve this by providing you with proven ârecipesâ that have been tested and refined by experts.
Think of these workflows as interactive cookbooks where:
Each workflow is contained in a Jupyter notebook - an interactive document that combines explanations, code, and visualizations all in one place.
Every notebook-based workflow in AgReFed-ML has three main ingredients:
These are like individual recipe steps. Each cell contains a small piece of code that does one specific task:
# Load your soil data (like getting ingredients from the pantry)
import pandas as pd
soil_data = pd.read_csv('soil_measurements.csv')
print(f"Loaded {len(soil_data)} soil samples")When you run this cell, it loads your data and tells you how many samples you have.
These are like adjustable recipe cards that let you customize the workflow without changing the code:
# settings_soil_mapping.yaml
input_file: "my_farm_data.csv"
target_property: "organic_carbon"
map_resolution: 100 # meters
uncertainty_method: "gaussian_process"This settings file tells the workflow which data to use and how detailed you want your final maps.
Each notebook includes detailed explanations between code cells, just like a good recipe explains why youâre doing each step.
Letâs walk through creating a soil organic carbon map using the static soil model workflow:
AgReFed-ML provides three main ârecipe categoriesâ:
For our carbon mapping example, weâll use the Static Soil Model.
Open the feature selection notebook:
# This notebook helps you pick the best predictors for your model
# Like choosing which spices will make your dish taste best
from notebooks import feature_importance_staticRun each cell in sequence. The notebook guides you through:
# Step 1: Load and explore your data
soil_data = load_data('my_soil_samples.csv')
# Step 2: Analyze which features are most important
important_features = analyze_feature_importance(soil_data)
# Step 3: Select the best features for modeling
selected_features = select_top_features(important_features, n_features=10)Each step produces output that helps you understand whatâs happening with your data.
Move to the prediction notebook and create your soil maps:
# Train your model using the selected features
model = train_soil_model(soil_data, selected_features)
# Generate prediction maps
carbon_map = predict_soil_property(model, prediction_grid)
# Create uncertainty maps too
uncertainty_map = predict_uncertainty(model, prediction_grid)When you run a notebook-based workflow, hereâs the step-by-step process that occurs:
Letâs break this down:
The notebook workflows are built on top of several core components. Hereâs how they work together:
# Each notebook follows this general pattern:
def run_workflow(settings_file):
# 1. Load configuration
config = load_yaml_settings(settings_file)
# 2. Initialize data pipeline
data_pipeline = DataPreprocessingPipeline(config)
# 3. Set up model based on use case
if config['workflow_type'] == 'static':
model = StaticSoilModel(config)
elif config['workflow_type'] == 'change':
model = ChangeDetectionModel(config)
# 4. Execute workflow steps
results = model.run_complete_workflow()
return resultsThis orchestration ensures that each workflow follows the same reliable pattern while allowing for customization through the settings files.
# Notebooks provide real-time feedback at each step
def display_progress(step_name, data):
print(f"â Completed: {step_name}")
print(f" Data shape: {data.shape}")
print(f" Memory usage: {data.memory_usage().sum() / 1024**2:.1f} MB")
# Show sample of results
display(data.head())This helps you understand whatâs happening at each stage and catch any issues early.
Notebook-Based Workflows make agricultural machine learning accessible because they:
Notebook-Based Workflows transform complex agricultural machine learning tasks into manageable, step-by-step processes. Like following a well-tested recipe, you can create sophisticated soil property maps and uncertainty analyses without needing to be a machine learning expert.
These workflows serve as your foundation for all AgReFed-ML analyses. Once youâre comfortable with the basic flow, you can explore the specific prediction workflows and advanced modeling techniques covered in the following chapters.
Ready to dive deeper into the mechanics? The next chapter covers Prediction Workflows, where weâll explore how the system actually generates those soil property maps and uncertainty estimates.