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
@techwithshadab
techwithshadab / byte-sizetuts.md
Created January 11, 2016 15:47 — forked from honkskillet/byte-sizetuts.md
A series of golang tutorials with youtube videos.
@techwithshadab
techwithshadab / tensorflow-for-beginners.ipynb
Last active August 2, 2019 19:51
Tensorflow for Beginners.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
import numpy as np
import matplotlib.pyplot as plt
mar_budget = np.array([60, 80, 100 , 30, 50, 20, 90, 10], dtype=float)
subs_gained = np.array([160, 200, 240, 100, 140, 80, 220, 60], dtype=float)
for i,c in enumerate(mar_budget):
print("{} Market budget = {} new subscribers gained".format(c, subs_gained[i]))
plt.scatter(mar_budget, subs_gained)
plt.xlim(0,120)
plt.ylim(0,260)
plt.xlabel('Marketing Budget(in thousand of Dollars)')
plt.ylabel('Subscribers Gained(in thousand)')
plt.show()
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(mar_budget,subs_gained,random_state=42,
train_size=0.8, test_size=0.2)
layer_0 = tf.keras.layers.Dense(units=1, input_shape=[1])
model = tf.keras.Sequential([layer_0])
model = tf.keras.Sequential([
tf.keras.layers.Dense(units=1, input_shape=[1])
])
model.compile(loss='mean_squared_error',
optimizer=tf.keras.optimizers.Adam(0.1))