Machine Learning
Machine learning is a way to build software by fitting models to examples instead of writing every rule by hand. A model sees data, optimizes an objective, and generalizes the learned pattern to new inputs.
What is semi-supervised learning?
Semi supervised learning is a type of machine learning that trains a model using a combination of labeled data and unlabeled data . It is useful when collecting raw data is easy, but manually labeling every example is expensive, slow, or difficult. Simple example Suppose you have 100,000 images, but only 5,000 of them have labels such as: A semi supervised approach can use the 5,000 labeled images together with the much larger set of unlabeled images to improve the model. Why use unlabeled data? Labeled examples tell the model what the correct outputs should be, while unlabeled examples can help the model learn the structure or distribution of the input data. A simplified view is: How it differs from related approaches Supervised learning mainly learns from labeled data. Unsupervised learning works without target labels. Semi supervised learning combines both labeled and unlabeled data. Common semi supervised techniques include methods such as pseudo labeling and consistency based training, but those techniques are separate implementation topics. In short, semi supervised learning uses a small amount of labeled data together with a larger amount of unlabeled data to learn effectively when complete labeling is impractical.
What is reinforcement learning?
Reinforcement learning is a type of machine learning in which an agent learns how to act by interacting with an environment and receiving rewards or penalties for its actions. Instead of learning from a fixed set of correct labels, the agent learns through trial and error. Core idea A reinforcement learning system usually involves: Agent: the learner or decision maker Environment: the world the agent interacts with State: the current situation the agent observes Action: a choice the agent can make Reward: feedback that indicates how good or bad an action was The interaction can be simplified as: Over many interactions, the agent learns a policy , which is a strategy for choosing actions in different situations. Simple example Imagine an agent learning to play a game. It observes the current game state, chooses a move, and receives feedback based on what happens. Actions that help it win may produce positive rewards, while poor actions may lead to lower rewards or penalties. By repeating this process, the agent learns which actions tend to produce better long term outcomes. What makes reinforcement learning different? Reinforcement learning focuses on sequential decisions . An action may affect not only the immediate reward but also future situations and future rewards. The goal is therefore usually to maximize the total reward accumulated over time, not simply to make one correct prediction. In short, reinforcement learning teaches an agent to make better decisions through interaction, feedback, and repeated experience.
What is the difference between supervised and unsupervised learning?
The main difference between supervised learning and unsupervised learning is whether the training data includes known target outputs. In supervised learning, the model learns from labeled examples. In unsupervised learning, the model works with unlabeled data and tries to discover structure or patterns on its own. Key differences Training data: Supervised learning uses labeled data, while unsupervised learning uses unlabeled data. Correct output: In supervised learning, the correct output is known during training. In unsupervised learning, no target output is provided. Main goal: Supervised learning learns to predict a known target. Unsupervised learning tries to discover hidden structure or patterns. Common tasks: Supervised learning is commonly used for classification and regression. Unsupervised learning is commonly used for clustering and dimensionality reduction. Example: Supervised learning can predict whether an email is spam, while unsupervised learning can group customers with similar behavior. Simple example Suppose we have customer data. With supervised learning, we might also know whether each customer churned: The model learns to predict churn for new customers. With unsupervised learning, we may have only the customer features and no churn labels: The model might identify groups of customers with similar purchasing or usage behavior. The key distinction Supervised learning learns a mapping from inputs to known outputs. Unsupervised learning looks for useful structure when no target output has been provided. In short, supervised learning learns from labeled data to make predictions, while unsupervised learning uses unlabeled data to discover patterns or structure.
What is a machine learning model?
A machine learning model is a learned mathematical or computational representation that takes input data and produces an output such as a prediction, score, category, or decision. Instead of containing only hand written rules, the model contains patterns learned from training data. Simple way to think about it A model acts like a function: For example, a house price model might receive: size of the house number of bedrooms location age of the property and produce: What does a model contain? What a model stores depends on the algorithm being used. For example: A linear model may store learned coefficients. A decision tree stores learned decision rules and split points. More complex models may contain many learned parameters that capture relationships in the data. These learned values determine how the model converts new inputs into outputs. Model vs algorithm A learning algorithm is the procedure used to learn from data. The model is the result produced after that learning process. A simple view is: Once trained, the model can be given new data and used to make predictions. In short, a machine learning model is the learned representation that uses patterns from data to convert new inputs into useful outputs.
What does it mean to train a machine learning model?
Training a machine learning model means using data to adjust the model so that it learns patterns that help it produce better predictions or decisions. During training, the model processes examples, makes predictions, compares those predictions with the desired outcome when one is available, and updates its internal parameters to reduce its errors. Simple example Suppose we want to train a model to predict house prices. The training data might contain examples such as: For each example, the model: receives the input features produces a predicted price compares the prediction with the actual price measures how wrong the prediction was adjusts its learned parameters to improve future predictions This process is repeated across many examples. What changes during training? The structure of the model may stay the same, but its learned parameters change. For example: a linear model updates its coefficients a decision tree learns useful split points other models adjust their own internal parameters according to their learning algorithm Training does not mean memorizing The goal is not simply to remember the training examples. A useful model should learn patterns that also work on new data it has not seen before. That ability is called generalization and is covered separately. In short, training is the process of using data to adjust a model's learned parameters so that it becomes better at performing its intended task.
What does it mean for a machine learning model to generalize?
Generalization means that a machine learning model performs well on new, unseen data that is similar to the data it was trained on. A model is useful when it learns underlying patterns rather than simply memorizing the training examples. Simple example Suppose a model is trained to predict house prices using historical data. If it performs well only on the houses it saw during training, it has not learned enough to be useful. If it can also make accurate predictions for new houses it has never seen before, the model is generalizing well. Training performance is not enough A model can achieve very low error on its training data and still perform poorly on new data. This often happens when the model learns details or noise that are specific to the training set instead of learning broader patterns. That problem is called overfitting and is covered separately. What good generalization looks like A model that generalizes well should: perform well on unseen validation or test data learn patterns that apply beyond individual training examples avoid depending too heavily on noise or accidental details in the training set Generalization does not mean a model will work equally well on completely different kinds of data. It usually assumes that future data is reasonably similar to the data used during development. In short, a machine learning model generalizes when what it learned from the training data also works well on new, unseen examples.
What is an observation or sample in machine learning?
An observation or sample in machine learning is one individual example in a dataset. It represents one unit that the model can learn from or make a prediction about. Simple example Suppose a dataset contains information about houses. One sample might look like this: This single house is one observation. What does a sample contain? A sample usually contains: Features: the input values that describe the example Target or label: the value the model is expected to predict, when the task is supervised For the house example: size, bedrooms, and age are features price is the target Samples form a dataset A dataset is made up of many observations: In tabular data, each row often represents one sample, while the columns represent features and possibly a target column. The terms observation , sample , example , and sometimes data point are often used to describe this same basic idea, although usage can vary slightly by context. In short, an observation or sample is one individual data example that contains the information a machine learning model uses for learning or prediction.
What is a feature in machine learning?
A feature in machine learning is an input variable or measurable property used by a model to make a prediction or decision. Features describe the characteristics of each observation in a dataset. Simple example Suppose we want to predict the price of a house. Possible features could include: size of the house number of bedrooms location age of the property distance from the city center The model uses these input values to learn patterns related to the house price. Features in a dataset In tabular data, features are often represented as columns. For example: Here: Size, Bedrooms, and Age are features Price is the target the model may be trying to predict Features can have different forms A feature may be: Numerical , such as age, income, temperature, or distance Categorical , such as city, product type, or payment method Binary , such as yes/no or true/false Derived , such as total purchases calculated from transaction history Before a model can use some features, they may need preprocessing or transformation. In short, a feature is a piece of input information that describes a sample and helps a machine learning model learn patterns and make predictions.
What is a target variable?
A target variable is the value that a supervised machine learning model is trained to predict. It represents the desired output associated with each training example. Simple example Suppose we want to predict house prices. Each sample might contain: house size number of bedrooms location age of the property actual house price Here, the first four values are features , while the actual house price is the target variable . Targets can take different forms A target variable may be: Numerical , such as house price, temperature, or sales amount Categorical , such as spam/not spam or approved/rejected Binary , when there are only two possible outcomes The type of target helps determine what kind of supervised learning problem is being solved. Numerical targets are commonly associated with regression, while categorical targets are commonly associated with classification. Target vs feature Features are the inputs used by the model. Target is the output the model is trying to learn to predict. In classification problems, the target is often also called a label . The concept of a label is covered separately. In short, the target variable is the outcome a supervised machine learning model learns to predict from the input features.
What is a label in machine learning?
A label in machine learning is the known output or category attached to a training example that a supervised model learns to predict. Labels provide the correct answer for the examples used during training. Simple example Suppose we are training a model to detect spam emails. Each email might have a label such as: Spam Not spam The model receives the email as input and learns to predict the correct label. Labels in classification The term label is used most often in classification problems, where the output belongs to a category. Examples include: cat, dog, or bird for image classification fraud or not fraud for transaction detection approved or rejected for an application Label vs target variable A target variable is the general output a supervised model tries to predict. A label usually refers to a known categorical target assigned to an example. In practice, the terms are sometimes used interchangeably, especially when discussing supervised learning. Labeled data A dataset is called labeled when its training examples include these known outputs. For example: Here, cat and dog are the labels. In short, a label is the known answer attached to a training example that tells a supervised model what output it should learn to predict.