Article

Hello world for machine learning

Cliff Ortmeyer
datacenter

What's Next Magazine

Machine learning (ML) is growing structurally and expanding to several industries all over the globe. It’s the most sought-after technology in today's market.

ML has been embraced by smart applications to solve virtually unsolvable problems. Also known as predictive analytics, it is a mathematical method that "learns" from known good data.

Try the steps and advice below to build your own ML model.

To begin...some background

There are two approaches to ML: inductive and deductive.

  • Inductive machine learning generalizes observations.
  • Deductive machine learning can be characterized as a search for patterns within a set of data.

ML algorithms have been getting smarter since their invention. Big Data is constantly growing, and it's changing how we develop products.

The rationale for this is the massive amount of data produced by applications, the increase of computation power over the last few years, and better algorithm development. ML plays a crucial role in multiple critical applications, notably data mining, natural language processing, image recognition, automation and expert systems. The potential opportunities for machine learning are so numerous that it is hard to list them all.

ML allows the system to learn automatically and predict without human intervention. The hello world program presented in this article should help you understand the concept, the build environment, and how coding works for ML algorithms. A few lines of Python is all it takes to write your first ML program. To do that, we'll work with an open-source library: scikit-learn.

Machine learning and its importance

ML is a subfield of Artificial Intelligence (AI). Early AI programs typically excelled at just one given thing. Today we want to write one program that can solve several problems without any rewrites. Alpha Go is a valid example where similar software can also learn to play Atari games. ML makes that possible. It's the study of algorithms that learn from examples and experience instead of relying on hard-coded rules.

In ML, instead of defining the rules and expressing them in a programming language, answers (typically called labels) are provided with the data. The machine will infer the rules that determine the relationship between the labels and the data. The data and labels are used to create ML algorithms, typically called models. Using this model, when the machine gets new data, it predicts or correctly labels them.

block diagram
The image depicts machine learning programming.

For example, if we train the model to discern between apples and oranges, the model can predict whether an object is an apple or an orange when new data is presented. The problem sounds easy, but it is impossible to solve without ML. You'd need to write tons of rules to tell the difference between apples and oranges. With a new problem, you need to restart the process.

There are many aspects of fruit that we can collect data on, including color, weight, texture and shape. For our purposes, we'll pick only two simple ones as data: weight and texture. In this article, we will explain how to create a simple ML algorithm that discerns between an apple and an orange.

Creating your first ML model

To discern between an apple and an orange, we create an algorithm that can figure out the rules so we don't have to write them by hand. And for that, we're going to train what's called a classifier. You can think of a classifier as a function. It takes some data as input and assigns a label to it as output. The technique of automatically writing the classifier is called supervised learning.

Supervised learning

To use supervised learning, we follow a simple procedure with a few standard steps. The first step is to collect training data. These are essentially examples of the problem we want to solve. Step two is to use these examples to train a classifier. Once we have a trained classifier, the next step is to make predictions and classify a new fruit.

block diagram
These are the primary steps in a machine learning procedure.

[Go here to follow the steps]

What’s Next?

Farnell has built an AI hub with the best selection of the latest development platforms and modules, open-source projects, application kits and much more to help design engineers, makers, researchers and students build their own AI applications or scale their current projects.

Farnell is part of the Avnet family of businesses and serves customers as a fast, reliable, high-service distributor of products and technology.

MORE READING

About Author

Cliff Ortmeyer
Cliff Ortmeyer, Global Head, Technical Marketing

Cliff’s musical tastes are as varied as his electrical engineering experience. He loves metal, jazz ...

Marketing Content Spots
Related Articles
Related Articles
man and woman at desk looking at computer monitors
Artificial intelligence and the universal impact on product design
By Karen Field   -   May 15, 2025
Some 82% of engineers surveyed by Avnet say they have products or are working on new designs that feature AI. The latest Avnet Insights survey explored how engineers are using AI in the design process and incorporating it into product design. The surv...
man using laptop computer in data center
5 myths about AI from a software standpoint
By Phil Robinson   -   May 14, 2025
Production-ready demo code and quick implementation. That’s what they tell you, but is it too good to be true? We break down some of the myths surrounding AI software implementation.
Related Events
Related Events
What, Why & How of Vision AI at the Edge
Date: April 23, 2021
Location: On Demand