<jupyter_start><jupyter_text>07. Why Neural Networks Deeply Learn a Mathematical Formula?  Machine Learning, what does it mean? > - The Machine Learns...>> But, **what does it learn?**<jupyter_code>%%HTML
<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Machine Learning, what does it mean? ⏯<br><br>· The machine learns...<br><br>Ha ha, not funny! 🤨 What does it learn?<br><br>· A mathematical equation. For example: <a href="https://t.co/sjtq9F2pq7">pic.twitter.com/sjtq9F2pq7</a></p>&mdash; <NAME> (@sotastica) <a href="https://twitter.com/sotastica/status/1449735653328031745?ref_src=twsrc%5Etfw">October 17, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script><jupyter_output><empty_output><jupyter_text>How does the Machine Learn?  In a Linear Regression<jupyter_code>%%HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/Ht3rYS-JilE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><jupyter_output><empty_output><jupyter_text>In a Neural Network<jupyter_code>%%HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/IHZwWFHWa-w?start=36" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><jupyter_output><empty_output><jupyter_text>A Practical Example → [Tesla Autopilot](https://www.tesla.com/AI) An Example where It Fails → [Tesla Confuses Moon with Semaphore](https://twitter.com/Carnage4Life/status/1418920100086784000?s=20)  Load the Data > - Simply execute the following lines of code to load the data.> - This dataset contains **statistics about Car Accidents** (columns)> - In each one of **USA States** (rows) https://www.kaggle.com/fivethirtyeight/fivethirtyeight-bad-drivers-dataset/<jupyter_code>import seaborn as sns

df = sns.load_dataset(name='car_crashes', index_col='abbrev')
df.sample(5)<jupyter_output><empty_output><jupyter_text>Neural Network Concepts in Python  Initializing the `Weights`  How to `kernel_initializer` the weights? $$accidents = speeding \cdot w_1 + alcohol \cdot w_2 \ + ... + \ ins\_losses \cdot w_7$$  Make a Prediction with the Neural Network > - Can we make a prediction for for `Washington DC` accidents> - With the already initialized Mathematical Equation?  Predictions vs Reality > 1. Calculate the Predicted Accidents and> 2. Compare it with the Real Total Accidents  How to `kernel_initializer` the weights to 1? $$accidents = speeding \cdot w_1 + alcohol \cdot w_2 \ + ... + \ ins\_losses \cdot w_7$$  Make a Prediction with the Neural Network > - Can we make a prediction for for `Washington DC` accidents> - With the already initialized Mathematical Equation?  Predictions vs Reality > 1. Calculate the Predicted Accidents and> 2. Compare it with the Real Total Accidents  Play with the Activation Function  Use `sigmoid` activation in last layer  Use `linear` activation in last layer  Use `relu` activation in last layer  How is the predictions changing? Why?  How to improve the Neural Network? > - The Neural Network is horrible because> - We didn't move the randomly initialized weights> - If we get to `fit()` the Neural Network,> - It will probably improve  How good is the Model now? > 1. Calculate the predictions> 2. Give the residuals  Summary- Mathematical Formula- Weights / Kernel Initializer- Loss Function- Activation Function- Optimizers  What cannot you change arbitrarily of a Neural Network?- Input Neurons- Output Neurons- Loss Functions- Activation Functions  Neural Network for Classification  Load Another Data<jupyter_code>fashion_mnist = tf.keras.datasets.fashion_mnist

(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',
               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']<jupyter_output><empty_output><jupyter_text>Visualize One Image<jupyter_code>plt.figure()
plt.imshow(train_images[0])
plt.colorbar()
plt.grid(False)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11972498814604078, 'fraction_numerical': 0.02110004741583689, 'mean_word_length': 5.7504, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 66, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '96660', 'license': 'MIT', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1303, 'n_words': 409, 'path': '#04. Why Neural Networks Deeply Learn a Mathematical Formula/04session.ipynb', 'repo_name': 'apoboldon/machine-learning-program', 'size': '4223'}