top of page

AI for Cybersecurity with Labs

  • May 28
  • 13 min read

Updated: Jun 8


AI for Cybersecurity with Labs

AI for Security Cybersecurity with Labs

Welcome & Install Jupyter Notebook

Welcome to our new lab series, “AI for Security Cybersecurity with Labs.” This series of projects will help you understand how AI works by the only proper way to learn it: by doing it. Learning AI will help future-proof you in the changing industry we are in today.


We are going to do some fun things; I’ll explain everything AI and the statistics you need to know along the way, so grab your lab coats and let’s get started!


Installing Jupyter Notebook on a Mac

The first thing you’re going to want to do is install brew on your machine if you haven’t already.


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the instructions on the output of that command; mine looks like this:


echo >> /Users/tylerwall/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/tylerwall/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

And then we’re going to install Python


brew install python

Then we’re going to install Jupyter Lab


pip3 install jupyterlab

Finally, we’ll install Jupyter Notebook


pip3 install notebook

You add it to your $PATH, first, but you want to see what terminal you’re using.


If you see /bin/zsh, you’re using Zsh (default in macOS Catalina and later).


If you see /bin/bash, you’re using Bash.


nano ~/.zshrc
or
nano ~/.bash_profile

Add this line to the end of the file:


export PATH="$HOME/Library/Python/3.9/bin:$PATH"

Save the file and run this command


source ~/.zshrc

And to run Jupyter Notebook, you type


jupyter notebook


Installing Jupyter Notebook on Windows

Install Python (if not already installed)


Download Python (preferably the latest version).


During installation, check the box that says:

[✓] Add Python to PATH

Open Command Prompt

Press Win + R, type cmd, and hit Enter.

Run these commands:

pip install notebook

Once installed, you can start it by running:

jupyter notebook

It will automatically open in your default web browser.


Wrapping Up Part I

Now run this command because you’ll need these too:

pip install pandas scikit-learn matplotlib seaborn flask

Jupyter Notebook is a tool you can use in your web browser that lets you write and run code, see the results, and explain what you’re doing all in one place. It was initially designed for Python, but now it also works with many other programming languages. The notebook is split into sections called “cells,” where you can write code or text. This makes it easy to test your ideas step by step and see what works. It’s great for learning, teaching, and working on projects.


Jupyter Notebook is especially helpful for artificial intelligence (AI) projects. It allows you to try out different models and see how well they perform with your data. You can also make charts and graphs to understand what’s going on. If something goes wrong, you can fix it right there without starting over. You can add notes and pictures to explain your work, which is useful when showing it to others.


It also works well with tools like TensorFlow, PyTorch, and scikit-learn, which are popular for building AI applications. Because of this, it’s easier to develop and test smart programs that can learn from data. You can even save your notebook as a file to share with others or keep for later.


Overall, Jupyter Notebook is an excellent tool for AI, as it enables you to try things quickly, learn from your results, and keep track of your work in a clear and organized manner.


Let’s get started with a quick intro to AI.


Intro to AI

Artificial Intelligence, or AI, is a term you’ve heard a lot about. It pops up in discussions about the latest tech, sci-fi movies, and even in conversations about the future of work and everyday life. But what exactly is AI? How does it relate to machine learning, and what role does something like ChatGPT play? And what about automation? How does that fit into the picture? In part two, we’ll dive into these topics, breaking them down in a way that’s easy to understand. By the end, you’ll have a clearer idea of what these terms mean and how they’re shaping our world.


To start, let’s understand what AI really is. Artificial Intelligence is the idea of creating machines or software that can perform tasks that normally require human intelligence. These tasks include things like understanding language, recognizing pictures, making decisions, and solving problems.


Think of AI as a super-smart computer program that can learn and adapt. When you play a video game against a computer opponent that gets better the more you play, or when you ask your phone’s assistant to set a reminder, you’re interacting with AI.


Levels of AI

AI comes in different levels, based on the intelligence and capabilities of these systems. The simplest form is called Narrow AI. Narrow AI is designed to do one specific thing. It’s excellent at that one thing, but can’t do anything else. For example, the spam filter in your email that catches junk mail is a type of Narrow AI. It’s great at identifying spam messages, but it can’t help you with your math homework or play chess with you.


Next up is General AI. This is the kind of AI that can understand, learn, and apply knowledge across a wide range of tasks, much like a human can. General AI doesn’t just excel at one task but can perform many different ones, switching between them as needed. Imagine a robot that can cook, clean, help you study, and even have a meaningful conversation with you about your day. As of now, General AI is still something we’re working towards and hasn’t been fully realized yet.


Finally, there’s Super Intelligent AI. This is a level of AI that would surpass human intelligence in every aspect. It would not only perform tasks better and faster than humans, but also come up with ideas and solutions that exceed human capabilities. This kind of AI remains in the realm of science fiction for now, as we’re far from creating anything like it.


levels of ai
Figure 2–1: Levels of AI

Machine Learning

Now, let’s talk about machine learning. Machine learning is a big part of AI, but it’s more specific. It’s a method for teaching computers to learn from data. Instead of programming a computer with exact instructions for every possible situation, we give it lots of data and let it figure out patterns and rules by itself.


Imagine you have a computer program that you want to teach to recognize cars in pictures. Instead of telling it exactly what a car looks like, you show it thousands of images of vehicles and thousands of pictures of other things. The computer analyzes these pictures and learns the patterns that distinguish a car from other objects.


This process of learning from examples is what machine learning is all about.


ChatGPT

ChatGPT is a specific type of AI. It’s designed to understand and generate human-like text based on the input it receives. If you’ve ever chatted with an online assistant that can answer questions or help you with tasks, it might be powered by something similar to ChatGPT. What makes ChatGPT unique is that it employs a technique called deep learning, a type of machine learning. Deep learning involves using extensive networks of computers to learn from vast amounts of data, kind of like building a very complex brain for the computers.


ChatGPT is trained on a massive amount of text data from the internet. This process, called pre-training, helps it learn grammar, facts, and even some (minimal) reasoning skills. After this, it undergoes fine-tuning, where it improves at specific tasks by receiving feedback from developers and you. When you ask ChatGPT a question, it uses all this learning to generate a response that makes sense based on the context.


It’s important to note that while ChatGPT is a form of machine learning, it’s specifically designed for working with language. Making it a Narrow AI.


Not all machine learning models are like this. Some might be designed to recognize images, while others might predict weather patterns. ChatGPT’s primary function is to understand and generate text, making it a powerful tool for applications such as chatbots.


Automation

Automation is another concept that’s often mentioned alongside AI and machine learning, but it differs. Automation is all about making machines or software do tasks on their own without human help. These tasks are usually repetitive and follow a clear set of steps. For example, think about an automatic washing machine. Once you load your clothes and start it, the machine goes through a series of steps to wash your clothes without needing any further input from you. That’s automation.


Automation doesn’t necessarily require AI. For example, a simple conveyor belt system in a factory that moves products from one location to another is automated, but it lacks intelligence. It’s just following a pre-programmed set of instructions. It can’t learn anything new on its own or adapt.


So, how do AI, machine learning, and automation differ from each other?

AI is the broad concept of creating intelligent machines.

Machine learning is a specific approach within AI where machines learn from data.


ChatGPT is a specific approach within Machine Learning called Deep Learning.

Automation is about making machines or software perform tasks on their own, often without any need for intelligence. Automation is not AI. However, it’s being combined with AI every day in a thing called Agentic AI. Agentic AI is intelligence that can think and carry out tasks.


difference between ai and automation
Figure 2–2: Difference between AI and Automation

When you put them together, you get robust systems that can do amazing things, like self-driving cars that navigate traffic on their own, or intelligent assistants that manage your daily tasks.


AI Concerns

As exciting as all these advancements are, it’s essential to think about the impact of AI, machine learning, and automation on society. One concern is job displacement. As machines become capable of performing more tasks, some jobs may become obsolete. For example, self-driving trucks could reduce the need for truck drivers, and automated customer service systems could replace human agents. However, new jobs will also be created in areas such as AI development, data analysis, and the maintenance of these systems. It’s essential for education and training programs to equip individuals for these emerging roles.


Another concern is privacy. AI systems often rely on large amounts of data to function effectively. This data can include personal information, like your browsing history, purchase habits, and even your voice recordings. Companies need to handle this data responsibly and ensure that it’s protected from misuse. Regulations and policies are required to ensure that AI is used ethically and that people’s privacy is respected. This is an emerging field called AI Governance.


There are also ethical considerations around AI decision-making. For example, how do we ensure that AI systems are fair and unbiased? If an AI system is used to make decisions about things like job applications, loans, or medical treatments, these decisions must be made fairly. Bias can creep into AI systems if the data they’re trained on contains biases. For instance, if a hiring algorithm is trained on data where certain groups are underrepresented, it might unfairly disadvantage those groups. Researchers and developers are working on ways to identify and mitigate bias in AI systems to ensure they’re fair and equitable.


In addition to these concerns, there’s the question of control. As AI systems become more advanced and autonomous, how do we ensure that we remain in control? This is especially important when it comes to AI systems that can make decisions independently, such as self-driving cars or automated weapons. Establishing clear guidelines and oversight mechanisms is crucial to ensure that AI is used responsibly and safely.


Wrapping up Part Two

AI, machine learning, and automation are fascinating and transformative fields that are reshaping our world. AI is the broad concept of creating intelligent machines. Machine learning is a method that enables these machines to learn from data, and automation is about automating tasks without human intervention. As these technologies continue to evolve, they will bring new opportunities and challenges. Understanding them is the first step to being a part of this inevitable future.


The next part of AI for Cybersecurity with Labs focuses on the distinction between AI users and AI creators, with a world of many more users than creators and the skills needed for both.


Take a quick interactive quiz


AI Users vs. AI Creators

People who use AI and people who make AI are different in many ways. AI users focus on using tools to help with their daily tasks. They might use apps like ChatGPT to write stories or emails, use image generators to create art, or get help from smart assistants to answer questions. They don’t need to know how the AI works; they just want it to work well and help them get things done faster.


The people who make AI are the ones building those tools. They are engineers and researchers. They write code. They study math. They train AI models using powerful computers and huge sets of data. Their job is to make AI smarter, more helpful, and more reliable. While users explore what AI can do, makers explore how to make AI better.


The tools they use are also very different. AI users usually work with websites and apps. AI makers use programming tools, coding environments, and special hardware that can handle lots of calculations. Users can do their work on a regular laptop. Makers often need servers or advanced machines to test and train their AI systems.


Their responsibilities are not the same. AI users must be careful with how they use the technology. They shouldn’t use it to lie, cheat, or hurt others. AI makers have to make sure the systems they build are fair and safe. They have to think about privacy, bias, and long-term risks.


The way they think is also different. People who use AI think about what it can do for them. They like finding new ways to solve problems or save time. People who make AI think about how it works and how to improve it. They are problem solvers. They are builders.


The effects they have are different, too. AI users might impact their jobs or creative work. AI makers might impact entire industries or even the future of how we use technology.


In simple terms, users are like people driving cars. Makers are like the ones building the engines. One group gets things done with the help of AI. The other makes sure AI is possible. Both are important. Both are part of the same story, but they play very different roles.


Is Cybersecurity a User or Creator?

Cybersecurity engineers often find themselves in a unique position - they are both users and makers of AI, depending on the task and the level of expertise they bring.


As users, cybersecurity professionals rely on AI tools to detect threats, analyze logs, and respond to incidents faster than a human could alone. They might use AI-powered systems to spot unusual network behavior, identify phishing attempts, or classify malware. These tools help them sort through massive amounts of data quickly, making their jobs more efficient and their responses more accurate. In this way, AI becomes a powerful assistant - a second set of eyes that never gets tired.


But cybersecurity professionals are also increasingly becoming makers of AI. Many of them are now building custom models for their specific needs. For example, they might train a machine learning model to detect a new kind of attack that’s unique to their network. They might write scripts that feed threat data into AI systems or build automation workflows that let AI take action on its own. This kind of work moves beyond simply using tools - it’s about shaping them.


The more advanced a cybersecurity professional becomes, the more they shift into the maker role. They might experiment with anomaly detection algorithms, contribute to open-source security AI projects, or design entire AI systems for defense and offense. They understand how models work, how data flows through those models, and how attackers might try to trick or bypass them.


So, in the world of cybersecurity, the line between using AI and making AI is blurry. Most professionals start as users, but over time, as they develop more skills in programming, data analysis, and machine learning, they take on the mindset and responsibilities of makers. They don’t just protect systems with AI - they build the AI that protects the systems.


In the future, the best cybersecurity professionals will be those who can effectively utilize AI while also building it securely.


How Cybersecurity Uses AI

From your SIEM to your endpoint tool, they all seem to have some kind of AI built into them to make your job faster and more efficient. However, other ways Security professionals might utilize AI include using ChatGPT for writing scripts to modify, reducing work by 70%, or by asking it questions while troubleshooting, saving 40% of the time spent on Google. In the future, when Agentic AI arrives, a Security Engineer might be responsible for configuring the automations and building our own models for security. Personalized AI models trained on company data have a much higher accuracy rating. The cleaner the data it’s trained on, the better it will work.


Everyone will need to learn to use AI in their favorite tools. However, there will only need to be a few people who are makers of AI, and Security professionals will be the ones to use AI.


So, first things, how do I even start making AI?


How to Start Making AI

If you want to make AI instead of just using it, there are a few important things you need to learn first. At the most basic level, AI is about creating systems that can act smart - things like recognizing patterns, making decisions, or learning from experience. Most modern AI is built using something called machine learning, where a computer learns from data instead of being programmed with step-by-step instructions.


To understand how AI works, you’ll need to learn some basic math. You don’t have to be a math expert, but you should be comfortable with algebra, statistics, and eventually some linear algebra. These help you understand how AI models process data and make predictions. Later on, if you want to dive deeper, some knowledge of calculus can also be helpful.


Next, you need to learn how to code, and Python is the best place to start. It’s simple to read and has a lot of useful libraries for AI, like scikit-learn, TensorFlow, and PyTorch. You’ll use coding to load data, train models, and test their results. Along with coding, you’ll need to understand how to work with data - how to collect it, clean it, and analyze it. Data is what AI learns from, so learning how to handle it well is a must.


Once you’re comfortable with code and data, you can start learning about models and training. An AI model is like a digital brain that gets smarter as you feed it data. We will begin with supervised learning to get our hands dirty quickly, where the model is trained with labeled examples, and work on basic tasks like classifying emails. You’ll also learn about important ideas like overfitting, where a model memorizes instead of learning, and underfitting, where it doesn’t learn enough.


The best way to truly understand AI is to build projects. You can start simple - predicting house prices, filtering spam, recognizing handwriting, or even building a basic chatbot. These hands-on experiences will teach you more than reading alone. You can also learn a lot from the community. There are websites like Kaggle, where you can join data science competitions, and Google Colab, where you can write and run Python code in the cloud for free. Hugging Face is another great place to explore powerful AI models for natural language tasks.


In short, if you want to make AI, we’ve started by learning what it is, now we will begin building simple projects. The more you build and explore, the more confident you’ll become.


From this point forward, our learning will be in Jupyter Notebooks.






How to Start a Jupyter Notebook

Open your terminal (Mac/Linux) or Command Prompt (Windows).

Navigate to the folder where your notebook is saved using cd, for example

cd Downloads

Start Jupyter by typing:

jupyter notebook

Your browser will open the Jupyter file explorer.

Click the notebook file to open it.


Run (Play) the Notebook

Once the notebook is open:

Click on a cell (a gray or white box of code or text).

Run the cell by pressing:

Shift + Enter (the most common)
OR click the Run button (a triangle ▶ at the top)

Keep doing this cell by cell.

Watch the output appear just below each code cell.


How to Reset (Restart) a Jupyter Notebook

Inside the notebook (once it’s open), go to the menu at the top.

Click Kernel → Restart.

This clears all variables in memory (like starting over).

It does not delete your code.

After restarting, to re-run all your code:

Click Cell → Run All, or
Press Shift + Enter on each cell one by one.












$14.95

Cyber NOW® Socks

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$41

Cyber NOW® Unisex Track Pants

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$20.45

Cyber NOW® Women's short sleeve t-shirt

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

Recommended Products For This Post

Commentaires


Get Your Dream Cybersecurity Job

Cyber NOW

Courses  :  Certifications  :  Cyber Range  :  Job Boards  :  Knowledge Base  :  Webinars  :  WhatsApp Community

Jump Start Your SOC Analyst Career

Get the new book, Jump-start Your SOC Analyst Career, authored by Tyler Wall.  

 

Winner of the 2024 Cybersecurity Excellence Awards in the category of Best Cybersecurity Book!

Contact us

  • LinkedIn
  • Facebook
bottom of page