C1 W1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Rules

(Expressed in
Code)

calcPE(stock){
price = readPrice();
earnings = readEarnings();
Data return (price/earnings);
}

Answers
(Returned From Code)
if (ball.collide(brick)){
removeBrick();
ball.dx=-1*(ball.dx);
ball.dy=-1*(ball.dy);
}
Rules
Traditional Answers
Data Programming
Rules
Traditional Answers
Data Programming

Answers
Machine Rules
Data Learning
Activity Recognition

if(speed<4){

status=WALKING;
}
Activity Recognition

if(speed<4){ if(speed<4){

status=WALKING; status=WALKING;
} } else {

status=RUNNING;
}
Activity Recognition

if(speed<4){ if(speed<4){ if(speed<4){


status=WALKING;
status=WALKING; status=WALKING; } else if(speed<12){
} } else { status=RUNNING;
} else {
status=RUNNING; status=BIKING;
} }
Activity Recognition

if(speed<4){ if(speed<4){ if(speed<4){ // Oh crap


status=WALKING;
status=WALKING; status=WALKING; } else if(speed<12){
} } else { status=RUNNING;
} else {
status=RUNNING; status=BIKING;
} }
Rules
Traditional Answers
Data Programming

Answers
Machine Rules
Data Learning
Activity Recognition

01010010101001010 10101001010010101 10010100111110101 11111111110100111


10100101010100101 01010101001001001 01110101011101010 01001111101011111
11010100101010010 00010010011111010 11101010101111010 01010101110101010
10100101010010101 10111110101001001 10101111111100011 10111010101010101
00101010 11101011 11010101 00111110
Label = Label = Label = BIKING Label =
WALKING RUNNING GOLFING (Sort
of)
X = -1, 0, 1, 2, 3, 4
Y = -3, -1, 1, 3, 5, 7
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)


ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

model.fit(xs, ys, epochs=500)

print(model.predict([10.0]))
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)


ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

model.fit(xs, ys, epochs=500)

print(model.predict([10.0]))
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)


ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

model.fit(xs, ys, epochs=500)

print(model.predict([10.0]))
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)


ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

model.fit(xs, ys, epochs=500)

print(model.predict([10.0]))
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)


ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

model.fit(xs, ys, epochs=500)

print(model.predict([10.0]))

You might also like