Professional Documents
Culture Documents
uses a dataset of about 3,700 photos of flowers. The dataset contains five sub-
directories, one per class:
import pathlib
dataset_url =
"https://storage.googleapis.com/download.tensorflow.org/example_images/
flower_photos.tgz"
data_dir = tf.keras.utils.get_file('flower_photos.tar', origin=dataset_url,
extract=True)
data_dir = pathlib.Path(data_dir).with_suffix('')
image_count = len(list(data_dir.glob('*/*.jpg')))
print(image_count)
roses = list(data_dir.glob('roses/*'))
PIL.Image.open(str(roses[0]))
What is Train/Test
Train/Test is a method to measure the accuracy of your model.
It is called Train/Test because you split the data set into two sets: a training
set and a testing set.
Our data set illustrates 100 customers in a shop, and their shopping habits.
import numpy
import matplotlib.pyplot as plt
numpy.random.seed(2)
x = numpy.random.normal(3, 1, 100)
y = numpy.random.normal(150, 40, 100) / x
plt.scatter(x, y)
plt.show()
train_x = x[:80]
train_y = y[:80]
test_x = x[80:]
test_y = y[80:]
Example
plt.scatter(train_x, train_y)
plt.show()
Example
plt.scatter(test_x, test_y)
plt.show()