<jupyter_start><jupyter_text>Vertical Line Test  1.1 Create two graphs, one that passes the vertical line test and one that does not.<jupyter_code># This graph passes the vertical line test.

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-10,10,100)
y = 2*x+1
plt.plot(x, y, '-r', label='y=2x+1')

plt.xlabel('x')
plt.ylabel('y')
plt.legend(loc='upper left')
plt.grid()
plt.show()

# This graph does not pass the vertical line test.

t = np.arange(0,2*np.pi, 0.1)
x = 16*np.sin(t)**3
y = 13*np.cos(t)-5*np.cos(2*t)-2*np.cos(3*t)-np.cos(4*t)
plt.plot(x,y)
plt.show()<jupyter_output><empty_output><jupyter_text>1.2 Why are graphs that don't pass the vertical line test not considered "functions?" Functions are mappings from an input to a single input. Graphs that fail the vertical line test have two values for an input, and are therefore not functions.  Functions as Relations  2.1 Which of the following relations are functions? Why?\begin{align}\text{Relation 1: } \{(1, 2), (3, 2), (1, 3)\}\\\text{Relation 2: } \{(1, 3), (2, 3), (6, 7)\}\\\text{Relation 3: } \{(9, 4), (2, 1), (9, 6)\}\\\text{Relation 4: } \{(6, 2), (8, 3), (6, 4)\}\\\text{Relation 5: } \{(2, 6), (2, 7), (2, 4)\}\end{align} Relation 1 and Relation 2 are functions. Relations 3-5 map a single input to multiple outputs, and therefore are not functions.  Functions as a mapping between dimensions  3.1 for the following functions what is the dimensionality of the domain (input) and codomain (range/output)?\begin{align}m(𝑥_1,𝑥_2,𝑥_3)=(x_1+x_2, x_1+x_3, x_2+x_3)\\n(𝑥_1,𝑥_2,𝑥_3,𝑥_4)=(x_2^2 + x_3, x_2x_4)\end{align} *   The domain of m is 3-dimensional, and the codomain is 3-dimensional.*   The domain of n is 4-dimensional, and the codomain is 2-dimensional.  3.2 Do you think it's possible to create a function that maps from a lower dimensional space to a higher dimensional space? If so, provide an example. Yes, it is possible to create such a function. For example:\begin{align}f(𝑥_1,𝑥_2)=(x_1, x_2, 1)\\\end{align}  Vector Transformations  4.1 Plug the corresponding unit vectors into each function. Use the output vectors to create a transformation matrix.\begin{align}p(\begin{bmatrix}x_1 \\ x_2 \end{bmatrix}) = \begin{bmatrix} x_1 + 3x_2 \\2 x_2 - x_1 \\  \end{bmatrix}\\\\q(\begin{bmatrix}x_1 \\ x_2 \\ x_3\end{bmatrix}) = \begin{bmatrix} 4x_1 + x_2 + 2x_3 \\2 x_2 - x_1 + 3x_3 \\ 5x_1 - 2x_3 + x_2  \end{bmatrix}\end{align} \begin{align}p(\begin{bmatrix}1 \\ 0 \end{bmatrix}) = \begin{bmatrix} 1 \\ -1 \\  \end{bmatrix}\\p(\begin{bmatrix}0 \\ 1 \end{bmatrix}) = \begin{bmatrix} 3 \\ 2 \\  \end{bmatrix}\\\end{align} \begin{align}\begin{bmatrix} 1  & 3 \\-1 & 2 \\  \end{bmatrix}\end{align} \begin{align}\\q(\begin{bmatrix}1 \\ 0 \\ 0\end{bmatrix}) = \begin{bmatrix} 4 \\-1 \\ 5  \end{bmatrix}\\q(\begin{bmatrix}0 \\ 1 \\ 0\end{bmatrix}) = \begin{bmatrix} 1 \\2 \\ 1  \end{bmatrix}\\q(\begin{bmatrix}0 \\ 0 \\ 1\end{bmatrix}) = \begin{bmatrix} 2 \\3 \\ -2  \end{bmatrix}\end{align} \begin{align}\begin{bmatrix} 4 & 1 & 2 \\-1 & 2 & 3 \\ 5 & 1 & -2  \end{bmatrix}\end{align}  4.2 Verify that your transformation matrices are correct by choosing an input matrix and calculating the result both via the traditional functions above and also via vector-matrix multiplication.<jupyter_code># Testing p with vector [3,4]. Via the traditional functions:

t1 = np.array([[3],[4]])
p = np.array([
    t1[0]+(3*t1[1]), 
    (2*t1[1]-t1[0])
])
p
# Via vector-matrix multiplication:

tmat_1 = np.array([
    [1,3],
    [-1,2]
])
np.dot(tmat_1, t1)
# Testing q with vector [2,3,4]. Via the traditional functions:

t2 = np.array([[2],[3],[4]])
q = np.array([
    4*t2[0] + t2[1] + 2*t2[2],
    2*t2[1] - t2[0] + 3*t2[2],
    5*t2[0] - 2*t2[2] + t2[1]
])
q
# Via vector-matrix multiplication:

tmat_2 = np.array([
    [4,1,2],
    [-1,2,3],
    [5,1,-2]
])
np.dot(tmat_2, t2)<jupyter_output><empty_output><jupyter_text>Eigenvalues and Eigenvectors  5.1 In your own words, give an explanation for the intuition behind eigenvalues and eigenvectors. The eigenvectors for a linear transformation are the vectors that don't get knocked off of their span during the transformation. They are scaled by their eigenvalues.  The Curse of Dimensionality  6.1 What are some of the challenges of working with high dimensional spaces?*   Each time a feature is added, it exponentially increases the computational workload*   The volume of the space rapidly increases with each additional feature, meaning that available data will become sparse. This is a problem for various machine learning algorithms that are sensitive to distance.* A high number of dimensions relative to observations risks overfitting.  6.2 What is the rule of thumb for how many observations you should have compared to parameters in your model?*   The rule of thumb is that you should have 5 times more observations than parameters in your model.  Principal Component Analysis  7.1 Load the UCI Machine Learning Repository's [Iris Dataset](https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/d546eaee765268bf2f487608c537c05e22e4b221/iris.csv) and use PCA to isolate the dataset's first and second principal components and plot them on a graph.<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.143917761279269, 'fraction_numerical': 0.054254711593375214, 'mean_word_length': 4.076328502415459, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '90319', 'license': 'MIT', 'n_tokens_mistral': 2018, 'n_tokens_neox': 1833, 'n_words': 626, 'path': 'Stephen_Sinclair_High_Dimensional_Data_Assignment.ipynb', 'repo_name': 'SMSinclair/DS-Unit-1-Sprint-4-Statistical-Tests-and-Experiments', 'size': '5253'}