main #2
@@ -258,19 +258,21 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"name": "stdout",
|
||||||
"text/plain": [
|
"output_type": "stream",
|
||||||
"Matrix([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])"
|
"text": [
|
||||||
|
"Matrix([[0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])\n",
|
||||||
|
"Matrix([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]])\n",
|
||||||
|
"Matrix([[0.0, 0.0], [0.0, 0.0], [0.0, 1.0]])\n"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"execution_count": 8,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"A = Matrix.zeros(2, 3) # rows - columns\n",
|
"A = Matrix.zeros(2, 3) # rows - columns\n",
|
||||||
"A # each row is a vector of length 3"
|
"print(A) # each row is a vector of length 3\n",
|
||||||
|
"A[1, 2] = 1.0\n",
|
||||||
|
"print(A)\n",
|
||||||
|
"print(A.transpose())"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -311,7 +313,7 @@
|
|||||||
" X = Matrix.zeros(n_samples, n_features) # `Matrix.ones` is needed\n",
|
" X = Matrix.zeros(n_samples, n_features) # `Matrix.ones` is needed\n",
|
||||||
" for row in range(n_samples):\n",
|
" for row in range(n_samples):\n",
|
||||||
" for col in range(n_features):\n",
|
" for col in range(n_features):\n",
|
||||||
" X.data[row][col] = x_data[row] ** col\n",
|
" X[row, col] = x_data[row] ** col\n",
|
||||||
"\n",
|
"\n",
|
||||||
" return X"
|
" return X"
|
||||||
]
|
]
|
||||||
@@ -326,7 +328,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Matrix([[1, 0, 0, 0], [1, 1, 1, 1], [1, 2, 4, 8], [1, 3, 9, 27], [1, 4, 16, 64]])\n"
|
"Matrix([[1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0], [1.0, 2.0, 4.0, 8.0], [1.0, 3.0, 9.0, 27.0], [1.0, 4.0, 16.0, 64.0]])\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -378,7 +380,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"degree = 3\n",
|
"degree = 3\n",
|
||||||
"X_design = design_matrix_for_poly(xx.data, degree)"
|
"X_design = design_matrix_for_poly(xx, degree)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user