Anaconda and Python: Your Beginner’s Guide to Train Your Own AI Model

Anaconda and Python: Your Beginner's Guide to Train Your Own AI Model

Introduction to Python and Anaconda

What the heck? Why do we have all these Snakes in AI? What is Anaconda and what is Python? Simple Beginner explanation and use cases for all the toys we are going to play with.

What Python is and why it’s awesome – The Python Syntax Language Explained

Think of Python as a tool, like a toy you want to play with. When you download and install Python, you’re getting that tool. It’s like having a set of building blocks to create things. That’s pretty much explaining the Python basics.

Understanding Anaconda and its role – Beginner Explanation

Now, Anaconda is like a big box of toys, and Python is just one of the toys inside that box. Anaconda also has lots of other toys that can help you do special things, like drawing pictures or solving puzzles. So, when you download and install Anaconda, you get not only Python but also all these extra toys.

And yes, we do need all these toys for Building AI Models.

Building AI Models using Anaconda and Python
Why you should start to train your own AI Model

If you only want to play with Python, you don’t need Anaconda. You can just download Python, and that’s enough. But if you want to do more special things, like data science or making cool graphs, then Anaconda can be very helpful because it gives you those extra toys right away without having to find and add them one by one.

So, it’s up to you! If you’re just starting and want to learn Python, you can start with Python alone. If you want to explore more fun things later, you can get Anaconda, and it will have those extra toys ready for you.

However, when getting started, and when you want to train your own AI Model, it’s highly recommended to install Anaconda. That’s what I use for my own AI Model Training.

Let’s remember, if you are going to install Anaconda, you are also getting Python.

When you install Anaconda, it includes Python as part of the package. So, if you choose to install Anaconda, you automatically get Python along with many other useful tools and libraries for data science and machine learning. It’s like getting a big box of toys, and Python is one of the toys in that box.

I will also create a Beginner’s Guide to Python. But till that’s released, et’s focus on setting up Anaconda.

What is Anaconda in professional terms?

Anaconda is not a programming language, but rather a software distribution and package manager for programming languages, primarily Python. Think of it as a tool that helps you manage and work with different software and libraries related to data science, machine learning, and scientific computing.

What can you do with Anaconda?

Here’s what you can do with Anaconda:

  1. Manage Python Environments: Anaconda allows you to create isolated Python environments. Each environment can have its own version of Python and its own set of libraries. This is helpful when you work on multiple projects with different library requirements, as it prevents conflicts between libraries.
  2. Package Management: Anaconda includes a package manager called conda that simplifies the installation, update, and removal of software packages, including Python libraries. conda takes care of resolving dependencies, making it easier to manage complex software setups.
  3. Access to Libraries: Anaconda provides access to a vast ecosystem of pre-built packages and libraries commonly used in data science, machine learning, and scientific computing. This includes libraries like NumPy, pandas, scikit-learn, Matplotlib, TensorFlow, PyTorch, and more. You can easily install these libraries using conda.
  4. Integrated Development Environments (IDEs): Anaconda comes with popular integrated development environments like Jupyter Notebook and Spyder, which are helpful for interactive coding, data analysis, and visualization.
  5. Data Science Tools: It includes tools for data science, such as data visualization libraries, statistical packages, and tools for working with databases.
  6. Cross-Platform: Anaconda is available for Windows, macOS, and Linux, making it suitable for users on various operating systems.
  7. Conda Channels: You can access and install packages from different channels (repositories) in Anaconda, allowing you to find and add packages from different sources.
  8. Environment Management: Anaconda helps you manage your coding environments, making it easy to switch between different setups and project requirements.

In short, Anaconda is a versatile tool for managing and working with programming languages, with a strong focus on Python. It simplifies the process of setting up and managing complex software configurations, making it a valuable resource for data scientists, researchers, and developers in the field of data science and machine learning.

It’s not a programming language itself, but it provides a convenient environment for using programming languages like Python effectively.

What is a Python Environment?

Explaining Python environments

Imagine you have a big box of LEGO blocks. Each time you build something with these blocks, you want to make sure your creations don’t mix up with each other. So, what can you do? You can have different containers, like separate bowls or buckets, to keep your LEGO blocks organized.

In the world of computers and programming, we also build things, like little programs and projects. But just like with LEGO, we want to keep these projects separate and organized so they don’t mix up.

That’s where a “Python environment” comes in. It’s like having a special bowl or bucket for each of your projects. Each bowl has its own set of tools (like Python and other programs) and special instructions (like which LEGO blocks to use).

Python Environment
Personal Trained AI Models

So, when you work on one project, you use one bowl with its tools and instructions. And when you work on another project, you use a different bowl with its own tools and instructions. This way, everything stays neat and tidy, just like your LEGO creations in their separate containers.

Anaconda helps you set up these special bowls (Python environments) for your computer projects, so you can work on different things without them getting mixed up. It’s like having a magical organizer for your computer work!

What is an Anaconda Environment?

The difference between Anaconda environments and Python environments

Sometimes you hear developers talking about an Anaconda Environment. This can be confusing for young developers. In the context of Anaconda, “Anaconda environments” and “Python environments” are essentially the same thing. Anaconda is a tool that provides a way to create and manage Python environments, so when we talk about creating an Anaconda environment, we are also talking about creating a Python environment.

Anaconda Environment
Reasons for Training Your Custom AI Model

To clarify, when you create an Anaconda environment, you’re essentially creating a Python environment that is managed by Anaconda. These environments serve the same purpose, which is to keep your Python projects separate, organized, and free from conflicts in terms of the libraries and packages you use.

So, whether you refer to it as an “Anaconda environment” or a “Python environment” when using Anaconda, it means the same thing – a controlled and isolated workspace for your Python projects.

How to get started with Anaconda?

How to access and install Anaconda? Well, the Anaconda Installation is pretty easy. Let’s get started with Anaconda by downloading and installing the Anaconda application.

Anaconda Installtion Guide
Anaconda Installation

Getting started with Anaconda

  1. Download and install Anaconda from the official website:
  2. Open Anaconda Navigator and create a new environment. Select the latest Python and R Version available.
Anaconda Navigator
Anaconda Navigator

3. In the environment creation window, select the packages you want to install. For My AI Training model, you will need to install the following packages:

  • Python: Python is like the main language of your computer. It helps you give instructions to your computer to do all kinds of things, like playing games or drawing pictures.
  • NumPy: NumPy is like a special toolbox for doing math on your computer. It helps you work with numbers, like adding them, multiplying them, and doing other math stuff.
  • Pandas: Pandas is like a smart organizer for your data. It helps you keep your data in neat tables, like a list of your favorite toys with their names, colors, and sizes.
  • scikit-learn: Scikit-learn is like a superhero for solving problems with data. It helps you predict things, like whether it will rain tomorrow or not, using data and patterns.
  • PyTorch: PyTorch is like a magical wand for teaching your computer. It helps you make robots and train them to do things, like recognizing your drawings or understanding your words.

Important: You need to make sure that your Python version will be compatible with any Library you want to install. Otherwise, you’ll run into an installation error.

Usually a bunch of Libraries are already pre-installed. You can check and switch between Installed, Not Installed. Once the environment is created, you can activate it by clicking on the “Activate” button.

How to choose Machine Learning Frameworks?

Specifically, what machine learning frameworks do you need for your Environment?

First of all, let’s somehow explain what Machine Learning Frameworks are. And how they work. Let me try to give you a simplified example.

Explaining machine learning frameworks

Imagine you have a friend who loves learning new things. When you show your friend a picture of a cat, they quickly learn that it’s a cat. Then, when you show them a picture of a dog, they know it’s a dog. Your friend becomes really good at telling things apart.

Machine learning frameworks are like special tools that help your friend learn even faster. They provide super cool gadgets that help your friend understand pictures and things in a smart way. With these tools, your friend can look at lots of pictures and learn what’s in them, like cats, dogs, or even toys.

So, machine learning frameworks are like magic helpers for your friend to learn and understand pictures and lots of other things quickly!

GPT-3 for example, and many others like it often to use a machine learning framework called “PyTorch.” Think of PyTorch as the special toolbox that helps them understand and learn from lots of information. Just like you use different tools for different tasks, GPT-3 and other models use PyTorch to work their magic and understand words and sentences in a smart way.

Choosing Machine Learning Frameworks

That being said. Now we understand how important it is to choose the right machine learning framework for your Environment. In short, you need to know what you want to train your AI Model before you even start your AI project. Choose the most suitable framework for a Simple AI Model Creation.

  1. Understand Your Problem:
    • Start by clearly defining your problem or project. What are you trying to achieve with machine learning? Is it image recognition, text analysis, time series forecasting, or something else?
  2. Consider Your Expertise:
    • Think about your familiarity with programming languages. Are you comfortable with Python, R, or any other language? Most machine learning frameworks support specific languages, so choose one that aligns with your skills.

My AI Training Model

My Goals and what to consider for choosing your Machine Learning Frameworks

For my AI Training, I am going to create my own AI Clone. That means, I want to train my own personal AI Model with my own thoughts, believes, feelings, attitudes, Habits, anything that is considered “myself” or my soul. From a logical point of view, but also from a total human perspective of view. Including all my flaws, my anger, my frustration, my feelings, my perspective of seeing and experiencing the world. Wow, you bet. My AI Model is going to be a crazy maniac monster. lol;

What Language Model do I use?

There are several language models we can start with. However, keep in mind not all language models are for free to use. In fact, some of them can be very expensive. Please read my AI Language Model article, in which I am outlining and explaining in more detail why I choose BERT as my language model.

And because I decided to work with BERT, we can use a framework like PyTorch.

Anaconda Environment and Libraries installed, now what?

After you have successfully installed all your toys (speaking about Anaconda and all the necessary Libraries) it’s time to launch the Environment.

Jupyter Notebook Explanation

To do so, we need to launch Jupyter Notebook. What the heck is that now? Okay, in short, let me try to explain Jupyter Notebook to you. What it actually does, what it is, and used for.

Jupyter Notebook is like a special book where you can write stories with a magic pen. But it’s not just any stories; it’s stories for your computer. You can write down instructions for your computer, like ‘Draw a smiley face’ or ‘Tell me a joke.’

Jupyter Notebook
Train an AI Model Beginners’ Guide

Jupyter Notebook knows how to speak the computer’s language, like Python. So, you write your computer stories using Python words. Then, the computer reads your stories and does what you ask. It’s like having a secret conversation with your computer!

For example, you can tell Jupyter Notebook, ‘Add 2 and 3,’ and it will tell you the answer: ‘It’s 5!’ It’s a fun way to tell your computer what to do and make it your computer friend!”

Can I say that the Jupyter Notebook itself is basically used to write code with a program language like Python?

Yes, you can say that! Jupyter Notebook is indeed used to write and run code, especially with program languages like Python. It’s like a special notebook where you write down instructions for your computer using Python or other languages. Then, the computer understands those instructions and does what you ask.

Can I compare Jupyter Notebook with a Programm Editor, like Notepad++

If you are familir with writing any other code, for example PhP, Perl, C++, LUA, etc. you might be more familiar with Program Editors, like Notepad++.

so basically Yes, you can compare Jupyter Notebook to a code editor like Notepad++. Both tools are used for writing and working with code, but there are some important differences:

  • Jupyter Notebook is interactive and allows you to run code step by step. It’s often used for data analysis, data science, and creating documents that combine code, text, and visualizations.
  • Notepad++ is a text editor designed primarily for writing and editing code. It’s great for programming but doesn’t have the interactive features of Jupyter Notebook.

So, while they both help you work with code, Jupyter Notebook is more interactive and versatile, while Notepad++ is focused on code editing.

Jupyter Notebook Example

Let me give you an example. We’ll use a Jupyter Notebook in our New Created Anaconda Environment to do some basic math.

  1. Open Jupyter Notebook: Think of this like opening your special notebook on your computer.
  2. Create a New Page: This is where you write your story or do math. It’s like a new page in your notebook.
  3. Write a Math Problem:
    • Imagine you want to add two numbers, like 3 and 4.
    • You write down the problem: 3 + 4.
  4. Ask the Computer:
    • You ask your computer, “What’s 3 + 4?”
  5. Get the Answer:
    • The computer thinks for a moment and tells you the answer: “It’s 7!”

The thinking was done with Python. That’s the program language we installed for our Anaconda Environment. Let’s not mix up a Program Language with a Language Model. Please read for that my clarification and explanation about the differences between Program Languages and Language Models. We don’t want to mix Apples with Bananas, right?

# This is where you write your math problem
problem = 3 + 4

# Ask the computer and get the answer

Connecting Jupyter Notebook

Now let’s check this simple code within your own Jupyter Notebook. In order to get this done, we need to install The Jupyter Notebook.

Connecting Jupyter Notebook
Jupyter Notebook Installation

First of all, if the Jupyter Notebook is not installed yet, simply click the Install Button to install that thing.

Launching Jupyter Notebook in Anaconda

Once installed, the Button is changing, and you can now LAUNCH Jupyter Notebook. When you do that, make sure you have your current Environment. selected.

After the launch, your Browser will be fired up. And you will see a website pointing to your localhost. That’s where you can now Create a New Notebook, see screenshot below.

Launching Jupyter Notebook in Anaconda
Jupyter Notebook Launcher

Create a New Notebook:

To create a new Jupyter Notebook, click the “New” button on the right-hand side of the Jupyter dashboard, and then select “Python 3” (or the Python version you want to use). This will open a new notebook for you to work in.

Once this is done, you successfully create a new Jupyter Notebook. Rename it to your likings, in my case I renamed it to My AI Clone, running with the Python 3 Kernel.

Writing and running code examples

Writing and running code examples in Jupyter Notebook
Jupyter Notebook UI
  1. Using Jupyter Notebook:
    • In your new notebook, you can create code cells and markdown cells. Code cells are where you can write and run Python code, while markdown cells are for adding explanations or text.
    • To run a code cell, select it and press “Shift+Enter” or click the “Run” button in the toolbar.
  2. Saving Your Work:
    • You can save your Jupyter Notebook by clicking the floppy disk icon (or “File” > “Save and Checkpoint”). It will be saved with a .ipynb file extension.

Now let’s go back to our simple example. And let’s add the following code again to our Jupyter Notebook Editor.

# This is where you write your math problem
problem = 3 + 4

# Ask the computer and get the answer

Now this is it for the beginning and the start. Now you have all the essentials, and your Anaconda Environment Setup, including the Jupyter Notebook. We got almost everything we need to start to train our own AI Model. However, there is of course one MAJOR ELEMENT missing.

What Language Model are we going to use to train our AI Model?

I mentioned it already a bit earlier, that I decided to use BERT as my language model for training my own AI. The reason for that simplified: Because this language model is entirely free. By free I mean, you will not be charged for using the language model at all, and it’s also an open-source language model free to use from the licensing perspective of view.

Please read my comprehensive blog post about the available different language models, my comparison and my personal statements why I decided to use BERT for this project.

BERT is a language model, that needs to be installed in Anaconda like any other language model.

BERT Language Model to train our AI Model
How To Train Your Own AI Model

Installing BERT in Anaconda is a bit complex, and because of that I recommend to read my blog post that guides you with all the details step-by-step through the installation process of BERT with Anaconda.

For a quick overview, this is a short and super simplified step-by-step guide how BERT will be installed with Anaconda.

Step 1: Open Your Special Notebook

  • Imagine Anaconda as your special notebook where you write magic spells for your computer.

Step 2: Get a Magic Wand for Language (BERT)

  • BERT is like a magic wand for talking with your computer in a smart way.

Step 3: Connect the Magic Wand (Install BERT)

  • You need to connect the magic wand to your special notebook (Anaconda). Here’s how:
    • Open a special window in your notebook, like opening a secret door.
    • In that window, type the spell (command) “pip install transformers.”
    • Press “Enter,” and the magic wand (BERT) is now connected.

Step 4: Train Your AI Model

  • Now you can use BERT’s magic wand to teach your computer new things. You can write stories, answer questions, and have fun adventures with your computer!

Remember, it’s a bit more complex than this in real life, but this simple guide gives you an idea of what’s happening when you install BERT in Anaconda.

Now we came literally to an end for this documentation, which hopefully explained to you how to get started using Anaconda and Python. For better clarification, about all the different terms I was using in my blog post, I recommend reading my article about the Basics and Fundamentals of Training your own AI Model.

Creating your AI Model

As a reminder, when creating your AI Model, you should have a clear understanding of what you want to do with your AI Model.

  1. Define Your Goal: Decide what you want your AI model to do. Do you want it to answer questions, recognize pictures, or translate languages?
  2. Collect Data: Gather lots of information that your AI model will learn from. For example, if you want it to recognize cats and dogs, get pictures of cats and dogs.
  3. Prepare Your Data: Clean up the information and make it easy for your AI model to understand. It’s like organizing your toys neatly.
  4. Choose a Model: Pick a machine learning model (like Naive Bayes or a neural network) that fits your goal.
  5. Train Your Model: Teach your model by showing it the data. For example, show it cat pictures and say, “This is a cat.” Your model learns to tell cats from dogs.
  6. Test Your Model: Give it new information to see if it works. If you show it a new cat picture, it should say, “That’s a cat!”
  7. Improve Your Model: If it makes mistakes, give it more examples to learn from. Practice makes it better!

Creating your AI model is like teaching a pet new tricks. With time and practice, your AI model becomes smarter and can do amazing things!

Other useful resources about training your own AI Model

There are many resources available to help you learn about AI, understanding machine learning and how to train your own models. Here are a few examples:

These platforms provide access to a variety of tools and services that can help you train and deploy AI models.

Scroll to Top