Artificial Intelligence / Machine Learning in AI

Difference Between AI, ML, and Deep Learning

This tutorial distinguishes the differences and relationship between AI, Machine Learning, and Deep Learning. These are often misunderstood to be the same, but they are different …

Tutorial 2 of 5 5 resources in this section

Section overview

5 resources

Explains how machine learning forms the foundation of AI, including supervised and unsupervised learning.

1. Introduction

In this tutorial, we aim to clarify the differences and relationships between Artificial Intelligence (AI), Machine Learning (ML), and Deep Learning (DL). Although these terms are often used interchangeably, they each refer to distinct concepts in the realm of intelligent systems.

By the end of this tutorial, you will have a clear understanding of what AI, ML, and DL are, how they relate to each other, and the practical applications of each.

This tutorial is suitable for beginners and doesn't require any prerequisites.

2. Step-by-Step Guide

2.1 Artificial Intelligence (AI)

Artificial Intelligence refers to the simulation of human intelligence processes by machines, especially computer systems. These processes include learning, reasoning, problem-solving, perception, and language understanding.

AI is classified into two types:

  • Weak AI: Designed to perform a narrow task (e.g., voice recognition).
  • Strong AI: Also known as General AI, it performs any intellectual task that a human being can do.

2.2 Machine Learning (ML)

Machine Learning is a subset of AI that provides systems the ability to learn and improve from experience without being explicitly programmed. It focuses on the development of computer programs that can access data and use it to learn for themselves.

There are three types of learning in ML:

  • Supervised Learning: The model learns from labeled data.
  • Unsupervised Learning: The model learns from unlabeled data.
  • Reinforcement Learning: The model learns by interacting with its environment.

2.3 Deep Learning (DL)

Deep Learning is a subset of ML that imitates the workings of the human brain in processing data for use in decision making. DL uses artificial neural networks with several layers (hence the 'deep' in deep learning).

3. Code Examples

In this section, we'll use Python's sklearn library for ML examples and keras for DL examples. Note that these are not AI code examples, since AI is a broader concept that encompasses ML and DL.

3.1 Machine Learning Example

This is an example of supervised learning. We'll use a simple linear regression model to predict house prices based on a single feature.

# Import necessary libraries
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
import numpy as np

# Assume we have the following data
# house_sizes = size of the house in square feet
# house_prices = price of the house in thousands of dollars

house_sizes = np.array([1500, 2000, 2500, 3000, 3500])
house_prices = np.array([200, 250, 300, 350, 400])

# Reshape the data since we only have one feature
house_sizes = house_sizes.reshape(-1, 1)

# Split the data into training set and test set
X_train, X_test, y_train, y_test = train_test_split(house_sizes, house_prices, test_size=0.2, random_state=42)

# Create a linear regression model
model = LinearRegression()

# Train the model
model.fit(X_train, y_train)

# Predict house price for a new house size
new_house_size = np.array([3200]).reshape(-1, 1)
predicted_price = model.predict(new_house_size)

print(f'The predicted price for a house of size {new_house_size[0][0]} sq ft is {predicted_price[0]} thousand dollars.')

3.2 Deep Learning Example

This is a simple DL example using Keras to classify handwritten digits using the MNIST dataset.

# Import necessary libraries
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils

# Load data
(X_train, y_train), (X_test, y_test) = mnist.load_data()

# Flatten 28*28 images to a 784 vector for each image
num_pixels = X_train.shape[1] * X_train.shape[2]
X_train = X_train.reshape((X_train.shape[0], num_pixels)).astype('float32')
X_test = X_test.reshape((X_test.shape[0], num_pixels)).astype('float32')

# Normalize inputs from 0-255 to 0-1
X_train = X_train / 255
X_test = X_test / 255

# One hot encode outputs
y_train = np_utils.to_categorical(y_train)
y_test = np_utils.to_categorical(y_test)
num_classes = y_test.shape[1]

# Define model
model = Sequential()
model.add(Dense(num_pixels, input_dim=num_pixels, kernel_initializer='normal', activation='relu'))
model.add(Dense(num_classes, kernel_initializer='normal', activation='softmax'))

# Compile model
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

# Fit the model
model.fit(X_train, y_train, validation_data=(X_test, y_test), epochs=10, batch_size=200, verbose=2)

# Final evaluation of the model
scores = model.evaluate(X_test, y_test, verbose=0)
print("Baseline Error: %.2f%%" % (100-scores[1]*100))

4. Summary

In this tutorial, we've covered the differences and relationships between AI, ML, and DL. We've learned that ML is a subset of AI that focuses on the ability of machines to receive a set of data and learn for themselves, changing their behavior based on what they learn. DL, on the other hand, is a subset of ML that uses the concept of neural networks to solve complex problems.

5. Practice Exercises

  1. Use the sklearn library to write a program for a classification problem using supervised learning. Use any sample dataset of your choice.

  2. Write a deep learning program using the keras library to solve a problem of your interest.

  3. (Advanced) Implement a reinforcement learning model to play a simple game like tic-tac-toe. You can use any library of your choice.

Remember, practice is key to mastering these concepts. Happy coding!

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

HTML

Learn the fundamental building blocks of the web using HTML.

Explore

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Text Diff Checker

Compare two pieces of text to find differences.

Use tool

Case Converter

Convert text to uppercase, lowercase, sentence case, or title case.

Use tool

Date Difference Calculator

Calculate days between two dates.

Use tool

Timestamp Converter

Convert timestamps to human-readable dates.

Use tool

AES Encryption/Decryption

Encrypt and decrypt text using AES encryption.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help