Skip to content

Instantly share code, notes, and snippets.

View techwithshadab's full-sized avatar
💻
Playing with Data

Shadab Hussain techwithshadab

💻
Playing with Data
View GitHub Profile
trained_model = model.fit(X_train, y_train, epochs=1000, verbose=False)
print("Finished training the model")
import matplotlib.pyplot as plt
plt.xlabel('Epoch Number')
plt.ylabel("Loss Magnitude")
plt.plot(trained_model.history['loss'])
y_pred = model.predict(X_test)
print('Actual Values\tPredicted Values')
print(y_test,' ',y_pred.reshape(1,-1))
from sklearn.metrics import r2_score
r2_score(y_test,y_pred)
l_0 = tf.keras.layers.Dense(units=4, input_shape=[1])
l_1 = tf.keras.layers.Dense(units=5)
l_2 = tf.keras.layers.Dense(units=1)
model = tf.keras.Sequential([l_0, l_1, l_2])
model.compile(loss='mean_squared_error', optimizer=tf.keras.optimizers.Adam(0.1))
model.fit(X_train,y_train, epochs=2000,verbose=False)
print('\n Finished training Model')
print(model.predict([80]))
y_pred=model.predict(X_test)
print(r2_score(y_test,y_pred))
import os, cv2, random
import numpy as np
import pandas as pd
%pylab inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from matplotlib import ticker
import seaborn as sns
%matplotlib inline
# loading labels for each image from csv
labels = pd.read_csv('results.csv')
labels = labels.iloc[:,0:2]
labels.head()
# Separating male labels
male_data = labels[labels['Gender'] == 0]
male_data.head()