Using Tensorflow and Python to create a linear regression machine learning model to predict machine reliability from excel data.
All code from all my videos is posted on my GitHub account!
THANKS SO MUCH FOR ALL THE SUPPORT. 150+ SUBSCRIBERS (!!!!)
Thanks for watching this video. If you have any suggestions on what's next, please let me know!
Here's the spreadsheet if you would like to use it:
https://drive.google.com/open?id=10fE...
Here's the full code I said I would post in the description!
Start training
with tf.Session() as sess:
Run the initializer
sess.run(init)
Fit all training data
for epoch in range(training_epochs):
for (x, y) in zip(train_X, train_Y):
sess.run(optimizer, feed_dict={X: x, Y: y})
Display logs per epoch step
if (epoch+1) % display_step == 0:
c = sess.run(error, feed_dict={X: train_X, Y:train_Y})
print("Epoch:", '%04d' % (epoch+1), "error=", "{:.9f}".format(c), \
"W=", sess.run(W), "b=", sess.run(b))
print("Optimization Finished!")
training_error = sess.run(error, feed_dict={X: train_X, Y: train_Y})
print("Training error=", training_error, "W=", sess.run(W), "b=", sess.run(b), '\n')
Graphic display
plt.plot(train_X, train_Y, 'ro', label='Original data')
plt.plot(train_X, sess.run(W) * train_X + sess.run(b), label='Fitted line')
plt.legend()
plt.show()
Testing example, as requested (Issue #2)
test_X = numpy.asarray([2,4,6,8,10])
test_Y = numpy.asarray([25,23,21,19,17])
print("Testing... (Mean square loss Comparison)")
testing_error = sess.run(
tf.reduce_sum(tf.pow(pred - Y, 2)) / (2 * test_X.shape[0]),
feed_dict={X: test_X, Y: test_Y}) # same function as cost above
print("Testing error=", testing_error)
print("Absolute mean square loss difference:", abs(
training_error - testing_error))
plt.plot(test_X, test_Y, 'bo', label='Testing data')
plt.plot(train_X, sess.run(W) * train_X + sess.run(b), label='Fitted line')
plt.legend()
plt.show()
The full code can be found here:
https://github.com/Derrick-Sherrill/D...
*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
https://github.com/Derrick-Sherrill/D...
Check out my website:
https://www.derricksherrill.com/
If you liked the video - please hit the like button. It means more than you know. Thanks for watching!!
Useful Links
-----------------------------------------------------------------------------------------------------------------
Python Download:
https://www.python.org/downloads/
(Remember Python 3 is the future!)
I use Atom Text Editor for all my tutorials
Atom Text Editor:
https://atom.io/
Packages I often use in Python tutorials:
-Pandas
https://pandas.pydata.org/pandas-docs...
-Numpy
https://www.numpy.org/
-xlrd
https://xlrd.readthedocs.io/en/latest/
-TensorFlow
https://www.tensorflow.org/api_docs/p...
-Matplotlib
https://matplotlib.org/
-Django Framework
https://www.djangoproject.com/
-Beautiful Soup
https://www.crummy.com/software/Beaut...
(Install through Terminal $pip3 install ....)
Other Useful Services sometimes featured:
-Amazon Web Services (AWS)
https://aws.amazon.com/
-Microsoft Azure
https://azure.microsoft.com/en-us/
-Google Cloud
https://cloud.google.com/
-Juypter Notebooks
https://jupyter.org/
Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!