{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
Введение в машинное обучение.
\n", "Вводятся базовые элементы пакета линейной алгебры (Numpy) относфщейся к питону (Python версии 3.xx). Конкретно речь идет о алгебре и, соотвествено, линейной регресии.\n", "Последнее, в частности, используется для ввода ключевых понятий из машинного обучения: выборка, обучающее множество, тестовое/валидационное множество, поиск \"оптимального\" решения и регуляризация. Уровни значимости (F-статистика) при построении регрессий (statmodels). \n", "
\n", "\n", "Это предварительная версия! Любые замечания приветствуются.
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Отрисовка кривой" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([10.05883074, 17.73304573, 12.71185369, 15.44752132, 12.49656279])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Для начала случайно сгенерируем точки в которых будет вычислена функция.\n", "np.random.uniform(10, 20, 5) # Создаем матрицу равномерных распределений. Первые два числа казывают диапазон." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "x = np.random.uniform( 3, 10, 10 ) # 10 точек на отрезке [3, 10]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([6.65771569, 6.50170589, 3.77197208, 9.43421992, 9.20279068,\n", " 8.63828662, 7.2352993 , 4.97128899, 3.64077699, 7.46958444])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(10,)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x.shape # Это действительно массив из 10 чисел." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "y = x * 2 - 15 # Вычисляем значение в каждой из точек. Функция линейная." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([-1.68456862, -1.99658821, -7.45605585, 3.86843985, 3.40558136,\n", " 2.27657325, -0.52940139, -5.05742203, -7.71844602, -0.06083113])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[