{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "xPKpZHvt_xgq" }, "source": [ "# Machine Learning\n", "\n", "\n", "* Machine learning is a subset of artificial intelligence (AI) that focuses on enabling computers to learn from data and make predictions or decisions without being explicitly programmed. In traditional programming, developers write code to provide instructions to computers on how to perform specific tasks. However, in machine learning, instead of programming explicit instructions, algorithms are trained on large datasets to recognize patterns and make predictions or decisions based on that data.\n", "* Types of Machine Learning:\n", " \n", "\n", "1. Supervised Learning: Learning from labeled data, where the computer is trained on input-output pairs. Predicting whether a given email is spam or not spam based on its content and whether it was marked as spam by the user.\n", "2. Unsupervised Learning: Finding patterns and structures in data without explicit supervision. Sorting different types of fruits into groups based on their similarities in size, color, and texture.\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "id": "Fj-HaH5PBiE3" }, "source": [ "### Linear Regression\n", "Linear regression is a statistical method used to model the relationship between two variables, typically denoted as X and Y. It assumes that there is a linear relationship between the independent variable X and the dependent variable Y.\n", "\n", "Example: Predicting Exam Scores\n", "Let's consider an example where we want to predict students' exam scores\n", "Y based on the number of hours they study X. We'll assume that there is a linear relationship between study hours and exam scores.\n", "\n", "Suppose our model equation is Y=5X+10.\n", "If a student studies for 6 hours(X = 6), we can predict their exam score using the equation: Y = 5(6) + 10 = 40" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "xRKsg7uiDyEB" }, "outputs": [], "source": [ "# importing library\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from sklearn.linear_model import LinearRegression" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "cbfhyR34GMBw", "outputId": "cbc27605-f2a7-401a-d176-90a53a14d7b9" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Mounted at /content/drive\n" ] } ], "source": [ "from google.colab import drive\n", "drive.mount('/content/drive')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "id": "vBEd9zFGD4qC" }, "outputs": [], "source": [ "# Reading the .csv file\n", "data = pd.read_csv('/content/drive/MyDrive/MASHDEMY_AI_Summer Camp/LEVEL2_ML/scores.csv')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 206 }, "id": "KHtyAtCSGftV", "outputId": "2f6bcab8-c230-485d-ec84-2d68ce78468b" }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " Hours Score\n", "0 8 90\n", "1 8 99\n", "2 9 100\n", "3 4 10\n", "4 5 23" ], "text/html": [ "\n", "
| \n", " | Hours | \n", "Score | \n", "
|---|---|---|
| 0 | \n", "8 | \n", "90 | \n", "
| 1 | \n", "8 | \n", "99 | \n", "
| 2 | \n", "9 | \n", "100 | \n", "
| 3 | \n", "4 | \n", "10 | \n", "
| 4 | \n", "5 | \n", "23 | \n", "
LinearRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LinearRegression()
LinearRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LinearRegression()