Professional Documents
Culture Documents
Hands On Artificial Intelligence For IoT Prefinal1
Hands On Artificial Intelligence For IoT Prefinal1
Hands On Artificial Intelligence For IoT Prefinal1
net/publication/331498644
Hands-On Artificial Intelligence for IoT: Expert machine learning and deep
learning techniques for developing smarter IoT systems
CITATIONS READS
10 4,300
1 author:
Amita Kapoor
University of Delhi
70 PUBLICATIONS 151 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Amita Kapoor on 22 March 2019.
www.packtpub.com
–
mapt.io
www.packt.com
customercare@packtpub.com
www.packt.com
ó
authors.packtpub.com
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
www.packtpub.com
www.packtpub.com/support
www.packtpub.com
https://github.com/PacktPublishing/Hands-On-Artificial-Intelligence-for-IoT
https://github.com/PacktPublishing/
http://www.packtpub.com/sites/default/files/downloads/9781788836067_ColorImages
.pdf
CodeInText
A B
tf.placeholder float32
# Declare placeholders for the two matrices
A = tf.placeholder(tf.float32, None, name='A')
B = tf.placeholder(tf.float32, None, name='B')
feedback@packtpub.com
questions@packtpub.com
www.packtpub.com/submit-errata
copyright@packtpub.com
authors.packtpub.com
packtpub.com
http://www.itrco.jp/libraries/RFIDjournal-
That%20Internet%20of%20Things%20Thing.pdf
—
—
—
https://www.itu.int/en/ITU-T/gsi/
iot/Pages/default.aspx
New dimension introduced in IoT (adapted from b-ITU-T Y.2060 report)
—
IoT layers
https://www.postscapes.com/internet-of-things-
protocols/
Prediction about the growth of IoT devices by 2025
https://cdn.ihs.com/www/pdf/enabling-IOT.pdf
–
á Ó
Services that different AI/IoT platforms support
Chapter 9
Session
Session
https://github.com/PacktPublishing/Hands-On-
Artificial-Intelligence-for-IoT matrix_multiplication.ipynb
import tensorflow as tf
import numpy as np
mat1
mat2
A B
A B
tf.placeholder float32
None
tf.matmul
C = tf.matmul(A,B)
Session mat1
mat2 A B
#Create Variable
x = K.variable(value=A)
y = K.variable(value=B)
z = K.dot(x,y)
print(K.eval(z))
http://
archive.ics.uci.edu/ml/datasets/combined+cycle+power+plant
xls ods
° °
—
ı ü
ı ü ı ü
https://archive.ics.uci.edu/ml/datasets/Wine+Quality
csv
https://repositorium.
sdum.uminho.pt/bitstream/1822/10029/1/wine5.pdf
https://www.
kaggle.com/c/predict-impact-of-air-quality-on-death-rates
.txt
open() read() write() close()
Shakespeare
https://ocw.mit.edu/ans7870/6/6.006/s08/lecturenotes/files/t8.shakespeare.
txt
data_folder = '../../data/Shakespeare'
data_file = 'alllines.txt'
f = open(data_file)
read
contents = f.read()
contents contents
1000
print(contents[:1000])
"ACT I"
"SCENE I. London. The palace."
"Enter KING HENRY, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR
WALTER BLUNT, and others"
"So shaken as we are, so wan with care,"
"Find we a time for frighted peace to pant,"
"And breathe short-winded accents of new broils"
"To be commenced in strands afar remote."
"No more the thirsty entrance of this soil"
"will daub her lips with her own children's blood,"
"Nor more will trenching war channel her fields,"
"Nor bruise her flowerets with the armed hoofs"
"Of hostile paces: those opposed eyes,"
"Which, like the meteors of a troubled heaven,"
"All of one nature, of one substance bred,"
"Did lately meet in the intestine shock"
"And furious close of civil butchery"
"will now, in mutual well-beseeming ranks,"
"March all one way and be no more opposed"
"Against acquaintance, kindred and allies:"
"The edge of war, like an ill-sheathed knife,"
"No more will cut his master. Therefore, friends,"
"As far as to the sepulchre of Christ,"
"Whose
.csv
csv numpy
pandas household_power_consumption
https://github.com/ahanse/
machlearning/blob/master/household_power_consumption.csv
data_folder = '../../data/household_power_consumption'
data_file = 'household_power_consumption.csv'
csv
csv
csv.reader
import csv
import os
with open(os.path.join(data_folder,data_file),newline='') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
print(row)
csv.writer
delimiter quoting
reader writer
delimiter ,
delimiter reader writer
| delimiter
# read the file and write first ten rows with '|' delimiter
with open(os.path.join(data_folder, data_file), newline='') as csvfile, \
open(os.path.join(data_folder, 'temp.csv'), 'w', newline='') as
tempfile:
csvreader = csv.reader(csvfile)
csvwriter = csv.writer(tempfile, delimiter='|')
for row, i in zip(csvreader, range(10)):
csvwriter.writerow(row)
# read and print the newly written file
with open(os.path.join(data_folder, 'temp.csv'), newline='') as tempfile:
csvreader = csv.reader(tempfile, delimiter='|')
for row in csvreader:
print(row)
delimiter
['0007-01-01|00:00:00|2.58|0.136|241.97|10.6|0|0|0']
quotechar quoting
quotechar quoting
csv.QUOTE_ALL
csv.QUOTE_MINIMAL
csv.QUOTE_NONNUMERIC
csv.QUOTE_NONE
0007-01-01|00:00:00|2.58|0.136|241.97|10.6|0|0|0
0007-01-01|00:01:00|2.552|0.1|241.75|10.4|0|0|0
0007-01-01|00:02:00|2.55|0.1|241.64|10.4|0|0|0
0007-01-01|00:03:00|2.55|0.1|241.71|10.4|0|0|0
0007-01-01|00:04:00|2.554|0.1|241.98|10.4|0|0|0
0007-01-01|00:05:00|2.55|0.1|241.83|10.4|0|0|0
0007-01-01|00:06:00|2.534|0.096|241.07|10.4|0|0|0
0007-01-01|00:07:00|2.484|0|241.29|10.2|0|0|0
0007-01-01|00:08:00|2.468|0|241.23|10.2|0|0|0
# read the file and write first ten rows with '|' delimiter, all quoting
and * as a quote charachetr.
with open(os.path.join(data_folder, data_file), newline='') as csvfile, \
open('temp.csv', 'w', newline='') as tempfile:
csvreader = csv.reader(csvfile)
csvwriter = csv.writer(tempfile, delimiter='|',
quotechar='*',quoting=csv.QUOTE_ALL)
for row, i in zip(csvreader, range(10)):
csvwriter.writerow(row)
*0007-01-01*|*00:00:00*|*2.58*|*0.136*|*241.97*|*10.6*|*0*|*0*|*0*
*0007-01-01*|*00:01:00*|*2.552*|*0.1*|*241.75*|*10.4*|*0*|*0*|*0*
*0007-01-01*|*00:02:00*|*2.55*|*0.1*|*241.64*|*10.4*|*0*|*0*|*0*
*0007-01-01*|*00:03:00*|*2.55*|*0.1*|*241.71*|*10.4*|*0*|*0*|*0*
*0007-01-01*|*00:04:00*|*2.554*|*0.1*|*241.98*|*10.4*|*0*|*0*|*0*
*0007-01-01*|*00:05:00*|*2.55*|*0.1*|*241.83*|*10.4*|*0*|*0*|*0*
*0007-01-01*|*00:06:00*|*2.534*|*0.096*|*241.07*|*10.4*|*0*|*0*|*0*
*0007-01-01*|*00:07:00*|*2.484*|*0*|*241.29*|*10.2*|*0*|*0*|*0*
*0007-01-01*|*00:08:00*|*2.468*|*0*|*241.23*|*10.2*|*0*|*0*|*0*
reader
read_csv()
df = pd.read_csv('temp.csv')
print(df)
date time
to_csv()
df.to_csv('temp1.cvs')
header
sep
sep ,
names
usecols
dtype
https://pandas.pydata.org/pandas-docs/stable/generated/
pandas.read_csv.html https://pandas.pydata.org/pandas-docs/
stable/generated/pandas.DataFrame.to_csv.html
np.loadtxt() np.genfromtxt()
np.loadtxt
3 4
×
array([[2.58 , 0.136],
[2.552, 0.1 ],
[2.55 , 0.1 ],
[2.55 , 0.1 ],
[2.554, 0.1 ],
[2.55 , 0.1 ],
[2.534, 0.096],
[2.484, 0. ],
[2.468, 0. ]])
np.loadtxt()
np.genfromtxt()
np.genfromtxt()
np.savetxt()
np.savetxt()
.xlsx
workbook
wb = Workbook()
active
ws = wb.active()
title
append
ws.append()
create_sheet()
column row
save
load_workbook
get_sheet_names()
OpenPyXl_example.ipynb
https://openpyxl.readthedocs.io/en/stable/
.xlsx read_excel
sheet_name
to_excel
Pandas_xlsx_example.ipynb
import pandas as pd
df = pd.read_excel("empty_book.xlsx", sheet_name=0)
df.describe()
result = df * 2
result.describe()
result.to_excel("empty_book_modified.xlsx")
zips.json
json.load() json.loads()
zips.json
import os
import json
from pprint import pprint
{'_id': '01001',
'city': 'AGAWAM',
'loc': [-72.622739, 42.070206],
'pop': 15338,
'state': 'MA'}
json.loads()
json.load()
json_data
json.dumps()