My notes for the Machine Learning, Data Science and Deep Learning with Python course on Udemy
My person notes for the Machine Learning, Data Science and Deep Learning with Python course by Frank Kane on Udemy
conda install pydotplus
conda install tensorflow
jupyter notebook
3.2 This will open a browser tab with the url http://localhost:8888/tree with the script files and accompanying dataIn terminal navigate to the MLCourse directory , run jupyter notebook
and click on Python101.ipynb
{}
in JavaScript;
required to terminate the end of a linelike in JavaScript:
Example: Write a python program to create a list of numbers from 1 to 6 and then print whether that number is either even or odd
listOfNumbers = [1, 2, 3, 4, 5, 6]
for number in listOfNumbers:
if (number % 2 == 0):
print(number, "is even")
else:
print(number, "is odd")
print ("All done.")
import
to importas
keywordExample: Import the numpy library and generate a list of 10 numbers with a mean of 25 and a standard deviation of 5
import numpy as np
A = np.random.normal(25.0, 5.0, 10)
print (A)
Python’s version of JavaScript arrays
x = [1, 2, 3, 4, 5, 6]
print(len(x)) # 6
x[:3] # [1, 2, 3]
x[3:] # [4, 5, 6]
x[-2:] # [5, 6]
x.extend([7,8]) # [1, 2, 3, 4, 5, 6, 7, 8]
x.append(9) # [1, 2, 3, 4, 5, 6, 7, 8, 9]
y = [10, 11, 12]
listOfLists = [x, y]
print(listOfLists) # [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12]]
z = [3, 2, 1]
z.sort() # [1, 2, 3]
z.sort(reverse=True) # [3, 2, 1]
Immutable lists used for functional programming or working with Apache Spark
x = (1, 2, 3)
len(x) # 3
y = (4, 5, 6)
y[2] # 6
listOfTuples = [x, y]
listOfTuples # [(1, 2, 3), (4, 5, 6)]
(age, income) = "32,120000".split(',')
print(age) # 32
print(income) # 120000
Similiar to objects in JavaScript also reffered to as a map or hash table in other languages
captains = {}
captains["Enterprise"] = "Kirk"
captains["Enterprise D"] = "Picard"
captains["Deep Space Nine"] = "Sisko"
captains["Voyager"] = "Janeway"
print(captains["Voyager"]) # Janeway
print(captains.get("Enterprise")) # Kirk
print(captains.get("NX-01")) # none
for ship in captains:
print(ship + ": " + captains[ship])
# Enterprise: Kirk
# Enterprise D: Picard
# Deep Space Nine: Sisko
# Voyager: Janeway
# Example syntax
def FunctionName(param1, param2, ... , paramn):
return param1 + param2 + ... + paramn
# Return the square of a given number
def SquareIt(x):
return x * x
# Pass function in as a parameter
def DoSomething(f, x):
return f(x)
print(SquareIt(2)) # 4
print(DoSomething(SquareIt, 3))
# Inline simple function using Lambda function
print(DoSomething(lambda x: x * x * x, 3)) # 27
print(1 == 3) # False
print(True or False) # True
print(1 is 3) # False
if 1 is 3:
print("How did that happen?")
elif 1 > 3:
print("Yikes")
else:
print("All is well with the world")
# All is well with the world
for x in range(10):
print(x)
for x in range(10):
if (x is 1):
continue
if (x > 5):
break
print(x)
x = 0
while (x < 10):
print(x)
x += 1
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for x in myList:
if (x % 2 == 0):
print(x)