Laboratory exercises for the Artificial Intelligence course in the BS Computer Science program at the University of Gujrat. This repository contains practical implementations of AI and Machine Learning concepts using Python and Jupyter Notebooks.
The exercises introduce data preparation, numerical computing, data visualization, supervised and unsupervised learning, model evaluation, and introductory neural networks. Each notebook is designed to combine explanations with executable experiments, allowing students to modify inputs and observe the results.
The following example loads the Iris dataset, trains a classifier, and evaluates its accuracy:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.neighbors import KNeighborsClassifier
# Load the dataset into a Pandas DataFrame
iris = load_iris()
data = pd.DataFrame(iris.data, columns=iris.feature_names)
data["species"] = iris.target
# NumPy arrays are useful for efficient numerical operations
X = data[iris.feature_names].to_numpy()
y = data["species"].to_numpy()
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, random_state=42, stratify=y
)
model = KNeighborsClassifier(n_neighbors=3)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
print(f"Accuracy: {accuracy_score(y_test, predictions):.2%}")
# Visualize two features with Matplotlib
plt.scatter(X[:, 0], X[:, 1], c=y, cmap="viridis")
plt.xlabel("Sepal length")
plt.ylabel("Sepal width")
plt.title("Iris dataset")
plt.show()Jupyter Notebooks contain Markdown explanations, Python code cells, charts, and output in one interactive document. Install the common dependencies and launch Jupyter with:
python -m pip install numpy pandas matplotlib scikit-learn tensorflow jupyter
jupyter notebookSelect a notebook from the browser, run cells from top to bottom, and experiment with the datasets, parameters, and visualizations. For reproducible results, record the required packages, use fixed random seeds where appropriate, and explain the inputs and outputs of each exercise.
- Use Python syntax and scientific-computing tools for AI experiments.
- Clean, inspect, and visualize datasets with Pandas and Matplotlib.
- Implement and evaluate machine-learning models with Scikit-learn.
- Build a foundation for neural-network experiments with TensorFlow.
- Interpret results and document experiments in Jupyter Notebooks.
AiLabs is a workspace for experimenting with and building AI-powered applications. It is intended to collect prototypes, research, and reusable components for working with modern artificial intelligence tools.
Organize the repository by experiment or application. Each project should include its own documentation, dependencies, configuration, and usage instructions where applicable.
- Clone or download the repository.
- Open the project you want to run.
- Follow that project's setup instructions and install its dependencies.
- Configure any required environment variables, such as API keys, in a local
.envfile. - Run the project's documented development or start command.
- Keep experiments self-contained and clearly named.
- Document setup steps, expected inputs, and outputs.
- Never commit secrets, credentials, or private data.
- Add tests or evaluation examples for reusable functionality.
This repository is under active development. Individual projects may be experimental and subject to change.