Introduction
In this tutorial, you'll learn how to set up and use a basic AI development environment using Python and popular AI libraries. This is the kind of foundational setup that might be used by developers working on AI projects like the one being planned in the Philippines. We'll walk through installing Python, setting up a virtual environment, and installing essential AI libraries that are commonly used in AI development.
Prerequisites
Before starting this tutorial, you should have:
- A computer running Windows, macOS, or Linux
- Basic understanding of using a command line or terminal
- Internet connection for downloading software
This tutorial assumes no prior AI experience, but some basic computer literacy is helpful.
Step 1: Install Python
Why:
Python is the most popular programming language for AI and machine learning because it's easy to learn and has many powerful libraries for data analysis and AI development.
How:
- Visit the official Python website at python.org/downloads
- Download the latest Python version (3.10 or higher recommended)
- Run the installer and make sure to check "Add Python to PATH" during installation
Verification: Open your command prompt or terminal and type:
python --version
You should see the version number of Python you just installed.
Step 2: Create a Virtual Environment
Why:
A virtual environment keeps your AI project files separate from other Python projects on your computer. This prevents conflicts between different versions of libraries.
How:
- Open your terminal or command prompt
- Navigate to where you want to create your AI project folder
- Create a new folder for your project:
mkdir ai_project
cd ai_project
- Create a virtual environment:
python -m venv ai_env
- Activate the virtual environment:
On Windows:
ai_env\Scripts\activate
On macOS and Linux:
source ai_env/bin/activate
You should see (ai_env) at the beginning of your command prompt, showing the environment is active.
Step 3: Install AI Libraries
Why:
These libraries are essential tools for AI development. NumPy handles mathematical operations, Pandas helps with data manipulation, and Scikit-learn provides machine learning algorithms.
How:
- With your virtual environment activated, install the required packages:
pip install numpy pandas scikit-learn matplotlib
This command installs several key libraries that form the foundation of most AI projects.
Step 4: Test Your Setup
Why:
Testing ensures all components are working correctly before starting more complex projects.
How:
- Create a new Python file named
test_ai.py:
import numpy as np
import pandas as pd
from sklearn import datasets
print("AI Environment Test")
print("NumPy version:", np.__version__)
print("Pandas version:", pd.__version__)
# Create a simple dataset
iris = datasets.load_iris()
print("Dataset shape:", iris.data.shape)
- Run the file:
python test_ai.py
If everything works correctly, you should see version numbers and dataset information printed to your screen.
Step 5: Create a Simple AI Example
Why:
This practical example demonstrates how AI libraries work together to solve a basic problem - classifying flower types based on measurements.
How:
- Create a new file called
simple_ai.py:
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn import datasets
# Load the iris dataset
iris = datasets.load_iris()
X = iris.data # Features: sepal length, sepal width, petal length, petal width
y = iris.target # Target: flower type
# Split data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Create and train the model
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)
# Make predictions
predictions = model.predict(X_test)
# Calculate accuracy
accuracy = accuracy_score(y_test, predictions)
print(f"Model Accuracy: {accuracy:.2f}")
# Test with a new sample
new_sample = [[5.1, 3.5, 1.4, 0.2]] # Sepal length, width, petal length, petal width
prediction = model.predict(new_sample)
print(f"Prediction for new sample: {iris.target_names[prediction][0]}")
- Run the file:
python simple_ai.py
You should see output showing the accuracy of your model and a prediction for a new flower sample.
Summary
Congratulations! You've successfully set up an AI development environment. You installed Python, created a virtual environment to keep your project isolated, and installed essential AI libraries. You also ran a simple AI example that demonstrated how to train a model and make predictions. This basic setup is what developers use when working on AI projects, similar to the kind of infrastructure being developed in the Philippines. As you continue learning, you can add more advanced libraries like TensorFlow or PyTorch for deep learning projects.



