Imagine that in mid-June - two months before the wheat harvest - you know exactly how many tonnes you will harvest from each hectare. Not guessing, not relying on intuition or experience from previous years. We are talking about concrete forecasts with 85-92% accuracy, generated by machine learning algorithms.
This is not science fiction - it is a reality available to Polish farmers today. Machine learning (ML) is revolutionising yield forecasting, turning mountains of data into concrete, valuable predictions. In this article we explain how it works, what data is needed and how much you can save by deploying these technologies on your farm.
What is machine learning in the context of agriculture?
Machine learning is a branch of artificial intelligence that lets computers learn from data without every rule being explicitly programmed. Instead of telling the computer "if the temperature exceeds 30°C, yield falls by 5%", we show it thousands of examples from the past and let it detect the patterns itself.
How does it work in practice?
Imagine you have data from the last 15 years for 100 fields. For every field and every year you have:
- Weather data (temperature, rainfall, sunshine)
- Soil parameters (pH, NPK content, structure)
- Crop information (variety, sowing date, fertilisation)
- Treatment history (protection, growth regulation)
- The actual yield achieved after harvest
The ML algorithm analyses this data and detects relationships: "When the temperature at the heading stage exceeds 28°C for more than 5 days and rainfall in May is below 30 mm, yield falls by 12% on average." There can be hundreds of such relationships, and some are so subtle that a person would never notice them.
Types of ML models used in agriculture
1. Linear and polynomial regression - the simplest models, good as a starting point. Accuracy: 70-75%.
2. Random Forest - one of the most popular. It creates hundreds of "decision trees" and averages their predictions. Accuracy: 82-88%.
3. Gradient Boosting (XGBoost, LightGBM) - an advanced technique of iterative learning. Currently the most effective for yield forecasts. Accuracy: 85-92%.
4. Deep neural networks (deep learning) - powerful, but they need huge amounts of data. Used mainly for analysing satellite and drone images. Accuracy: 88-95% (with large datasets).
5. Hybrid models - combine different approaches. For example a neural network analyses satellite images, and XGBoost integrates those results with weather and soil data.
Input data - the foundation of accurate forecasts
A saying in machine learning goes: "Garbage in, garbage out". The quality of the forecast depends directly on the quality and completeness of the input data.
1. Weather data - the most critical
Weather has a direct effect on plant development and final yield. ML analyses:
Historical data (growing season):
- Air temperature (daily mean, maximum, minimum)
- Total rainfall (daily, ten-day, monthly)
- Sunshine (sunshine hours, radiation)
- Air humidity
- Wind speed
- Sum of active temperatures (∑t > 10°C)
Short-term forecasts (2-4 weeks):
- The same parameters, but predicted for the coming weeks
- Used by advanced models to update forecasts during the season
Data sources in Poland: the Institute of Meteorology and Water Management (IMGW), the Open-Meteo API, local agrometeorological stations, weather satellites.
2. Soil parameters
Soil is a "store" of nutrients and water. ML takes into account:
- Soil type: light, medium, heavy (affects water retention)
- Soil pH: acidity affects nutrient availability
- Macronutrient content: N, P, K, Mg, Ca
- Organic matter: humus content
- Structure and texture: percentage of sand, loam, clay
- Retention capacity: how much water the soil can hold
- Salinity and heavy metal content: potential toxicity
Sources: soil maps, laboratory analyses, databases of the Institute of Soil Science and Plant Cultivation (IUNG).
3. Crop data
Agronomic practices have an enormous effect on yield:
- Crop and variety: winter wheat variety X vs Y (yield differences of 10-15%)
- Sowing date and density: number of seeds/m², sowing date
- Previous crop: what grew in the field the year before
- Fertilisation: NPK rates, application dates, form of fertiliser
- Plant protection: fungicides, herbicides, insecticides, number of treatments
- Irrigation: whether used, how much water
- Tillage: ploughing, reduced, no-till
4. Satellite and image data
Modern ML models increasingly use images from satellites and drones:
Vegetation indices (calculated from multispectral images):
- NDVI (Normalized Difference Vegetation Index): an indicator of vegetation density and condition. Values of 0.2-0.4 = low vegetation, 0.6-0.9 = lush vegetation.
- NDRE (Normalized Difference Red Edge): more precise for advanced growth stages.
- EVI (Enhanced Vegetation Index): corrected for the influence of atmosphere and soil.
- LAI (Leaf Area Index): leaf area per unit of ground area.
Image sources: Sentinel-2 (European Space Agency, free, 10 m resolution, refreshed every 5 days), Landsat (NASA, free, 30 m), drones (centimetre resolution, but costly).
5. Historical yield data
Without history there is no machine learning. The model needs "answers" - actual yields from the past - to learn to predict the future.
What is needed:
- At least 5 years of data (the more the better)
- Yields at field level (not an average for the whole farm)
- Main yield plus quality traits (protein, gluten content for cereals)
Where to get historical data: your own records, data from the agricultural agency ARiMR (area declarations), data from buying stations, cooperation with other farms in the region.
How does the forecasting process work?
We have covered the input data. Now let us see step by step how an ML algorithm generates a yield forecast.
Step 1: Data preparation (data preprocessing)
Raw data is untidy and incomplete. The algorithm needs it "cleaned":
- Filling gaps: If rainfall data is missing for 3 days in June 2018, it can be interpolated from neighbouring days or stations.
- Normalisation: Temperature ranges from -10°C to +35°C and rainfall from 0-150 mm. They have to be brought to a common scale (for example 0-1).
- Encoding categories: "Light soil" is converted to a number (for example 1), "medium" to 2, "heavy" to 3.
- Time aggregation: Instead of 150 temperature measurements a day, the daily mean, maximum and minimum are calculated.
Step 2: Feature engineering
This is where the magic happens. The algorithm does not just use raw data but creates "derived features" from it that better describe the relationships:
Examples of derived features:
- Sum of active temperatures: ∑(temperature - 10°C) for days when T > 10°C. An indicator of heat accumulation.
- Drought index: the number of consecutive days without rainfall above 1 mm.
- Rainfall-to-evaporation ratio: whether plants have enough water.
- GDD (Growing Degree Days): a measure of the heat available for growth across the whole season.
- Critical-stage indicators: temperature at heading, rainfall at grain filling.
- NDVI trend: whether NDVI is rising (plants developing) or falling (stress).
A person might come up with 10-20 such features. An ML algorithm can generate hundreds of them and select the most predictive.
Step 3: Model training
Now the algorithm "learns" from historical data:
- Splitting the data: 70% of the data is the "training set" (the model learns on it), 30% is the "test set" (we check how well the model works on it).
- Iterative learning: The model tries to predict yields from historical years, compares them with known results, adjusts its internal parameters (weights) and tries again.
- Hyperparameter optimisation: Choosing the optimal model settings (for example tree depth in Random Forest, learning rate in XGBoost).
- Cross-validation: The model is trained and tested many times on different splits of the data to make sure it has not "overlearned" (overfitting).
Training time: from a few minutes (simple models, small datasets) to a few hours (neural networks, millions of records).
Step 4: Validation and assessment
How do we judge whether the model is good?
Accuracy metrics:
- RMSE (Root Mean Squared Error): the average forecast error in tonnes/ha. RMSE = 0.5 t/ha means the model is off by ±0.5 tonnes on average.
- MAE (Mean Absolute Error): the average absolute error. Easier to interpret than RMSE.
- R² (coefficient of determination): how much of the variability in yields the model explains. R² = 0.85 means 85% of the variability is explained by the model.
- MAPE (Mean Absolute Percentage Error): the error as a percentage. MAPE = 8% means the average error is 8% of the actual yield.
Example: A model forecasts winter wheat yield. Actual yields: 6.2, 5.8, 7.1, 6.5 t/ha. Forecasts: 6.0, 5.9, 6.9, 6.6 t/ha. RMSE = 0.22 t/ha, R² = 0.91, MAPE = 3.5%. A very good result!
Step 5: Generating the forecast for the current season
The model is trained and validated. Now we use it to predict yields in the current season:
- We collect current data: weather to date, the latest NDVI satellite reading, soil parameters and treatments.
- We add forecasts: If it is mid-June and harvest is planned for August, we use weather forecasts for June-August.
- The model generates a forecast: "Predicted yield for field A: 6.8 t/ha ± 0.4 t/ha (90% confidence interval)."
- Updating during the season: Every week, as new data arrive (NDVI measurements, current rainfall), the forecast is recalculated. Accuracy usually rises as harvest time approaches.
Real examples of use in Poland
Theory is one thing, practice another. Let us see how ML yield forecasting works in Polish conditions.
Example 1: A grain farm (500 ha, Kujawy)
Problem: The farmer wanted to plan grain sales better. Until then he estimated yields "by eye" and often signed forward contracts that later proved unprofitable (the actual yield was lower than assumed).
Solution: Deployment of an ML system based on XGBoost. Input data: 10 years of yield history, weather data from 3 IMGW stations, NDVI maps from Sentinel-2, soil analysis results.
Results:
- Forecast accuracy: RMSE = 0.35 t/ha (at an average yield of 6.5 t/ha = an error of ~5.4%)
- Forecast available as early as mid-June (6 weeks before harvest)
- Savings: Better decisions on forward contracts brought an extra 50 PLN/t (at 3,000 t = +150,000 PLN a year)
- Additional benefit: Optimised harvest logistics (they know exactly how many grain bags to prepare and when to order transport)
Example 2: A mixed farm (200 ha, Pomerania)
Problem: Variability of yields between fields (the same species and variety, different yields). The farmer did not know whether the cause was differences in soil, fertilisation or other factors.
Solution: A Random Forest model with feature importance analysis. The system showed which factors have the biggest effect on yields on this particular farm.
Results:
- Identification of key factors: soil pH (30% of influence), rainfall in May (25%), phosphorus content (18%)
- Recommendation: liming fields with pH < 6.0, extra phosphorus fertilisation on 3 deficient fields
- After implementing the recommendations: average yield up 0.6 t/ha (+9%)
- ROI (return on investment): 420% in the first year
Example 3: A cooperative of 15 farms (2,000 ha in total, Greater Poland)
Problem: The cooperative wanted to plan purchases of production inputs (fertilisers, plant protection products) for its members better. Earlier estimates based on multi-year averages were inaccurate.
Solution: A central ML model aggregating data from all 15 farms. Joint purchase of premium satellite data (3 m resolution), shared software costs.
Results:
- Forecast accuracy at cooperative level: MAPE = 4.2%
- Better purchase planning: they saved 180,000 PLN a year in wholesale negotiations (they knew exactly how much fertiliser they needed)
- Higher yields: +0.4 t/ha on average thanks to more precise fertilisation based on the forecasts
- System cost: 25,000 PLN/year (1,667 PLN per farm) - paid back in 2 months
Economic benefits - concrete numbers
How much can you save or earn thanks to accurate yield forecasts?
1. A better sales strategy
Scenario: In June you know you will harvest 300 tonnes of wheat (ML forecast). The June wheat price is 950 PLN/t. You know it is a good price and sign a forward contract.
Alternative without a forecast: You estimate 250 tonnes "by eye" and sign a contract for that amount. After harvest it turns out you have 300 tonnes. You sell the extra 50 tonnes in September at 850 PLN/t (prices fell after harvest).
Difference: 50 tonnes × (950 - 850) PLN = 5,000 PLN of loss. With an ML forecast: you avoided it.
2. Optimising fertilisation
Scenario: The forecast shows that on field A (light soil, low rainfall forecast) even with high nitrogen fertilisation yield will be limited by water. You cut the nitrogen rate from 140 to 100 kg N/ha.
Saving: 40 kg N/ha × 4 PLN/kg = 160 PLN/ha. For a 200 ha farm = 32,000 PLN. Yield drops only marginally (because it was limited by water anyway).
3. Investment planning
Scenario: ML forecasts show that on 30% of the farm's fields yields are systematically 15-20% lower because of low pH. You invest in liming these fields (cost: 800 PLN/ha).
Return: A yield increase of 0.8 t/ha × 1,000 PLN/t = 800 PLN/ha already in the first year. In later years (lime works for 4-5 years) it is pure benefit.
4. Risk reduction
Scenario: In July the forecast shows that drought will cut maize yield by 30%. You sell livestock early (because your own feed will run short) instead of buying expensive feed in winter.
Saving: Avoiding the purchase of 50 tonnes of maize at 1,100 PLN/t in winter = 55,000 PLN.
Financial summary
For a 300 ha grain farm, typical annual benefits from deploying ML in yield forecasting:
- A better sales strategy: +30,000 PLN
- Fertilisation optimisation: +15,000 PLN
- Targeted investments: +20,000 PLN (amortised)
- Logistics and planning: +10,000 PLN
- Total: +75,000 PLN/year
Cost of the ML system:
- Software subscription: 5,000 - 15,000 PLN/year (depends on the vendor)
- Satellite data: 0 PLN (Sentinel-2 is free) or 3,000-8,000 PLN (premium high resolution)
- Training and deployment: 5,000 PLN (one-off)
- Annual cost: 8,000 - 23,000 PLN
ROI (return on investment): 300% - 900% in the first year. Higher still from the second year (no deployment costs).
Challenges and limitations
Machine learning in yield forecasting is not a magic solution. It has its limitations and challenges.
1. The need for historical data
An ML model needs data from the past in order to learn. The minimum is 5 years, but the more the better. If you have completely changed your cultivation system (moving from ploughing to no-till) or varieties, historical data may be less valuable.
Solution: Cooperation with neighbouring farms (data pooling) or use of regional databases.
2. Extreme events
If the historical data never included an extreme drought (like 2018) or a flood, the model may not predict such scenarios well.
Solution: Ensemble models (combining many approaches), Monte Carlo simulations (testing thousands of scenarios), including data from wider regions.
3. Climate variability
The climate is changing. Relationships detected by ML in data from 2005-2020 may not hold in 2025 and later.
Solution: Regular retraining of models (once a year), longer time windows of data (20 years instead of 10), taking climate trends into account.
4. Cost and availability
Professional ML systems can be expensive (10,000 - 50,000 PLN/year for a 500 ha farm). Not every farmer has the budget or technical knowledge.
Solution: More and more free and low-cost solutions are available, such as the free tools described below.
The future of yield forecasting
Current ML models are already very good, but the technology keeps developing. What will the near future bring?
1. High-resolution forecasts
Today we forecast the average yield for a whole field (for example 10 ha). The future: yield variability maps at 10 m × 10 m resolution. You will know that the northern part of the field will give 7.2 t/ha and the southern 6.1 t/ha - and why.
2. Real-time updates
Drones and in-field sensors will collect data daily. The ML model will update forecasts in real time. In the morning you get an alert: "Forecast for field 5 updated: yield reduced by 0.3 t/ha because of yesterday's heat stress."
3. Integration with machinery
The combine harvester collects data on actual yield during harvest (yield maps). This data goes automatically to the ML model, which immediately "learns" more and will be even more accurate next year.
4. Quality forecasting
Yield is one thing, quality another. Future models will predict not only how many tonnes you will harvest but also what protein content the wheat grain will have (which affects the price!) or the sugar content of beets.
5. Personalised recommendations
The model will not only forecast but also recommend: "If you increase nitrogen fertilisation by 20 kg N/ha on field 7, yield will rise by 0.4 t/ha (ROI: 280%). If you increase it on field 3, yield will rise by only 0.1 t/ha (ROI: 45%). Recommendation: fertilise field 7, not field 3."
How to start using ML on your farm?
You are convinced that ML in yield forecasting is not futuristic but brings real benefits. How do you start?
Step 1: Collect historical data
Start by taking stock of what you have:
- Yield records from the last 5-10 years (at field level)
- Information on treatments (fertilisation, varieties, sowing dates)
- Soil analysis results
If you have no data of your own, consider cooperating with neighbours or joining a cooperative.
Step 2: Try free tools
Before you invest in a commercial system, test free solutions:
- Sentinel Hub EO Browser: browse free satellite images of your fields and watch NDVI
- Google Earth Engine: a platform for analysing satellite data (requires programming skills)
Step 3: Consider commercial solutions
If the free tools gave positive results, the next step is a professional system:
Providers of ML systems for agriculture in Poland (selected):
- FarmFacts - an agronomy platform with yield forecasts (subscription from 8,000 PLN/year)
- Agremo - analysis of drone and satellite images (from 5,000 PLN/year)
- ClimateFieldView - Bayer's system for precision agriculture (prices depend on area)
- SatAgro - a Polish system using Sentinel-2 (from 3,000 PLN/year for 200 ha)
Questions to ask the vendor before buying:
- What is the forecast accuracy (RMSE, MAPE) for the crops you grow?
- Do they have references from farms in your region?
- What input data is required?
- Does the system integrate with software you already use (for example the farm's accounting program)?
- What technical support do they offer (training, hotline)?
Step 4: Start small
You do not have to deploy the system on the whole farm at once. Start with a test field or crop:
- Choose 1-2 fields (different soil types)
- Collect accurate data for 1 season
- Compare the ML forecasts with the actual yield
- If the results are good, scale up to the whole farm
Step 5: Continuous improvement
Machine learning is an ongoing process. The more data you collect, the better the forecasts:
- Add new data to the system every year
- Retrain the model on fresh data
- Experiment with different practices and watch how the model reacts
- Share experiences with other farmers
What this means in practice
Machine learning in yield forecasting is one of the most practical and profitable applications of artificial intelligence in agriculture. Algorithms analyse hundreds of variables - from weather and soil to agronomic practices - and predict yields with 85-92% accuracy, often months before harvest.
Key takeaways from the article:
- How it works: ML detects patterns in historical data and uses them to predict the future
- Input data: weather, soil, cultivation practices, satellite images, yield history
- Models: XGBoost and Random Forest are currently the most effective approaches
- Accuracy: MAPE 4-8% for well-trained models
- Benefits: better sales, optimised fertilisation, reduced risk - ROI 300-900%
- Costs: from free solutions (Sentinel-2, AI assistants) to commercial systems (5,000 - 20,000 PLN/year)
- Challenges: the need for historical data, extreme events, climate variability
Yield forecasting with ML is no longer the future - it is the present, available to Polish farmers. Whether you run a small 50 ha farm or a large 1,000 ha enterprise, you can use this technology and improve your farm's results.
The future of farming is data-driven - and machine learning is the key to using it.
Want to see how these solutions would work in your business or on your farm? Write to us via the contact form and we will discuss where to start.
Frequently asked questions
What is machine learning in the context of agriculture?
Machine learning is a branch of artificial intelligence that lets computers learn from data without every rule being explicitly programmed. Instead of telling the computer "if the temperature exceeds 30°C, yield falls by 5%", we show it thousands of examples from the past and let it detect the patterns itself.
How does the forecasting process work?
The algorithm prepares and cleans the data, engineers derived features such as growing degree days and drought indices, trains on historical yields (typically a 70/30 train-test split with cross-validation), is validated with metrics such as RMSE, MAPE and R², and then generates a forecast for the current season, updated every week as new weather and satellite data arrive.
How do I start using machine learning on my farm?
Start by collecting historical data: field-level yields from the last 5-10 years, treatment records and soil analyses. Try free tools such as Sentinel Hub EO Browser first, then consider a commercial system, asking vendors about accuracy for your crops. Begin on one or two test fields, compare the forecasts with actual yield after a season, and scale up if the results are good.