A MACHINE LEARNING-BASED PRICE PREDICTION FOR COWS

As Bangladesh is an agricultural country, cows have a great influence on our economy. However, there is no cow-related work or dataset accessible online in the fields of machine learning and artificial intelligence. This study aims to predict cow price ranges using any cow picture. Cow images were collected from different online e-commerce sites which are selling cows and mainly attempted to predict the price range of cows based on the images of the cows. Cows are divided into four classes based on their price range namely low, medium, high, and very high classes. A machine learning-driven approach has been taken for the prediction where convolutional neural network (CNN) is used as an image classifier and linear regression is used for predicting the prices. Our result shows that the price range of a cow can be predicted with an accuracy of 70%.


INTRODUCTION
Price prediction is difficult regarding the complex behavior of price signaling and datasets. But it has a great socioeconomic value. Almost 80% of people in our country Bangladesh live in rural areas. As they live in villages, they mainly depend on agriculture for their livelihoods. That's why cows are the most domestic animal in almost every house in the village. On the other hand, Bangladesh is a Muslim-majority country with significant demand for cows. So, cows have a great impact on the economy. People who are unaware of the price of cows, on the other hand, are often defrauded when selling and purchasing cows. So, a tool that predicts the cows' prices can be helpful to know about the prices of cows before selling and buying and the chance of deception will be reduced. Therefore, this work aims to predict the price of cows according to the image. Along with the images, some other attributes have also been considered.Predict of price is always a tough task. Here, the prediction of livestock like a cow's price class is more difficult than other price prediction tasks. A lot of works has already been done by machine learning engineers for price predictions such as stock price prediction, house price prediction, beef meat price, etc. from the images using in CNN. But a few works on cattle price prediction. In this paper cows' price range will be predicted. S. U. Rehman proposed an unsupervised CNN architecture for face image classification. By combining CNN with other modules and algorithms, a CNN capable of multitasking (e.g., facial detection and emotional classification) is developed. N. Jain et al. proposed a hybrid deep CNN and RNN (Recurrent Neural Network) model. The aim of this model is to improve the overall performance of image category detection. ConvNets can learn these channels/highlights with satisfactory preparation. Although some papers advocate for the use of unsupervised CNN, supervised learning is more suitable for this initiative.

METHODOLOGY
Firstly, a dataset is created by web scraping, then we preprocessed the dataset for implementing the algorithms. Then used CNN and Linear regression to predict the price. The detail is as follow,

CNN
A Convolutionary Neural Arrange (ConvNet / CNN) may be a Profound Learning algorithm, which permits an input picture to require on diverse viewpoints / objects and can be recognized from one picture (learnable weights and inclinations). ConvNet requires much less preprocessing than other classification calculations. Whereas the channels are hand-made in primitive strategies, ConvNets can learn these channels / highlights with adequate training. The ConvNet design is comparable to that of neurons within the human brain and was impacted by the Visual Cortex association. Inside a restricted region of the visual eld known as the Open Field, as it where person neurons react to jolts. The whole visual zone is secured by a choice of these areas.

Data Collection & Processing
Price range detection is the process of automatically discerning the price of a cow solely from a photo of its full body. Typically, you'll see price detection implemented as a three-stage process: Stage 1: Data Collection via web scraping Stage 2: Data processing adding cow price added in cow image path Converting images into 256 Stage 3: Extract the price Region of Interest (ROI), and apply the price predictor algorithm to predict the price of the cow.
There are 6 features(image,height,age,color,class) in the database and one dependent variable(price). First cow price is added in the cow image path so that a relationship between cow price and cow images can be built. Finally add four features(height, age, teeth, and color) inside the image header. Divide the whole database into the train (80%) and test (20%) datasets. Then pass images in CNN. Color is an example of a categorical attribute. As a result, color was used after encoding. Here, mainly tried to predict the price range of cows according to the images of the cows. Four classes are defined based on their price range. Low (price <75000 taka), medium(75000<price≤150000), high(150000<price≤250000) and very high (price>250000) class.

Image Processing
Image processing is a technique of performing operations on an image in order to improve it or obtain valuable information from it. This is a method of signal processing in which taking an image as input, and giving outputs as an image or some features. Reading image from dataframe, keeping inside 3D array (256,256,3) and scale image pixel value into 0 to 1. Then all images divide into three sets train images, test images, validation images.

Price Prediction With CNN
CNN algorithm is used for price range prediction. Some interdependent procedures are followed step by step. It is discussed in the below points.First,changing the current directory to the path where image dataset is been stored and then listing the files and directories in the specified path and adding cow price inside cow image path.Reading database from csv. Split database into train and test datasets. Processing images from path and convert them into 252x252x3 arrays and scaling pixel values into 0 to 1. Adding others features height; age; teeth; color, with image array. Finally, 256*256*3 array is formed. Building CNN model. adding Conv2D layer with 16 size and 3*3 kernel size, Relu activation layer and MaxPool2D. adding Second Conv2D layer with 32 size and 3*3 kernel size ,Relu activation layer and MaxPool2D.Adding 2 Dense layer with size 64.Finally adding output layer with input size 1.In this work, Keras is used and it supports CNN. Fit model with train data and validation data.

Dataset
There is no existing dataset. A dataset is created for this work. Library named beautiful soup is used for parsing HTML and XML documents including markups, non-closed tags. It builds a parse tree for parsed pages that are used for extracting data from HTML, which makes web scraping easier. Data sourcing websites are "amardeshshop.com" and "goruchai.com" which are e-commerce websites. Then decipher the information in URLs. After that links are sorted which information is used mainly needed. Then parse HTML code with beautiful soup. We make a CSV le with six columns. (cow id,image,height,age,teeth,color). The total length of a dataset is 931, out of which 596 is used for training,187 for testing, and 148 for validating the data. One valid image had a shape (256,256,3). We divided the cows into four categories based on price range [Low, Medium, High,Very High]. Test Dataset: The test data collection is used to evaluate the classification or model results and verify the performance of features such as precision, failure, sensitivity and so on. It is independent of the training and validation dataset. 20% of data from dataset is chosen randomly for testing the model. This work has an accuracy of 70.05%, its precision is 68.69%, recall is 70.05% and the F1 score is 65.73%. The accuracy level can be increased when the dataset will be increased.

CONCLUSION
In this paper, a model is proposed to perform price class estimation based on cows' images by using the image classifier CNN (convolutional neural network). Almost 1000 data points from different websites related to cows are collected for this process. Most of the data points are taken from the website "goruchai.com". 80% of data as training and 20% of data as testing purposes. This study shows an accuracy of 70%.