Supervised Learning:-

Supervised learning is a type of machine learning algorithm that uses labelled data to train a model to make accurate predictions. Linear regression is a supervised learning algorithm that is used to predict continuous values. It works by fitting a linear equation to a dataset of inputs and outputs. The linear equation consists of a set of weights and a bias term, which are adjusted to minimize the error between the predicted output and the actual output. The algorithm can then be used to make predictions for new data points.

The training data will consist of inputs paired with the correct outputs in supervised learning. This data can come from a variety of sources, such as labeled images, texts, and audio recordings. The data will be used to train a model to recognize patterns in the input and make predictions about the correct output. The model will then be tested on a set of test data containing inputs the model has not seen before. If the model performs well on the test data, then it can be used to make predictions on new data. A supervised learning algorithm can be represented as:

Y = f(x)

Here, Y is the predicted output that is determined by a mapping function that assigns a class to an input value x.

Supervised learning can be divided into two subcategories viz. Classification and regression.

Classification:

Classification algorithms are used to classify data into groups or categories. Examples include logistic regression, decision trees, Naive Bayes, k-nearest neighbour, support vector machines, etc.

Classification

  1. Linear Classifiers
  2. Support Vector Machines
  3. Decision Trees
  4. K-Nearest Neighbour
  5. Random Forest

Regression:

Regression algorithms are used to predict a continuous variable from the given data. There are many different types of regression algorithms. The three most common regressions are linear, polynomial, and logistic regression.

Simple Regression Example: First we will import the needed libraries and then create a random dataset with increasing output.

Guiding Steps for Linear Regression

Step 1. Import dependent libraries.

Copy to Clipboard

Step 2. Load sample data in a text file format with Numpy array.

Copy to Clipboard

Step 3. Convert data into a 2D array.

Copy to Clipboard

Step 4. Split the data into train and test data.

Copy to Clipboard

Step 5. Create a linear regression object and train it using the training data:

Copy to Clipboard

Step 6. Predict the output for the testing dataset using the training model:

Copy to Clipboard

Step 7. Check the performance of the model.

Copy to Clipboard

Output:

Linear Regression

In conclusion, supervised learning is a powerful tool for creating highly accurate predictive models. With careful data preparation and feature engineering, supervised learning models can be used to solve a wide range of tasks. By taking the time to understand the principles of supervised learning and apply them to your own data, you can create powerful predictive models that can help you to gain valuable insights.