Skip to content
1,214 changes: 1,214 additions & 0 deletions Classification/SVM.ipynb

Large diffs are not rendered by default.

700 changes: 700 additions & 0 deletions Classification/cell_samples.csv

Large diffs are not rendered by default.

1,214 changes: 1,214 additions & 0 deletions Hierarchical/Vehicle_Hierarchical.ipynb

Large diffs are not rendered by default.

160 changes: 160 additions & 0 deletions Hierarchical/cars_clus.csv

Large diffs are not rendered by default.

851 changes: 851 additions & 0 deletions K_Means/Cust_Segmentation.csv

Large diffs are not rendered by default.

1,214 changes: 1,214 additions & 0 deletions K_Means/K_Means_Customer.ipynb

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions happy_sad_prediction/h-or-s_Prediction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import tensorflow as tf
import os
import zipfile
from os import path, getcwd, chdir

path = f"{getcwd()}/tmp2/happy-or-sad.zip"

zip_ref = zipfile.ZipFile(path, 'r')
zip_ref.extractall("/tmp/h-or-s")
zip_ref.close()


# GRADED FUNCTION: train_happy_sad_model
def train_happy_sad_model():
DESIRED_ACCURACY = 0.999

class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if(logs.get('acc')>0.999):
print("\nReached 99.9% accuracy so cancelling training!")
self.model.stop_training = True


# This Code Block should Define and Compile the Model. Please assume the images are 150 X 150 in your implementation.
model = tf.keras.models.Sequential([
# Your Code Here
# Note the input shape is the desired size of the image 300x300 with 3 bytes color
# This is the first convolution
tf.keras.layers.Conv2D(16, (3,3), activation='relu', input_shape=(150, 150, 3)),
tf.keras.layers.MaxPooling2D(2, 2),
# The second convolution
tf.keras.layers.Conv2D(32, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
# The third convolution
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
# The fourth convolution
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
# The fifth convolution
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
# Flatten the results to feed into a DNN
tf.keras.layers.Flatten(),
# 512 neuron hidden layer
tf.keras.layers.Dense(512, activation='relu'),
# Only 1 output neuron. It will contain a value from 0-1 where 0 for 1 class ('horses') and 1 for the other ('humans')
tf.keras.layers.Dense(1, activation='sigmoid')
])
callbacks = myCallback()
from tensorflow.keras.optimizers import RMSprop

model.compile(
loss='binary_crossentropy',
optimizer=RMSprop(lr=0.001),
metrics=['acc'])


# This code block should create an instance of an ImageDataGenerator called train_datagen
# And a train_generator by calling train_datagen.flow_from_directory

from tensorflow.keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(rescale=1/255) # Your Code Here

# Please use a target_size of 150 X 150.
train_generator = train_datagen.flow_from_directory(
'/tmp/h-or-s/', # This is the source directory for training images
target_size=(150, 150), # All images will be resized to 150x150
batch_size=128,
# Since we use binary_crossentropy loss, we need binary labels
class_mode='binary')
# Expected output: 'Found 80 images belonging to 2 classes'

# This code block should call model.fit_generator and train for
# a number of epochs.
# model fitting
history = model.fit_generator(
train_generator,
steps_per_epoch=8,
epochs=15,
verbose=1)
# model fitting
return history.history['acc'][-1]

train_happy_sad_model()
Binary file added happy_sad_prediction/happy-or-sad.zip
Binary file not shown.