{ "cells": [ { "cell_type": "markdown", "id": "9cb10ea7-ba09-44b5-b8f5-16164464afc9", "metadata": {}, "source": [ "# **Lecture 6: Examples for logistical Regression**\n", "\n", "**Two problems related to Logistical regression demonstrated**\n", "- Logistical classifier\n", "- Logistical regression" ] }, { "cell_type": "markdown", "id": "d0e26c6d-aa8e-49b4-9f79-2b9ede3e72e5", "metadata": {}, "source": [ "## **Part I: logistic classification**" ] }, { "cell_type": "code", "execution_count": 1, "id": "099644bb-883e-402e-9503-ddacd42eacb5", "metadata": {}, "outputs": [], "source": [ "# Code source: Gaël Varoquaux\n", "# Modified for documentation by Jaques Grobler\n", "# License: BSD 3 clause\n", "\n", "import matplotlib.pyplot as plt\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn import datasets\n", "from sklearn.inspection import DecisionBoundaryDisplay" ] }, { "cell_type": "markdown", "id": "c64a8687-4610-4202-a37d-a9b4d64e8e45", "metadata": {}, "source": [ "### 1.1, Import some data to play with" ] }, { "cell_type": "code", "execution_count": 2, "id": "ecdbdf12-dc29-4c06-92d9-d8f413f808dc", "metadata": {}, "outputs": [], "source": [ "# import some data to play with\n", "iris = datasets.load_iris()\n", "X = iris.data[:, :2] # we only take the first two features.\n", "Y = iris.target" ] }, { "cell_type": "markdown", "id": "f8b51501-19d5-4835-b7a8-bb73f0a678e6", "metadata": {}, "source": [ "### 1.2, Create an instance of Logistic Regression Classifier and fit the data." ] }, { "cell_type": "code", "execution_count": 6, "id": "6b98424d-ab84-4089-a477-efa873e56dc2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
LogisticRegression(C=100000.0)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LogisticRegression(C=100000.0)