{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from sklearn import linear_model\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "\n", "np.random.seed(1220)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# 生成模型数据\n", "size = 10000\n", "x = np.random.normal(size=size)\n", "y = (x > 0).astype(np.float64)\n", "x *= 1.5\n", "x += 0.5 * np.random.normal(size=size)\n", "x = x[:, np.newaxis]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
LinearRegression()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LinearRegression()