by alexander white ©
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tensorflow as tf | |
| tf.logging.set_verbosity(tf.logging.ERROR) | |
| import numpy as np | |
| import matplotlib.pyplot as plt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| layer_0 = tf.keras.layers.Dense(units=1, input_shape=[1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model = tf.keras.Sequential([layer_0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model = tf.keras.Sequential([ | |
| tf.keras.layers.Dense(units=1, input_shape=[1]) | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| model.compile(loss='mean_squared_error', | |
| optimizer=tf.keras.optimizers.Adam(0.1)) |
OlderNewer