Introduction to Machine Learning

Machine Learning Fundamentals with Python

2 min read

Published Nov 16 2025


10
0
0
0

ClusteringImagesK-MeansLinear RegressionLogistic RegressionMachine LearningNeural NetworksNLPNumPyPythonRandom Forestsscikit-learnSupervised LearningUnsupervised Learning

What is Machine Learning?

Machine Learning (ML) is a way of teaching computers to find patterns in data and make predictions or decisions without being explicitly programmed for every task.
Instead of hard-coding rules, we give the computer examples (data) and let it learn from them.



Examples of ML applications:

  • Predicting house prices based on past sales
  • Classifying emails as spam or not spam
  • Recommending movies or products
  • Recognising objects in images
  • Translating text from one language to another

At its core, ML involves training a model using data, and then using that model to make predictions on new, unseen data.






The Basic ML Workflow

  1. Collect data — gather examples of the problem you’re solving.
  2. Prepare data — clean, organise, and transform data into a usable form.
  3. Train a model — fit an algorithm to your training data.
  4. Evaluate performance — test how well the model performs on new data.
  5. Deploy and improve — use the model in real applications and retrain as needed.





Example: Teaching a Model to Predict House Prices

Suppose we have data about houses, each example includes:

  • size_in_sqft
  • number_of_bedrooms
  • distance_to_city_center
  • price

Our goal: predict price based on the other features.


Simple Python example:

import numpy as np
from sklearn.linear_model import LinearRegression

# Example data (in real life this comes from a dataset)
# size, bedrooms, distance_from_city_center
X = np.array([
    [1000, 2, 5],
    [1500, 3, 3],
    [800, 2, 7],
    [1200, 3, 4],
    [2000, 4, 2]
])

# Prices (in thousands)
y = np.array([200, 300, 180, 250, 400])

# Create and train a simple linear regression model
model = LinearRegression()
model.fit(X, y)

# Predict price for a new house
new_house = np.array([[1300, 3, 3]])
predicted_price = model.predict(new_house)

print(f"Predicted price for new house: £{predicted_price[0]*1000:.2f}")

Explanation:

  • We created some small example data.
  • We used Scikit-learn’s LinearRegression model.
  • We trained the model (fit) and then predicted for a new example (predict).

This simple exercise captures the essence of ML — learn from data, then generalise to new cases.






Key Terms to Remember

  • Feature - An input variable (e.g., house size, number of rooms)
  • Label / Target - The value we want to predict (e.g., house price)
  • Training Data - Data used to teach the model
  • Testing Data - Data used to evaluate how well the model generalises
  • Model - The mathematical representation of what the computer has learned
© 2025 SimpleSteps.guide
AboutFAQPoliciesContact
Machine Learning Fundamentals with Python | Introduction to Machine Learning | SimpleSteps.guide