Emma's A3 Assignment


In [1]:
import numpy as np;
import scipy as sp;
from sklearn import tree;
from sklearn.neighbors import KNeighborsClassifier;
from sklearn.linear_model import LogisticRegression;
from sklearn.cross_validation import cross_val_score;
from sklearn import svm;

from pandas import DataFrame, read_csv # Importing specific library functions

import matplotlib.pyplot as plt # Importing library but no functions + give nickname
import pandas as pd #this is how I usually import pandas

# Enable inline plotting
%matplotlib inline

#Tutorial: http://nbviewer.jupyter.org/urls/bitbucket.org/hrojas/learn-pandas/raw/master/lessons/01%20-%20Lesson.ipynb
#Intro to pandas and datastructures: http://www.gregreda.com/2013/10/26/intro-to-pandas-data-structures/

In [2]:
# Load in the data
walk_location = r'/Users/emma/Downloads/heather_data/walking.csv'
walk_raw = pd.read_csv(walk_location)
drive_location = r'/Users/emma/Downloads/heather_data/driving.csv'
drive_raw = pd.read_csv(drive_location)
static_location = r'/Users/emma/Downloads/heather_data/static.csv'
static_raw = pd.read_csv(static_location)
upstairs_location = r'/Users/emma/Downloads/heather_data/upstair.csv'
upstairs_raw = pd.read_csv(upstairs_location)
run_location = r'/Users/emma/Downloads/heather_data/running.csv'
run_raw = pd.read_csv(run_location)

In [3]:
# http://stackoverflow.com/questions/17315737/split-a-large-pandas-dataframe
# input - df: a Dataframe, chunkSize: the chunk size
# output - a list of DataFrame
# purpose - splits the DataFrame into smaller of max size chunkSize (last may be smaller)
def splitDataFrameIntoSmaller(df, chunkSize = 1000): 
    listOfDf = list()
    numberChunks = len(df) // chunkSize + 1
    for i in range(numberChunks):
        listOfDf.append(df[i*chunkSize:(i+1)*chunkSize])
    return listOfDf

In [4]:
# Set up the 10-second chunks
walk_chunked = splitDataFrameIntoSmaller(walk_raw)
for idx, df in enumerate(walk_chunked):
    walk_chunked[idx] = pd.DataFrame(df)
    
drive_chunked = splitDataFrameIntoSmaller(drive_raw)
for idx, df in enumerate(drive_chunked):
    drive_chunked[idx] = pd.DataFrame(df)
    
static_chunked = splitDataFrameIntoSmaller(static_raw)
for idx, df in enumerate(static_chunked):
    static_chunked[idx] = pd.DataFrame(df)

upstairs_chunked = splitDataFrameIntoSmaller(upstairs_raw)
for idx, df in enumerate(upstairs_chunked):
    upstairs_chunked[idx] = pd.DataFrame(df)    
    
run_chunked = splitDataFrameIntoSmaller(run_raw)
for idx, df in enumerate(run_chunked):
    run_chunked[idx] = pd.DataFrame(df)

In [5]:
# This is where the feature data will go. The array for each activity will have length 30.
walk_featured = []
drive_featured = []
static_featured = []
upstairs_featured = []
run_featured = []

# Populate the features
for df in walk_chunked:
    features = df.mean().values.tolist() + df.std().values.tolist()
    walk_featured.append(features)
    
for df in drive_chunked:
    features = df.mean().values.tolist() + df.std().values.tolist()
    drive_featured.append(features)
    
for df in static_chunked:
    features = df.mean().values.tolist() + df.std().values.tolist()
    static_featured.append(features)
    
for df in upstairs_chunked:
    features = df.mean().values.tolist() + df.std().values.tolist()
    upstairs_featured.append(features)
    
for df in run_chunked:
    features = df.mean().values.tolist() + df.std().values.tolist()
    run_featured.append(features)

In [6]:
# Combine all of the feature sets into one big one. Along the way, generate my target array.
all_featured = walk_featured + drive_featured + static_featured + upstairs_featured + run_featured
target = [] + [0] * len(walk_featured)
target = target + [1] * len(drive_featured)
target = target + [2] * len(static_featured)
target = target + [3] * len(upstairs_featured)
target = target + [4] * len(run_featured)

if target.count(0) != 30 or target.count(1) != 30 or target.count(2) != 30 or target.count(3) != 30 or target.count(4) != 30:
    raise ValueError('Target is corrupt')

In [7]:
# Create and run cross-validation on a K-Nearest Neighbors classifier
knn = KNeighborsClassifier()
knn_scores = cross_val_score(knn, all_featured, target, cv = 5)
print knn_scores


[ 1.  1.  1.  1.  1.]

In [8]:
# Create and run cross-validation on a Logistic Regression classifier
lr = LogisticRegression()
lr_scores = cross_val_score(lr, all_featured, target, cv = 5)
print lr_scores


[ 0.9  1.   1.   1.   1. ]

In [9]:
# Create and run cross-validation on a Decision Tree classifier
svc = svm.SVC(kernel='linear')
svc_scores = cross_val_score(svc, all_featured, target, cv = 5)
print svc_scores


[ 1.  1.  1.  1.  1.]

In [10]:
# Create and run cross-validation on a Support Vector Machine classifier
dtree = tree.DecisionTreeClassifier()
dtree_scores = cross_val_score(dtree, all_featured, target, cv = 5)
print dtree_scores


[ 0.9  1.   1.   1.   1. ]

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [11]:
# Beginning to figure out features
print walk_raw[['attitude_yaw']].describe()[2:3]
print run_raw[['attitude_yaw']].describe()[2:3]
print static_raw[['attitude_yaw']].describe()[2:3]
print upstairs_raw[['attitude_yaw']].describe()[2:3]
print drive_raw[['attitude_yaw']].describe()[2:3]


     attitude_yaw
std      1.066812
     attitude_yaw
std      1.867349
     attitude_yaw
std      0.007585
     attitude_yaw
std      1.911433
     attitude_yaw
std      2.119805

In [ ]:


In [ ]:


In [12]:
walk_raw.plot(x='timestamp', y='attitude_yaw', title='walk attitude_yaw data', ylim=(-3,3), xlim= (681840,681850))


Out[12]:
<matplotlib.axes._subplots.AxesSubplot at 0x1171eac90>

In [13]:
# Plotting one chunk (10 seconds) of walking data
chunk = walk_raw[['attitude_yaw']][1000:2000]
chunk.plot(title='10 second chunk')


Out[13]:
<matplotlib.axes._subplots.AxesSubplot at 0x117be0890>

In [14]:
# Reformat the chunk
formatted_chunk = chunk.as_matrix().tolist() # Get it out of pandas DataFrame format
formatted_chunk = [item[0] for item in formatted_chunk]

In [15]:
# Do a Fast Fourier Transform on attitude_yaw, chop off low frequency stuff
walk_fft = np.abs(np.fft.fft(formatted_chunk)) # Taking absolute value gives us the magnitude
plt.plot(walk_fft)
walk_fft


Out[15]:
array([  2.82199299e+02,   5.29524606e+01,   3.56962573e+01,
         3.01778813e+01,   2.74633986e+01,   1.82258724e+01,
         3.19238456e+01,   3.53291591e+01,   6.42140723e+01,
         2.60162887e+02,   9.50629593e+01,   2.12943102e+01,
         1.95754477e+01,   1.20952157e+01,   3.41742156e+00,
         1.44789746e+01,   5.78638076e+00,   6.43244691e+00,
         2.58215810e+01,   4.90251382e+01,   2.08399646e+00,
         1.09826860e+01,   1.29166147e+01,   9.09049594e+00,
         7.25624990e+00,   3.06326186e+00,   8.06942322e+00,
         2.01960119e+01,   1.11054920e+02,   2.02056041e+01,
         1.73884840e+01,   1.59560855e+01,   6.37551794e+00,
         4.30784746e+00,   3.97522505e+00,   6.63813000e+00,
         1.45004215e+01,   3.29551424e+01,   2.57213060e+01,
         5.44691339e+00,   6.77216081e+00,   8.99970862e+00,
         7.92819581e+00,   1.82010030e+00,   5.40305605e+00,
         5.38904823e+00,   1.04845764e+01,   2.24882380e+01,
         3.33797044e+00,   3.65902030e+00,   5.09021266e+00,
         6.01807956e+00,   1.96948176e+00,   1.45361788e+00,
         1.39485952e+00,   2.70384990e+00,   9.42717297e+00,
         6.66723696e+00,   7.76043724e+00,   3.29920899e+00,
         1.88311773e+00,   8.09321383e+00,   1.35341427e+00,
         8.36534728e-01,   2.38134976e+00,   4.33722028e+00,
         7.62057477e+00,   1.25631125e+00,   1.01390102e+00,
         1.93139418e+00,   1.32187965e+00,   1.83566528e+00,
         2.30754733e+00,   4.84673571e+00,   5.59828249e+00,
         5.53105814e+00,   4.72793193e+00,   1.90759094e+00,
         1.69016453e+00,   1.71196109e+00,   1.90559388e+00,
         8.81153959e-01,   9.25909566e-01,   2.79152927e+00,
         7.45131060e+00,   4.11922794e+00,   4.70319575e+00,
         1.54355068e+00,   2.06331273e+00,   3.16232225e+00,
         2.15177912e+00,   8.19622740e-01,   1.32732587e+00,
         3.22183901e+00,   3.84350298e+00,   2.54659213e+00,
         2.37864383e+00,   2.17019033e+00,   9.62543857e-01,
         2.40126555e+00,   2.61080064e+00,   1.64250113e+00,
         2.16684234e+00,   1.86299915e+00,   2.65446065e+00,
         4.92359969e-01,   1.42556347e+00,   8.10087521e-01,
         8.67300591e-01,   5.99958169e-01,   2.43127364e-01,
         1.35452050e+00,   1.89035195e+00,   1.39901507e+00,
         2.80729125e+00,   9.43196878e-01,   1.23240784e+00,
         2.31751409e+00,   5.72043726e-01,   1.55027637e+00,
         4.35861080e-01,   1.00927046e+00,   1.54309179e+00,
         1.05386548e+00,   1.69155548e+00,   9.45883665e-01,
         8.23971112e-01,   1.01995410e+00,   1.17048599e+00,
         9.80914699e-01,   1.52235872e+00,   7.28117522e-01,
         1.49715447e+00,   3.60849790e-01,   1.67550853e+00,
         1.05988450e+00,   3.92095322e-01,   2.76150069e-01,
         1.14946327e+00,   5.70752805e-01,   1.26407097e+00,
         4.34082769e-01,   1.43260246e+00,   5.77500996e-01,
         7.97520048e-01,   1.23926662e+00,   5.70281104e-01,
         8.42744683e-01,   6.41163762e-01,   7.21633919e-01,
         9.78194580e-01,   2.86180204e-01,   1.37701759e+00,
         5.86295095e-01,   8.05321907e-01,   5.90920098e-01,
         1.02684463e+00,   7.34806646e-01,   7.98530950e-01,
         1.99138651e-01,   1.55523263e+00,   4.88368982e-01,
         7.22612104e-01,   4.75956113e-01,   4.03668497e-01,
         6.24204774e-01,   1.14258314e+00,   3.24280828e-01,
         9.10009709e-01,   5.40438340e-01,   1.03174062e+00,
         1.46465112e-01,   6.14234959e-01,   4.13670686e-01,
         5.28162447e-01,   2.93168124e-01,   8.07024851e-01,
         2.30442041e-01,   7.91090182e-01,   2.70676230e-01,
         1.09804670e+00,   2.98936108e-01,   7.36148075e-01,
         8.33757121e-01,   6.48786304e-01,   4.58774488e-01,
         3.57313603e-01,   5.97676962e-01,   4.63293955e-01,
         2.49176238e-01,   5.57565597e-01,   4.83327340e-01,
         4.51850206e-01,   4.77428144e-01,   8.39419182e-01,
         4.95947919e-01,   6.91197410e-01,   2.36629987e-01,
         3.59931258e-01,   1.78987685e-01,   4.93928774e-01,
         7.26428523e-01,   7.85594019e-01,   2.55185923e-01,
         6.56119437e-01,   2.39649714e-01,   5.71739471e-01,
         3.08383848e-01,   9.39998044e-01,   2.77695727e-01,
         5.16262230e-01,   5.21190601e-01,   3.91017200e-01,
         2.77549030e-01,   6.13824387e-01,   5.23640399e-01,
         6.16168433e-01,   6.34203344e-01,   3.62778311e-01,
         5.29606557e-01,   6.47852531e-01,   2.51087963e-01,
         5.42014537e-01,   3.31388675e-01,   2.97961352e-01,
         5.70648439e-01,   4.87335491e-01,   5.63581602e-01,
         3.00029917e-01,   3.91156708e-01,   5.40171459e-01,
         3.00925737e-01,   7.13944682e-01,   1.74466483e-01,
         3.77394019e-01,   3.60860910e-01,   7.42675878e-01,
         3.84096200e-01,   4.03593680e-01,   2.50237251e-01,
         6.41883781e-01,   1.20609292e-01,   6.26578029e-01,
         2.96786479e-01,   7.03216741e-01,   4.96565160e-01,
         4.99044399e-01,   1.45882150e-01,   2.75084469e-01,
         6.22421936e-01,   9.57678906e-01,   7.19332010e-01,
         2.68890365e-01,   6.05578240e-01,   2.74056063e-01,
         6.74457262e-01,   5.15917235e-01,   3.79777185e-01,
         3.93669741e-02,   4.18045344e-01,   5.89444706e-01,
         2.95020675e-01,   7.65980621e-01,   3.32955217e-01,
         4.64747543e-01,   5.33515723e-01,   5.64887621e-01,
         4.35553070e-01,   6.41675140e-01,   2.52529247e-01,
         6.16862634e-01,   5.29101533e-01,   6.37363715e-01,
         2.06410313e-01,   4.32032925e-01,   8.32831641e-01,
         4.80425936e-01,   7.94226735e-01,   6.26208366e-01,
         6.84255645e-01,   4.13302176e-01,   6.97606395e-01,
         6.86970794e-02,   2.57992199e-01,   2.86712984e-01,
         6.67418777e-01,   9.04713551e-01,   4.20702327e-01,
         2.97016627e-01,   5.63362770e-01,   4.98869545e-01,
         6.07396174e-01,   5.12673009e-01,   6.55964631e-01,
         2.04382230e-01,   8.47183483e-01,   2.21567579e-01,
         3.67416185e-01,   3.96514693e-01,   1.02215275e+00,
         2.31849222e-01,   7.56875782e-01,   2.28525770e-01,
         6.51614821e-01,   4.08303359e-01,   1.14195244e+00,
         1.96556481e-01,   4.82566299e-01,   2.27454124e-01,
         4.11920355e-01,   6.31533298e-01,   7.38441957e-01,
         5.11168812e-01,   4.92331536e-01,   5.92577908e-01,
         2.97931451e-01,   6.62814372e-01,   3.29850166e-01,
         3.69795930e-01,   9.26859234e-01,   1.94432509e-01,
         4.58356030e-01,   1.43410586e-01,   2.91708528e-01,
         9.93890968e-01,   8.44278757e-01,   4.34356155e-01,
         6.78149564e-01,   1.93910002e-01,   5.49496430e-01,
         4.84646942e-01,   6.76423133e-01,   3.40270121e-01,
         4.53047928e-01,   3.40230217e-01,   1.03460067e+00,
         2.62285724e-01,   4.05727822e-01,   1.47978268e-01,
         6.28910089e-01,   6.26653352e-01,   5.29688498e-01,
         3.35711303e-01,   9.57461684e-01,   3.73627032e-01,
         5.31682549e-01,   3.94693856e-01,   6.75370005e-01,
         3.07318771e-01,   4.29941085e-01,   4.82745881e-01,
         2.23541780e-01,   7.73051626e-01,   5.13790408e-01,
         4.50184225e-01,   3.53347264e-01,   1.46782125e-01,
         2.11031916e-01,   3.51792983e-01,   8.13855799e-01,
         3.75057180e-01,   1.16713540e+00,   3.64607366e-01,
         2.07166596e-01,   2.86708817e-01,   8.24469429e-01,
         9.90529490e-02,   7.45879178e-01,   4.01482842e-01,
         4.54932477e-01,   1.92982013e-01,   8.88815787e-01,
         2.93973706e-01,   6.91036955e-01,   3.78366076e-01,
         3.93080499e-01,   1.38652744e-01,   4.17533740e-01,
         6.99680468e-01,   5.27180148e-01,   4.90364526e-01,
         4.22099466e-01,   2.35561737e-01,   3.36847715e-01,
         3.10562266e-01,   8.56066050e-01,   2.86441080e-01,
         4.46964508e-01,   3.72025308e-01,   1.03530020e+00,
         2.34376971e-01,   1.28179736e-01,   8.66748746e-01,
         5.19811628e-02,   5.49828024e-01,   8.20186680e-01,
         3.48512748e-01,   1.57809561e-01,   4.67392597e-01,
         6.92548827e-02,   4.19196842e-01,   7.35002084e-01,
         1.23036195e-01,   1.28337437e-01,   5.86630450e-01,
         3.12054038e-01,   4.13335330e-01,   4.36005782e-01,
         2.41323606e-01,   6.28818670e-01,   4.85061886e-01,
         3.98439656e-01,   3.66966245e-01,   6.12862600e-01,
         2.79185046e-01,   9.81247177e-01,   5.29281192e-02,
         6.04911359e-01,   6.94894688e-01,   2.34843754e-01,
         8.60078275e-01,   4.12942413e-01,   5.41373779e-01,
         3.45331331e-01,   5.87832661e-01,   2.54523384e-01,
         3.98468554e-01,   3.05933699e-01,   5.67421746e-01,
         2.57703014e-01,   4.45389568e-01,   5.50539014e-01,
         3.32387131e-01,   3.07679841e-02,   8.79065562e-01,
         3.02775616e-01,   1.75365327e-01,   7.40731158e-01,
         2.97209744e-01,   4.89828603e-01,   5.65545897e-01,
         3.17961094e-01,   4.92684709e-01,   7.24017430e-01,
         2.19657983e-01,   4.65017612e-01,   7.42869458e-01,
         7.23091805e-02,   2.36758994e-01,   4.13543451e-01,
         8.32755683e-01,   5.52167635e-01,   3.28976660e-01,
         2.61002326e-01,   4.89192137e-01,   7.18077851e-01,
         4.67453218e-01,   3.92174628e-01,   7.54381851e-01,
         2.06525841e-01,   7.82447601e-01,   6.14703397e-01,
         5.51106737e-01,   3.97051404e-01,   1.01506605e+00,
         5.13760908e-01,   4.65440582e-01,   2.60328505e-01,
         6.43612363e-01,   8.71262677e-01,   9.39922249e-01,
         3.49188739e-01,   2.68538211e-01,   3.15913410e-01,
         4.23101266e-01,   2.86216630e-01,   2.39691565e-01,
         5.29081724e-01,   2.62749411e-01,   4.73361295e-01,
         1.98105838e-01,   4.75717258e-01,   7.80960663e-01,
         6.02354583e-01,   5.04044025e-01,   3.46935291e-01,
         7.45343308e-01,   3.39913169e-01,   1.11242535e+00,
         3.64041551e-02,   6.48400650e-01,   1.15281075e-01,
         5.96248394e-01,   1.68525724e-01,   1.01993118e+00,
         4.90801677e-01,   6.06033469e-01,   5.77712945e-01,
         5.22501845e-01,   1.64530053e-01,   7.71105000e-01,
         1.64530053e-01,   5.22501845e-01,   5.77712945e-01,
         6.06033469e-01,   4.90801677e-01,   1.01993118e+00,
         1.68525724e-01,   5.96248394e-01,   1.15281075e-01,
         6.48400650e-01,   3.64041551e-02,   1.11242535e+00,
         3.39913169e-01,   7.45343308e-01,   3.46935291e-01,
         5.04044025e-01,   6.02354583e-01,   7.80960663e-01,
         4.75717258e-01,   1.98105838e-01,   4.73361295e-01,
         2.62749411e-01,   5.29081724e-01,   2.39691565e-01,
         2.86216630e-01,   4.23101266e-01,   3.15913410e-01,
         2.68538211e-01,   3.49188739e-01,   9.39922249e-01,
         8.71262677e-01,   6.43612363e-01,   2.60328505e-01,
         4.65440582e-01,   5.13760908e-01,   1.01506605e+00,
         3.97051404e-01,   5.51106737e-01,   6.14703397e-01,
         7.82447601e-01,   2.06525841e-01,   7.54381851e-01,
         3.92174628e-01,   4.67453218e-01,   7.18077851e-01,
         4.89192137e-01,   2.61002326e-01,   3.28976660e-01,
         5.52167635e-01,   8.32755683e-01,   4.13543451e-01,
         2.36758994e-01,   7.23091805e-02,   7.42869458e-01,
         4.65017612e-01,   2.19657983e-01,   7.24017430e-01,
         4.92684709e-01,   3.17961094e-01,   5.65545897e-01,
         4.89828603e-01,   2.97209744e-01,   7.40731158e-01,
         1.75365327e-01,   3.02775616e-01,   8.79065562e-01,
         3.07679841e-02,   3.32387131e-01,   5.50539014e-01,
         4.45389568e-01,   2.57703014e-01,   5.67421746e-01,
         3.05933699e-01,   3.98468554e-01,   2.54523384e-01,
         5.87832661e-01,   3.45331331e-01,   5.41373779e-01,
         4.12942413e-01,   8.60078275e-01,   2.34843754e-01,
         6.94894688e-01,   6.04911359e-01,   5.29281192e-02,
         9.81247177e-01,   2.79185046e-01,   6.12862600e-01,
         3.66966245e-01,   3.98439656e-01,   4.85061886e-01,
         6.28818670e-01,   2.41323606e-01,   4.36005782e-01,
         4.13335330e-01,   3.12054038e-01,   5.86630450e-01,
         1.28337437e-01,   1.23036195e-01,   7.35002084e-01,
         4.19196842e-01,   6.92548827e-02,   4.67392597e-01,
         1.57809561e-01,   3.48512748e-01,   8.20186680e-01,
         5.49828024e-01,   5.19811628e-02,   8.66748746e-01,
         1.28179736e-01,   2.34376971e-01,   1.03530020e+00,
         3.72025308e-01,   4.46964508e-01,   2.86441080e-01,
         8.56066050e-01,   3.10562266e-01,   3.36847715e-01,
         2.35561737e-01,   4.22099466e-01,   4.90364526e-01,
         5.27180148e-01,   6.99680468e-01,   4.17533740e-01,
         1.38652744e-01,   3.93080499e-01,   3.78366076e-01,
         6.91036955e-01,   2.93973706e-01,   8.88815787e-01,
         1.92982013e-01,   4.54932477e-01,   4.01482842e-01,
         7.45879178e-01,   9.90529490e-02,   8.24469429e-01,
         2.86708817e-01,   2.07166596e-01,   3.64607366e-01,
         1.16713540e+00,   3.75057180e-01,   8.13855799e-01,
         3.51792983e-01,   2.11031916e-01,   1.46782125e-01,
         3.53347264e-01,   4.50184225e-01,   5.13790408e-01,
         7.73051626e-01,   2.23541780e-01,   4.82745881e-01,
         4.29941085e-01,   3.07318771e-01,   6.75370005e-01,
         3.94693856e-01,   5.31682549e-01,   3.73627032e-01,
         9.57461684e-01,   3.35711303e-01,   5.29688498e-01,
         6.26653352e-01,   6.28910089e-01,   1.47978268e-01,
         4.05727822e-01,   2.62285724e-01,   1.03460067e+00,
         3.40230217e-01,   4.53047928e-01,   3.40270121e-01,
         6.76423133e-01,   4.84646942e-01,   5.49496430e-01,
         1.93910002e-01,   6.78149564e-01,   4.34356155e-01,
         8.44278757e-01,   9.93890968e-01,   2.91708528e-01,
         1.43410586e-01,   4.58356030e-01,   1.94432509e-01,
         9.26859234e-01,   3.69795930e-01,   3.29850166e-01,
         6.62814372e-01,   2.97931451e-01,   5.92577908e-01,
         4.92331536e-01,   5.11168812e-01,   7.38441957e-01,
         6.31533298e-01,   4.11920355e-01,   2.27454124e-01,
         4.82566299e-01,   1.96556481e-01,   1.14195244e+00,
         4.08303359e-01,   6.51614821e-01,   2.28525770e-01,
         7.56875782e-01,   2.31849222e-01,   1.02215275e+00,
         3.96514693e-01,   3.67416185e-01,   2.21567579e-01,
         8.47183483e-01,   2.04382230e-01,   6.55964631e-01,
         5.12673009e-01,   6.07396174e-01,   4.98869545e-01,
         5.63362770e-01,   2.97016627e-01,   4.20702327e-01,
         9.04713551e-01,   6.67418777e-01,   2.86712984e-01,
         2.57992199e-01,   6.86970794e-02,   6.97606395e-01,
         4.13302176e-01,   6.84255645e-01,   6.26208366e-01,
         7.94226735e-01,   4.80425936e-01,   8.32831641e-01,
         4.32032925e-01,   2.06410313e-01,   6.37363715e-01,
         5.29101533e-01,   6.16862634e-01,   2.52529247e-01,
         6.41675140e-01,   4.35553070e-01,   5.64887621e-01,
         5.33515723e-01,   4.64747543e-01,   3.32955217e-01,
         7.65980621e-01,   2.95020675e-01,   5.89444706e-01,
         4.18045344e-01,   3.93669741e-02,   3.79777185e-01,
         5.15917235e-01,   6.74457262e-01,   2.74056063e-01,
         6.05578240e-01,   2.68890365e-01,   7.19332010e-01,
         9.57678906e-01,   6.22421936e-01,   2.75084469e-01,
         1.45882150e-01,   4.99044399e-01,   4.96565160e-01,
         7.03216741e-01,   2.96786479e-01,   6.26578029e-01,
         1.20609292e-01,   6.41883781e-01,   2.50237251e-01,
         4.03593680e-01,   3.84096200e-01,   7.42675878e-01,
         3.60860910e-01,   3.77394019e-01,   1.74466483e-01,
         7.13944682e-01,   3.00925737e-01,   5.40171459e-01,
         3.91156708e-01,   3.00029917e-01,   5.63581602e-01,
         4.87335491e-01,   5.70648439e-01,   2.97961352e-01,
         3.31388675e-01,   5.42014537e-01,   2.51087963e-01,
         6.47852531e-01,   5.29606557e-01,   3.62778311e-01,
         6.34203344e-01,   6.16168433e-01,   5.23640399e-01,
         6.13824387e-01,   2.77549030e-01,   3.91017200e-01,
         5.21190601e-01,   5.16262230e-01,   2.77695727e-01,
         9.39998044e-01,   3.08383848e-01,   5.71739471e-01,
         2.39649714e-01,   6.56119437e-01,   2.55185923e-01,
         7.85594019e-01,   7.26428523e-01,   4.93928774e-01,
         1.78987685e-01,   3.59931258e-01,   2.36629987e-01,
         6.91197410e-01,   4.95947919e-01,   8.39419182e-01,
         4.77428144e-01,   4.51850206e-01,   4.83327340e-01,
         5.57565597e-01,   2.49176238e-01,   4.63293955e-01,
         5.97676962e-01,   3.57313603e-01,   4.58774488e-01,
         6.48786304e-01,   8.33757121e-01,   7.36148075e-01,
         2.98936108e-01,   1.09804670e+00,   2.70676230e-01,
         7.91090182e-01,   2.30442041e-01,   8.07024851e-01,
         2.93168124e-01,   5.28162447e-01,   4.13670686e-01,
         6.14234959e-01,   1.46465112e-01,   1.03174062e+00,
         5.40438340e-01,   9.10009709e-01,   3.24280828e-01,
         1.14258314e+00,   6.24204774e-01,   4.03668497e-01,
         4.75956113e-01,   7.22612104e-01,   4.88368982e-01,
         1.55523263e+00,   1.99138651e-01,   7.98530950e-01,
         7.34806646e-01,   1.02684463e+00,   5.90920098e-01,
         8.05321907e-01,   5.86295095e-01,   1.37701759e+00,
         2.86180204e-01,   9.78194580e-01,   7.21633919e-01,
         6.41163762e-01,   8.42744683e-01,   5.70281104e-01,
         1.23926662e+00,   7.97520048e-01,   5.77500996e-01,
         1.43260246e+00,   4.34082769e-01,   1.26407097e+00,
         5.70752805e-01,   1.14946327e+00,   2.76150069e-01,
         3.92095322e-01,   1.05988450e+00,   1.67550853e+00,
         3.60849790e-01,   1.49715447e+00,   7.28117522e-01,
         1.52235872e+00,   9.80914699e-01,   1.17048599e+00,
         1.01995410e+00,   8.23971112e-01,   9.45883665e-01,
         1.69155548e+00,   1.05386548e+00,   1.54309179e+00,
         1.00927046e+00,   4.35861080e-01,   1.55027637e+00,
         5.72043726e-01,   2.31751409e+00,   1.23240784e+00,
         9.43196878e-01,   2.80729125e+00,   1.39901507e+00,
         1.89035195e+00,   1.35452050e+00,   2.43127364e-01,
         5.99958169e-01,   8.67300591e-01,   8.10087521e-01,
         1.42556347e+00,   4.92359969e-01,   2.65446065e+00,
         1.86299915e+00,   2.16684234e+00,   1.64250113e+00,
         2.61080064e+00,   2.40126555e+00,   9.62543857e-01,
         2.17019033e+00,   2.37864383e+00,   2.54659213e+00,
         3.84350298e+00,   3.22183901e+00,   1.32732587e+00,
         8.19622740e-01,   2.15177912e+00,   3.16232225e+00,
         2.06331273e+00,   1.54355068e+00,   4.70319575e+00,
         4.11922794e+00,   7.45131060e+00,   2.79152927e+00,
         9.25909566e-01,   8.81153959e-01,   1.90559388e+00,
         1.71196109e+00,   1.69016453e+00,   1.90759094e+00,
         4.72793193e+00,   5.53105814e+00,   5.59828249e+00,
         4.84673571e+00,   2.30754733e+00,   1.83566528e+00,
         1.32187965e+00,   1.93139418e+00,   1.01390102e+00,
         1.25631125e+00,   7.62057477e+00,   4.33722028e+00,
         2.38134976e+00,   8.36534728e-01,   1.35341427e+00,
         8.09321383e+00,   1.88311773e+00,   3.29920899e+00,
         7.76043724e+00,   6.66723696e+00,   9.42717297e+00,
         2.70384990e+00,   1.39485952e+00,   1.45361788e+00,
         1.96948176e+00,   6.01807956e+00,   5.09021266e+00,
         3.65902030e+00,   3.33797044e+00,   2.24882380e+01,
         1.04845764e+01,   5.38904823e+00,   5.40305605e+00,
         1.82010030e+00,   7.92819581e+00,   8.99970862e+00,
         6.77216081e+00,   5.44691339e+00,   2.57213060e+01,
         3.29551424e+01,   1.45004215e+01,   6.63813000e+00,
         3.97522505e+00,   4.30784746e+00,   6.37551794e+00,
         1.59560855e+01,   1.73884840e+01,   2.02056041e+01,
         1.11054920e+02,   2.01960119e+01,   8.06942322e+00,
         3.06326186e+00,   7.25624990e+00,   9.09049594e+00,
         1.29166147e+01,   1.09826860e+01,   2.08399646e+00,
         4.90251382e+01,   2.58215810e+01,   6.43244691e+00,
         5.78638076e+00,   1.44789746e+01,   3.41742156e+00,
         1.20952157e+01,   1.95754477e+01,   2.12943102e+01,
         9.50629593e+01,   2.60162887e+02,   6.42140723e+01,
         3.53291591e+01,   3.19238456e+01,   1.82258724e+01,
         2.74633986e+01,   3.01778813e+01,   3.56962573e+01,
         5.29524606e+01])

In [16]:
#walk_fft = [elem for elem in walk_fft if elem > 800]
# walk_fft = walk_fft[800:] # Low pass filter
plt.plot(walk_fft)


Out[16]:
[<matplotlib.lines.Line2D at 0x11909b850>]

In [17]:
# Reverse the Fast Fourier Transform
walk_ifft = np.abs(np.fft.ifft(walk_fft))
plt.plot(walk_ifft)


Out[17]:
[<matplotlib.lines.Line2D at 0x118424590>]