Machine Learning (Part 4)

Neil HaddleyJune 8, 2022

Colab

Colab is Google's implementation of Jupyter Notebooks.

A Colab consists of text comments and code

NumPy

NumPy is a Python library for creating and manipulating vectors and matrices.

import numpy as np

import numpy as np

np.array([...])

np.array([...])

np.array([[...],[...],...,[...]]

np.array([[...],[...],...,[...]]

a sequence from 5 to 11

a sequence from 5 to 11

6 random values between 50 and 100

6 random values between 50 and 100

5 random floating point values between 0 and 1

5 random floating point values between 0 and 1

feature and label

feature and label

adding noise

adding noise

Pandas

Pandas DataFrames are similar to spreadsheets. DataFrames have columns and rows.

import numpy and pandas

import numpy and pandas

pd.DataFrame(data=<data cell values>, columns=<column names>)

pd.DataFrame(data=<data cell values>, columns=<column names>)

<dataframe>["<new column name>"] = <dataframe>["<existing column name>"] + <constant>

<dataframe>["<new column name>"] = <dataframe>["<existing column name>"] + <constant>

<dataframe>[<start index>,<end index + 1>]

<dataframe>[<start index>,<end index + 1>]

<dataframe>.copy()

<dataframe>.copy()