Use of Machine Learning in Dairy farming

Anandk1 01 Dec, 2020 • 7 min read

This article was published as a part of the Data Science Blogathon.

Introduction:

These days if we read anything, we can see something is written on Machine Learning or Artificial Intelligence, how these are revolutionizing the industries or making our lives easier. We can see it being used everywhere, starting from the facial and fingerprint recognition in our phones to autonomous driving vehicles. Being a Data Science and Machine Learning enthusiast, I was pondering on where I can use these Machine Learning algorithms to make better decisions and make life a little easier.

Being from a dairy farming background my first thought went there if we could see that these days we can see how machine learning is helping in enhancing the produces from identifying weeds, pests, and machine-regulated drip irrigation and the list goes on. And coming to my interest I always wanted to do dairy farming and hopefully seeing myself to do it in the future, How can we use machine learning to help one in Dairy farming.

Here I came across many problems that I could solve using the simplest machine learning algorithms. (the simpler it seems the more complex it is)

And I will be explaining how I would use some of the algorithms I came across during my pursuit to study machine learning, and how these algorithms work.

So, the first thing whatever be the algorithms what it tries to do is to look for patterns or associations inside the data. And to do all this we need data. So how do I get the data? What to do to collect the data? It all depends on the problem one wants to solve. Here I would be discussing the data being for each of the algorithms and how I obtained it (still in progress)

Now addressing the major problems, as the main purpose of a dairy farm is to produce milk.

How to identify the major parameters that are affecting milk production? What algorithm can be used here?

 

Where to use On the farm?

Regression:

Like any other algorithm to find the relation between variables we need data, after a lot of calls with the Vet the major variables identified for the milk production in my locality are:

Amount of green grass-fed, Amount of hay fed, Amount of water, Amount of enriched food staples fed, the temperature of that day, Months since last birth, Age, Breed, and so on.

On obtaining the data we can use Multiple Linear regression to identify the major variables or regress on the amount of milk produced. So now the algorithm studies the data to identify the best variables that are affecting the amount of milk produced.

The regression line would like:

Y = b0+b1X1 +b2X2 +………bnXn

Here Y = Amount of milk produced

X1, X2.. = Variables that we provided in the data (Amount of foods, age, temperature, etc.)

b0, b1… = Coefficients obtained on regression

Now with the obtained regression like many inferences can be made and to put into use for the improvement in milk production.

In general, we can identify which variable is contributing the most to the amount of milk produced by the coefficient obtained using the regression model. With this, we can predict the amount of milk that we are expecting the next day, also identify which are the main variables that are contributing to the milk production.

And further on if we can see that the amount of milk produced is less than the predicted amount, it can be identified that the cow is sick or is in distress, a Vet can be contacted immediately for taking care of it.

 

Classification:

In India alone we can find around 37 varieties of cow, Identifying the right breed of the cow is a major factor as it caters to the functioning of the dairy farms, the type of the milk changes with cows some of which give rich in fat and some with medicinal benefits and so on.

Identifying the breed of the cow, always needed an expert in the field to identify the right breed. So is there a way by which we can identify the cow, without any help from an expert? Here we can use a classification algorithm like a decision tree to identify the breed of the cow using the data given.

Identifying the variables that can be used here are Height, Height to the hump, Weight, Type of horns, Color, head shape, ear type, and nostril pattern.

On modeling the data, we can expect a certain accuracy level to which we can correctly predict the breed of the cow. We can tune the model by changing the hyperparameters or use advanced machine learning algorithms like Random forest and Gradient boost (mentioned earlier that we would be using simple algorithms) to enhance our accuracy.

classification Decision Surface

The major advantage here is that next time when we can identify the breed of the cows just using it features just like an expert would do.

Again, measuring all the variables, measured for gathering the data can be used to identify the healthiness of the cattle adding the variables from the regression data.

The identification can also be done by building an image recognition model to identify the breed of the cattle, as we have a lot of algorithms available we can go with the one which is predicting the most correctly, this would be huge work to identify and feeding the photos of the different cattle breed spread across India and some are indigenous to a certain part, this can also be used to identify and map the indigenous varieties of cow and help maintain its existence.

Similarly, voice recognition or the pitch of the cattle moo can be used to identify the cattle is in distress or not, the voice changes when the cattle are in distress, this can be used when the owner of the farm is away from the farm to give an alarm in the phone or connected devices so that immediate action can be taken.

 

When buying a new cattle:

K Nearest neighbor algorithm

Now being discussed that how to measure the amount of milk that we can expect from a cow using the various food given to the cow. For a starter, how effectively can we predict the amount of milk that a new cow that we are looking forward to purchasing, we can’t just blindly believe that what the seller is giving about the amount of milk being produced?

This can be solved using the K Nearest neighbor algorithm, it can take the same dataset that we used above to cases combined. So nearest neighbor, how it works the algorithm studies the data by converting the data points into coordinates in space and find the distance of each data points and the data points with the least distance can be inferred as the one with the maximum similarity with the one with which we are comparing.

The same algorithm can be used here to identify or predict the amount of milk that we are expecting from a new cow that we are looking forward to adding to the farm.

knn, k nearest neighbor

Similarly, the KNN algorithm can also be used for identifying the breed of the cow using the same dataset that we used for the classification algorithm and the image classification algorithm that we used.

And the list of problems that can be solved using Machine Learning is huge, it can be used in every aspects of dairy farming, further venturing we can use image classification can be used to identify the breed of the cow and also the health of the cow. And can even predict that whether a cow is in distress by the way the cow moo’s using a voice classification and the list goes on.

Here in the article, it was shown that it’s not just for finance or business that we can use the machine learning algorithm, with the right analogy and right data we can use Machine learning in every aspect to improve or make our lives easier. To quote a few examples to find which type of mango a person is selling, what type of watermelon was spotted on the street with the right tools it can be used anywhere and everywhere.

 

Storage:

Time-series:

The amount of milk being produced on the farm every day can be used as time series data for forecasting the milk production in the upcoming week can take necessary steps for storage and processing of the same, enhancing the productivity after we receive the milk.

Milk production forecasting - machine learning odairy farming

A similar model can be made on the food consumed so that we can forecast consumption of the food in the upcoming week and be handy on the supply, it can be used on tracking the waste generated from the farm to keep everything check.

 

Data

The data collection part here is tremendous, so we must identify an alternative to the manual survey.

With the availability of various IoT devices available in the market, we can try to automate the data collection process, connecting with the weighing machines, with cameras and voice recording, and so on.

One main thing to remember here is that we need correct and accurate data to do all the Machine learning, so for working this we need a correct and accurate data collection strategy.

The potential for using machine learning techniques has endless potential in dairy farming to enhance productivity as well as for the treatment of the cattle.

Anandk1 01 Dec 2020

Frequently Asked Questions

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

Responses From Readers

Clear

Barbara
Barbara 01 Dec, 2020

Thanks for the post! This is truly fascinating! I am learning some of these techniques in my Master's program so seeing how they can be applied is very helpful.

Michelle
Michelle 28 Feb, 2022

Thanks for sharing this useful information! Hope that you will continue with the kind of stuff you are doing.