Home Machine Learning A Knowledge Science Course Challenge About Crop Yield and Worth Prediction I’m Nonetheless Not Ashamed Of | by Mikhail Sarafanov | Dec, 2023

A Knowledge Science Course Challenge About Crop Yield and Worth Prediction I’m Nonetheless Not Ashamed Of | by Mikhail Sarafanov | Dec, 2023

0
A Knowledge Science Course Challenge About Crop Yield and Worth Prediction I’m Nonetheless Not Ashamed Of | by Mikhail Sarafanov | Dec, 2023

[ad_1]

Howdy, pricey reader! Throughout these Christmas holidays, I skilled a sense of nostalgia for the previous pupil years. That’s why I made a decision to put in writing a submit a couple of pupil challenge that was finished nearly 4 years in the past as a challenge on the course “Strategies and fashions for Multivariate knowledge evaluation” throughout my Grasp’s diploma in ITMO College.

Disclaimer: I made a decision to put in writing this submit for 2 causes:

  1. to share an strategy to organizing college research that has confirmed to be very efficient (no less than for me);
  2. to encourage people who find themselves simply beginning to examine programming and/or statistics to attempt to experiment with their pet or course initiatives, as a result of generally such initiatives are memorable for a few years and surprisingly fulfilling

The article mentions, in suggestions format, good practices that I’ve been capable of apply throughout course challenge.

Starting of the story

So, at the start of the course, we had been knowledgeable that college students might type groups of two–3 individuals on our personal and suggest a course challenge that we’d current on the finish of the course. Throughout the studying course of (about 5 months), we are going to make intermediate shows to our lecturers. This fashion, the professors can see how the progress is (or shouldn’t be) occurring.

After that, I instantly teamed up with my dudes: Egor and Camilo (simply because we knew find out how to have enjoyable collectively), and we began occupied with the subject…

Selecting the subject

I urged selecting

  1. a theme that was sufficiently big that we might work independently on totally different elements of it
  2. the area which was near our pursuits (geographic info evaluation for me and economics for my colleagues)

So, it was…

Determine 1. Chosen matter (picture by writer)

Camilo additionally needed to attempt to make dashboards with visualisations (utilizing PowerBI), however just about any process could be appropriate for this want.

Tip 1: Select a subject that you simply (and your colleagues) shall be captivated with. It might not be the best challenge on a subject that’s not very fashionable, however you’ll get pleasure from spending your “evenings” engaged on it

What was the principle concept

The course consisted of a giant variety of matters every of which is a set of strategies for statistical evaluation. We determined that we’d attempt to forecast yield and crop value in as many various methods as attainable after which ensemble the forecasts utilizing some statistical methodology. This allowed us to strive many of the strategies mentioned within the course in apply.

Additionally, the spatio-temporal knowledge was really multidimensional — this associated fairly nicely to the principle theme of the course.

Spoiler: all of us obtained a rating 5 out of 5

Analysis (& knowledge sources)

We began with a literature evaluate to know precisely how crop yield and crop value are predicted. We additionally needed to know what sort of forecast error might be thought of passable.

I cannot cite on this submit the thesis ensuing from this evaluate. I’ll merely point out that we determined to make use of the next metric and threshold to judge the standard of the answer (for each crop yield and crop value):

Acceptable efficiency: Imply absolute share error (MAPE) for a fairly good forecast shouldn’t exceed 10%

2 tip: Begin your challenge (regardless of at work or throughout your research) with a evaluate of up to date options. Perhaps the issue you’re looking at now has already been solved.

3 tip: Earlier than beginning a improvement, decide what metric you’ll use to judge the answer. Keep in mind, you’ll be able to’t enhance what you’ll be able to’t measure.

Going again to the analysis, now we have recognized the next knowledge sources (Hyperlinks are updated at twenty eighth of December 2023):

Why these sources? — We’ve assumed that the value of a crop will depend upon the quantity of product produced. And in agriculture, the amount produced is dependent upon climate circumstances.

The mannequin was carried out for:

  • Yield of wheat, rice, maize, and barley;
  • International locations: Germany, France, Italy, Romania, Poland, Austria, the Netherlands, Switzerland, Spain and the Czech Republic.

Local weather knowledge preprocessing

So, now we have began with an assumption: “Wheat, rice, maize, and barley yields depend upon climate circumstances within the first half of the 12 months (till 30 June)” (Determine 2)

Determine 2. Technology of traits for yield prediction (utilizing the sum of energetic temperatures for instance) (picture by writer)

The supply archives obtained from the European house Company web site comprise netCDF information. The information have every day fields for the next parameters:

  • Imply every day air temperature, ℃
  • Minimal every day air temperature, ℃
  • Most every day air temperature, ℃
  • Strain, HPa
  • Precipitation, mm

Based mostly on the preliminary fields, the next parameters for the primary half of every 12 months had been calculated:

  • Whole rainfall for the primary half of the 12 months, mm (see Animation);
  • The variety of days with precipitation for the primary half of the 12 months, days;
  • Common stress, hpa;
  • Most common every day air temperature for the primary six months, ℃;
  • Minimal common every day temperature for the primary six months, ℃;
  • The sum of energetic temperatures above 10 levels Celsius, ℃ (see Determine 3).
Rainfall for the first half of the year, mm
Animation. Rainfall for the primary half of the 12 months, mm. The 12 months is listed on the high of the chart (by writer)
Determine 3. Sum of energetic temperatures for the primary half of the 12 months 1950, °C (picture by writer)

Thus we obtained matrices for the entire territory of Europe with calculated options for the longer term mannequin(s). The reader could discover that I calculate such a parameter as “The sum of energetic temperatures above 10 levels Celsius”. That is such a preferred parameter in ecology and botany that helps to find out the temperature optimums for various species of organisms (primarily vegetation, for instance “The sum of energetic temperatures as a way of figuring out the optimum harvest date of ‘S̆ampion’ and ‘Ligol’ apple cultivars”)

4 tip: You probably have experience within the area (which isn’t associated to Knowledge Science), be sure you use it within the challenge — present that you’re not solely making a “fit-predict” but in addition adapting and bettering domain-specific approaches

The following step is Aggregation of data by nation. For values from the meteorological parameter matrices had been extracted for every nation individually (Determine 4).

Determine 4. Matrix with the boundaries of nations (picture by writer)

I might be aware that this technique made sense (Determine 5): For instance, the image exhibits that for Spain, wheat yields are nearly unaffected by the sum of energetic temperatures. Nonetheless, for the Czech Republic, a warmer first half of the 12 months is extra prone to end in decrease yields. It’s subsequently a good suggestion to mannequin yields individually for every nation.

Determine 5. Dependence of wheat yield (tonnes per hectare) on the sum of energetic temperatures (picture by writer)

Not the entire nation’s territory is appropriate for agriculture. Subsequently, it was essential to mixture info solely from sure pixels. With a purpose to account for the situation of agricultural land, the next matrix was ready (Determine 6).

Determine 6. Land use matrix (picture by writer)

1. The subject of the lecture is: univariate statistical testing

So, we’ve obtained the info prepared. Nonetheless, agriculture is a really advanced trade that has improved markedly 12 months by 12 months, decade by decade. It could make sense to restrict the coaching pattern for the mannequin. For this function, we used the cumulative sum methodology (Determine 7):

Cumulative sum methodology:
To every quantity from the pattern, successive numbers are added sequentially to the next. That’s, if the pattern contains solely three years: 1950, 1951, and 1952, the quantity for 1950 shall be plotted on the Y-axis for 1950, and 1951 will present the sum of 1950 and 1951, and many others.

– If the form of the road is near a straight line and there aren’t any fractures, the pattern is homogeneous

– If the form of the road has fractures the pattern is split into 2 elements primarily based on this fracture

Determine 7. France. Comparability of goal variable throughout years: Wheat (tonnes per hectare) (picture by writer)

If a fracture was detected, we in contrast the 2 samples for belonging to the final inhabitants (Kolmogorov-Smirnov statistic). If the samples had been statistically considerably totally different, we used the second half to coach the mannequin for prediction. If not, we used your complete pattern.

5 tip: Don’t be afraid to mix approaches to statistical evaluation (it’s a course challenge!). For instance, within the lecture we weren’t informed in regards to the cumulative sums methodology — the subject was about evaluating distributions. Nonetheless, I’ve beforehand used this strategy to check developments in ice circumstances through the processing of ice maps. It appeared to me that it might be helpful right here as nicely

I ought to be aware right here that now we have assumed that the method is ergodic, so we determined to check on this approach.

So, after the preparation, we’re prepared to start out constructing statistical fashions — let’s check out essentially the most fascinating half!

2. The subject of the lecture is: multivariate regression

The next options was included within the mannequin:

  • Whole rainfall;
  • The variety of days with precipitation;
  • The sum of energetic temperatures above 10 ℃;
  • Imply stress;
  • Minimal air temperature ℃.

Goal variables: Yield of wheat, rice, maize, and barley

Validation years: 2008–2018 for every nation

Let’s transfer on to the visualisations to make it slightly clearer.

Determine 8. Generated surfaces with predictions for every nation for a particular 12 months primarily based on initialized fashions (picture by writer)

And right here is Determine 9 exhibiting the residuals (residual = noticed worth -estimated (predicted) worth) from the linear mannequin for France and Italy:

Determine 9. Visualisation of residuals and metrics for linear regression on the validation pattern (picture by writer)

It may be seen from the graphs that the metric is passable, however the error distribution is biased from zero — which means the mannequin has systematic error. We tried to right within the new fashions under

Validation pattern MAPE metric worth: 10.42%

6 tip: Begin with the only fashions (e.g. linear regression). This provides you with a baseline towards which you’ll evaluate improved variations of the mannequin. The less complicated the mannequin, the higher it’s, so long as it exhibits a passable metric

3. The subject of the lecture is: multivariate distributions evaluation

We’ve turned the fabric from this lecture right into a mannequin “Distribution evaluation”. The idea was easy — we analysed the distributions of climatic parameters for annually and for the present 12 months and located an analogue 12 months of the present one to foretell the worth of yield precisely the identical as that of the recognized previously (Determine 10).

Determine 10. The idea of pairwise comparability for the aim of choosing a year-analogue (picture by writer)

Thought: Yields for years with comparable climate circumstances shall be comparable

The strategy: Pairwise comparability of temperature, precipitation, and stress distributions. Prediction-yield for the 12 months that’s most much like the thought of one

Distributions used:

  • Temperature for the primary half of the 12 months, temperature for the months: February, April, June;
  • Precipitation for the primary half of the 12 months, precipitation for the months: February, April, June;
  • Strain for the primary half of the 12 months, stress for the months: February, April, June.

For comparability of distributions we used Kruskal-Wallis check. To regulate p-value, a a number of testing correction is launched — the Bonferroni correction.

Determine 11. Obtained distributions for 2000 and 2018 years for air temperature (picture by writer)

Validation pattern MAPE metric worth: 13.80%

7 tip: In case you are doing a number of statistical testing, don’t overlook to incorporate the correction (for instance, Bonferroni correction)

4. The subject of the lecture is: Bayesian community

One of many lectures was targeted on the Bayesian networks. Subsequently, we determined to adapt the strategy for yield prediction. We thought of that every 12 months is described by a set of group of variables A, B, C and many others. the place A is a set of classes describing crop yields, B is, for instance, the Sum of energetic temperatures circumstances and so forth. A, for instance, might take solely three values: “Excessive crop yield”, “Medium crop yield”, “Low crop yield”. The identical for B and C and others. Thus, if we categorise the circumstances and the goal variable, we receive the next description of every 12 months:

  • 1950 — “Excessive warmth provide”, “Low rainfall provide”, “Excessive atmospheric stress”— “Excessive crop yield”
  • 1951 — “Low warmth provide”, “Excessive rainfall provide”, “Excessive atmospheric stress” — “Medium crop yield”
  • 1952 — “Low warmth provide”, “Low rainfall provide”, “Excessive atmospheric stress” — Which crop yeild?

The algorithm was designed to foretell a yield class primarily based on a mix of three different classes:

  • Crop yield (3 classes) — hidden state — goal variable
  • Sum of energetic temperatures (3 classes)
  • Rainfall (3 classes)
  • Imply stress (3 classes)

How can we outline these classes? — through the use of a clustering algorithm! For instance, the next 3 clusters had been recognized for wheat yields

Determine 12. Wheat yield clusters for Bayesian community analisys (picture by writer)

The ultimate forecast of this mannequin — the typical yield of the anticipated cluster.

Validation pattern MAPE metric worth: 14.55%

8 tip: Do experiment! Bayesian networks with clustering for time collection forecasting? — Positive! Pairwise evaluation of distributions — Why not? Typically the boldest approaches result in vital enhancements

5. The subject of the lecture is: Time collection forecasting

In fact, we will forecast the goal variable as a time collection. Our process right here was to know how classical forecasting strategies work in principle and apply.

Placing this methodology into apply proved to be the simplest. For instance, in Python there are a number of libraries that enable to customize and apply the ARIMA mannequin, for instance pmdarima.

Determine 13. Utility of ARIMA mannequin to foretell yield time collection. X-axis: time index, Y-axis: Barley yield (picture by writer)

Validation pattern MAPE metric worth: 10.41%

9 tip: Don’t overlook the comparability with classical approaches. An summary metric won’t inform your colleague a lot about how good your mannequin is, however a comparability with well-known requirements will present the true stage of efficiency

6. The subject of the lecture is: Ensembling

After all of the fashions had been constructed, we explored precisely how every mannequin is “mistaken” (bear in mind residual plots for linear regression mannequin — see Determine 9):

Determine 14. Residuals plot for various crop yield forecasting fashions (picture by writer)

Not one of the introduced algorithms allowed to beat the ten% threshold (in line with MAPE).

The Kalman filter was used to enhance the standard of the forecast (to ensemble it). Passable outcomes have been achieved for some international locations (Determine 15)

Determine 15. Crop yield predictions for various international locations utilizing ensemble (picture by writer)

Validation pattern MAPE metric worth: 9.89%

10 tip: If I had been requested to combine the developed mannequin into Manufacturing service, I might combine both ARIMA or linear regression, though the ensemble metric is healthier. Nonetheless, metrics in enterprise issues are generally not the important thing. A standalone mannequin is typically higher than an ensemble as a result of it’s less complicated and extra dependable (even when the error metric is barely larger)

Futures value prediction

And the ultimate half: mannequin (lasso regression), which used predicted yield values and Futures options to estimate attainable value values (Determine 16):

Determine 16. Wheat Futures costs prediction (picture by writer)

Mape on validation pattern: 6.61%

Why I nonetheless assume this challenge is an efficient one

In order that’s the top of the story. Above there have been posted a few of suggestions. And within the final paragraph, I need to summarise the ultimate level and say why I’m happy with that challenge. Listed here are three important objects:

  • Organisation of labor and selection of matter — we mixed our strengths and greatest qualities very nicely, deliberate the work stack properly and managed as a workforce to arrange an excellent challenge and ship it on time. So, I’ve improved my gentle expertise;
  • Significant theme — I used to be captivated with what we had been doing. Even when I had a number of weeks free now for a pet challenge, I might fortunately apply my present expertise and expertise to such a case examine once more. So, I used to be happy with the work we had finished;
  • Laborious expertise — Throughout our work we have tried new statistical strategies, improved our understanding of already acquainted ones, and enhanced our programming expertise.

Properly, we additionally obtained nice marks on the examination XD

I hope your initiatives at college and elsewhere shall be as thrilling for you. Glad New Yr!

Sincerely yours, Mikhail Sarafanov

[ad_2]