A.I, Data and Software Engineering

AI in agriculture: fruit grading (Part 1)


During a meet up last month, a friend told me about the current project on a farm in New Zealand. They want to build a system to grade their fruits and AI is the technology they are looking for. It inspired me to write about how machine learning can help in solving such a problem.

apple grading using machine learning
Fig 1: Apple grading

The grading task

Given an apple, we need to sort it to correct category in three available categories: e.g. grade 1, 2, 3. Grade 1 apples have the best quality while 3rd ones are the worst.

So it is a classification problem and can be solved effectively using machine learning.

Data and features

To build the grading model, we will need relevant data, i.e. data of different apples. As shown in Fig 1, the information can include colours, shapes, weight, etc. Nevertheless, we need data with labels. It means that given an apple in the sample set, we should know its grade, e.g grade 1 or 2, or 3.

We may have several features of an apple to consider in a grading model. We need feature engineering to select the right feature set for accurate grading.

Basic classification

As discussed, the grading problem is similar to the classification problem. Unfortunately, I don’t have the real data for those fruits. Instead, we will create some fake data of three classes and try to use a pure python to implement the classifier with Multilayer Perception.

In part 2, we will use TensorFlow to reimplement this project.

Multi-layered Perception classifier

You can read more content from the data science category or read more about multilayer perception in Wikipedia.

1 comment

A.I, Data and Software Engineering

PetaMinds focuses on developing the coolest topics in data science, A.I, and programming, and make them so digestible for everyone to learn and create amazing applications in a short time.

Pin It on Pinterest


You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Petaminds will use the information you provide on this form to be in touch with you and to provide updates.
%d bloggers like this: