Byte-Sized AI: A Journey of a Thousand Iterations
Documenting my adventures in Machine Learning and AI, one byte at a time
I am a self-taught Software developer from Nigeria.
This week, I embarked on a journey to explore machine learning using Python. I started with a brief introduction to machine learning, its applications, and the difference between supervised and unsupervised learning. I also got an overview of essential libraries and tools I will be working with along the way like jupyter notebook, numpy, scipy, pandas, matplotlib etc
My first task was to predict the species of an iris flower based on its physical measurements. I used the Iris dataset, which consists of measurements annotated by an expert with the correct species, making this a supervised learning task. The task was a three-class classification problem, where I had to classify the iris flower into one of the three species: setosa, versicolor, or virginica.
Key Takeaways:
Supervised Learning: I learned that supervised learning involves training a model on labeled data to make predictions on new, unseen data.
Classification Problem: I got to understand that my task was a three-class classification problem, where I had to classify the iris flower into one of the three species.
Iris Dataset: I worked with the Iris dataset, which consists of two NumPy arrays: one containing the data (X) and one containing the correct outputs (y).
Training and Test Sets: I split my dataset into a training set and a test set to evaluate the performance of my model.
k-Nearest Neighbors (k-NN) Algorithm: I used the k-NN algorithm to classify new data points based on their closest neighbors in the training set.
Model Evaluation: I evaluated my model using the accuracy score, which gave me an idea of how well my model generalizes to new data.
Code summary:
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
# Load Iris dataset
iris = load_iris()
X = iris.data
y = iris.target
# Split data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Instantiate k-NN classifier
knn = KNeighborsClassifier(n_neighbors=1)
# Train the model
knn.fit(X_train, y_train)
# Evaluate the model
accuracy = knn.score(X_test, y_test)
print("Accuracy:", accuracy)
Overall, I got a general introduction to machine learning with Python and built a simple classification model using the k-NN algorithm.

