{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First we'll generate a random matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#Number of columns (features)\n",
"K = 5\n",
"\n",
"#Number of records\n",
"N = 1000\n",
"\n",
"#Generate an NxK matrix of uniform random variables\n",
"X = #Student: generate a uniform random matrix here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's peak at our data to confirm it looks as we expect it"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#Student - Put in a command to view the first 100 rows\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"#Student - put in a command to see the dimensions of X\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This exercise is about designing a scoring function for a logistic regression. As we are not concerned with fitting a model to data, we can just make up a logistic regression.
\n",
"\n",
"For quick intro, the Logistic Regression takes the form of $\\hat{Y} = f(x * \\beta^T)$, where $x$ is the $1xK$ vector of features and $\\beta$ is the $1xK$ vector of weights. The function $f$, called a 'link' function, is the inverse logit:
\n",
"\n",
"