Introduction to Pandas
Plotting Data
Getting Data
Chapter 1 | Intro to Pandas
import pandas as pd # importing the module
df = pd.DataFrame( # hard-coding a data-frame
[['Jan', -18, 2],
['Jul', 32, 18],
['Dec',-12, 7]],
index = [0,1,2], # index values
columns = ['month', 'lowest_temp', 'highest_temp']) # column names
print dfCode example for returning a Data frame
Chapter 1 | Python, class intro
Chapter 1 | Python, class intro
Chapter 1 | Intro to Pandas
Chapter 1 | Intro to Pandas
Chapter 1 | Intro to Pandas
print df['highest_temp']Chapter 2 | Plotting Data
Chapter 2 | Plotting Data
import numpy as np
import matplotlib.pyplot as plt
x = np.array([0, -3, 6, 4])
y = np.array([2, 4, 3, 1])
plt.scatter(x,y)
plt.savefig('/usercode/myfig')
plt.show()Chapter 2 | Plotting Data
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-5,5,50)
def y():
return x**2
plt.plot(x,y(x))
plt.savefig('/usercode/myfig')
plt.show()Chapter 2 | Plotting Data
import pandas as pd
import matplotlib.pyplot as plt
# Tracking height [m] of a young person
df = pd.DataFrame(
[[2018,160],
[2019,164],
[2020,168],
[2021,171],
[2022,173],
[2023,176],
[2024,178],
[2025,179],
[2026,180],
[2027,180]],
index = [0,1,2,3,4,5,6,7,8,9],
columns = ['year', 'height'])
plt.plot(df.year, df.height)
plt.savefig('/usercode/myfig')
plt.show()Chapter 3 | Getting Data
Chapter 3 | Getting Data
Chapter 3 | Getting Data
import pandas as pd
prices = pd.read_csv('bitCoinPrices2010To2018.csv')
df = DataFrame(prices)Chapter 3 | Getting Data
import pandas as pd
import requests
r = requests.get('https://api.coindesk.com/v1/bpi/historical/close.json?start=2013-01-01&end=2014-01-01')
df = pd.DataFrame(r.json())Chapter 4 | Processing and Graphing Data
Chapter 4 | Processing and Graphing Data
# Variation in velocity for a car on a given highway
plt.plot(df1.vel, df1.time, '-r') # Red plot
# Variation in velocity for a truck on a given highway
plt.plot(df2.vel, df2.time, '-b') # Blue plot
plt.xlabel('time (s)') # x-axis indicates time in seconds
plt.ylabel('velocity (m/s)') # y-axis indicates velocity in m/s
plt.title('Tracking velocity for a car and a truck on a highway')
plt.legend(['Car', 'Truck'])
plt.show()Example of more implementation with matplotlib
Methods for getting the speed at any given time
# printing the speed
# after 5 seconds
print pf1.vel[4]
# Printing highest
# speed reached
print pf1.max()
Chapter 5 |BitCoin price prediction
Chapter 5 |BitCoin price prediction
Chapter 5 |BitCoin price prediction
Chapter 5 |BitCoin price prediction
Convert a list to a Numpy array
import numpy as np
NewArray = np.asarray(list)Chapter 5 |BitCoin price prediction
Chapter 6 |Investment
Chapter 6 |Investment
def prepareDF(data):
x_normed = data/ data.max(axis=0)
return x_normed1 = Sell Bitcoins
0 = buy BitCoins
Chapter 6 |Investment
Training our Neural Network
def createTrain(dataset, array):
for i in range(len(dataset)-(len(dataset)//5)):
currentdata = dataset[i]['close']
previousdata= dataset[i-1]['close']
array.append([dataset[i]['close'], dataset[i]['volumeto'],
dataset[i]['volumefrom'],currentdata-previousdata])
NewArray = np.asarray(array)
return prepareDF(NewArray)Chapter 6 |Investment
Test input
def createTestInput(dataset, array):
length = 4*(len(dataset))//5
for i in range(len(dataset)-length):
currentdata = dataset[length+i]['close']
previousdata= dataset[length+i-1]['close']
array.append([dataset[i]['close'], dataset[i]['volumeto'],
dataset[i]['volumefrom'],currentdata-previousdata])
NewArray = np.asarray(array)
return prepareDF(NewArray)Chapter 6 |Investment
Chapter 1 | Basic Vector operations Data
Chapter 1 | Basic Vector operations Data
import numpy as np
# Making a vector
v = np.array([2,-3,1,0])Chapter 1 | Basic Vector operations Data
vT = np.transpose(v)Chapter 1 | Basic Matrix operations Data
| height | weight | vertical | sprint | |
|---|---|---|---|---|
| 1 | 196 | 98 | 40 | 6.4 |
| 2 | 205 | 124 | 34 | 6.7 |
| 3 | 198 | 115 | 36 | 6.6 |
| 4 | 192 | 107 | 38 | 6.3 |
| 6 | 208 | 127 | 35 | 6.7 |
List of data, i.e stats for a group of Basketball players
Can be represented as a matrix
Chapter 1 | Basic Matrix operations Data
import numpy as np
M = np.array([[1, 3, -2], [0, -2, 5], [3, 0, -1]])MT = np.transpose(M)Chapter 3 | Matrix-Vector operations
Chapter 3 | Matrix-Vector operations
2x2 Matrix
2x1 Vector
Output 2x1 vector
Chapter 3 | Matrix-Vector operations
Chapter 3 | Matrix-Vector operations
Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
The number of columns in matrix A
needs to be the same as the rows in matrix B
The output matrix will have rows same as matrix A and columns same as matrix B
Chapter 4 | Matrix-Matrix multiplication
As you can see. Multiplying matrices manually can be a long, tedious process
Luckly, This process can be done with just one line in Python!
np.dot(A, B)Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
Can be coded like this:
import numpy as np
# Making the 3x3 Identity matrix in two ways
# First way
I = np.array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]])
# Second Way
I = np.identity(3)Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Matrix-Matrix multiplication
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Nempy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
Chapter 4 | Numpy
To create a class, use the keyword class:
Create a class named Snake, with a property named name
Chapter 1 | Python, class intro
Use the __init__() function to assign values to object properties, or other operations that are necessary to do when the object is being created.
Chapter 2 | More on classes
In the class named Snake, use the __init__() function to assign values for new_color
Chapter 2 | More on classes
Chapter 3 | What’s a Neural Network?
Chapter 3 | What’s a Neural Network?
Chapter 3 | What’s a Neural Network?
Chapter 3 | What’s a Neural Network?
Chapter 3 | What’s a Neural Network?
Chapter 3 | What’s a Neural Network?
Chapter 5 | Forward propagation Intro
Chapter | Forward propagation Intro
Multiplication
of layers and weight matrices
Chapter | Forward propagation Intro
Multiplication
of layers and weight matrices
Chapter | Forward propagation Intro
Chapter | Forward propagation Intro
Chapter | Forward propagation Intro
Chapter | Forward propagation Intro
Multiplication
of layers and weight matrices
Chapter | Forward propagation Intro
Multiplication of layers and weight matrices
Chapter | Forward propagation Intro
Multiplication of layers and weight matrices
Chapter | Forward propagation Intro
What they represent mathematically
Chapter | Forward propagation Intro
What is Z representing
Chapter | Forward propagation Intro
What we learned
Chapter | Sigmoid Function
Chapter | Sigmoid Function
We need to convert our values into a probable value
Chapter | Sigmoid Function
Chapter | Forward Propagation Continued
Chapter | Forward Propagation Continued
Bootcamp- Concepts
www.diggitacademy.co.uk
Chapter | Error Calcuation
Chapter | Error Calcuation
Chapter | Error Calcuation
Chapter | Error Calcuation
Chapter | Error Calcuation
Chapter | Error Calcuation
https://www.surveymonkey.com/r/QY2W2C9
There are only 5 questions in the Survey
Linear Regression