Use of Machine Learning in Dairy farming

Anand
7 min readNov 29, 2020

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 little easier.

Being from a farming background my first thought went there, if we could see that these days we can see how AI/ML is helping in enhancing the produces from identifying weeds, pest and a 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, first thing whatever be the algorithms what it tries to do is look for pattern 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 on the data being for each the algorithms and how I obtained it (still in progress)

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

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

Where to use

In 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, temperature of that day, Months since last birth, Age, Breed and so on.

On obtaining the data 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 is 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 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 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 modelling the data, we can expect certain accuracy level to which we can correctly predict the breed of the cow. We can tune the model with 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.

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, the 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 a image recognition model for identify the breed of the cattle , as we have lot of algorithms available we can go with the one which is predicting the most correctly, this would be a huge work as to identify and feeding the photos of the different cattle breed spread across India and some are indigenous to certain part, this can also be used to identify and map the indigenous varieties of cow and help maintain its existence.

Similarly a 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 is in distress , this can be used for 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:

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 purchase, we cant just blindly believe that what the seller is giving about the amount of milk being produced.

This can be solved using K Nearest neighbor algorithm, it can take the same dataset that we used in 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.

Similarly, 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 the 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 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 show that its not just for finance or business that we can use the machine learning algorithm , with right analogy and right data we can use Machine learning in every aspects 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 in the farm everyday 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.

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 generation from the farm to keep everything check.

Data:

The data collection part here is tremendous, so we must identify alternative to 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 use of ML techniques has endless potential in dairy farming to enhance the productivity as well as for the treatment of the cattle.

--

--