<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mitesh Parmar on Medium]]></title>
        <description><![CDATA[Stories by Mitesh Parmar on Medium]]></description>
        <link>https://medium.com/@miteshparmar1?source=rss-59cc59fea6d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RE5B5TUais_-lGiQ.jpg</url>
            <title>Stories by Mitesh Parmar on Medium</title>
            <link>https://medium.com/@miteshparmar1?source=rss-59cc59fea6d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 16:41:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@miteshparmar1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Make the Raspberry Pi visible on Mac and Windows computers]]></title>
            <link>https://miteshparmar1.medium.com/make-the-raspberry-pi-visible-on-your-mac-and-windows-computers-31c12e4e19d2?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/31c12e4e19d2</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[computer-networking]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Mon, 20 Sep 2021 17:57:24 GMT</pubDate>
            <atom:updated>2021-09-23T20:22:20.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*G5NpcITD856vfyXm6eVJBg.jpeg" /><figcaption>image courtesy of www.makeuseof.com</figcaption></figure><p>Previously I wrote about what a <a href="https://medium.com/codex/what-is-the-raspberry-pi-and-why-you-should-buy-one-aaae7f417b63?sk=9ec9b34505d12085ab816ebbc5246085">Raspberry Pi is and why you should buy one</a>. Subsequently I wrote about <a href="https://medium.com/codex/how-to-install-a-fan-onto-a-raspberry-pi-and-make-it-run-dynamically-4ff0e59985fc?sk=2ff8f38c18ff1f1963803cbd5ad10a5c">how to install and configure a fan to run dynamically on the Raspberry Pi</a>. Here we examine how to get the Raspberry Pi on the home network; present in Finder on the Mac and under ‘Network’ in Windows Explorer on the PC.</p><p>By default when the Raspberry Pi is connected to a router and has internet connectivity it is not visible to other computers on the same network. The reason you’d want it to appear is simply to allow you to drag and drop files to and from your computer to the Raspberry Pi.</p><p><strong>Let’s get the Pi shown in Finder on the Mac first…</strong></p><p>Quite simply, to get the Raspberry Pi showing in Finder on Mac OS X log into your Raspberry Pi (via ssh or directly).</p><p>Enter the following command and press enter to retrieve and install netatalk:</p><pre>sudo apt-get install netatalk</pre><p>For security reasons the installation does not by default provide access to the Pi so an installed file needs to be amended accordingly. To edit the config file type:</p><pre>sudo nano /etc/netatalk/afp.conf</pre><p>You only need to comment out a single line by removing the semi-colon character. Replace the /xxxx with /home:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EWVjvt7EdjIq6D456Bm9Gw.png" /></figure><p>Press ctrl+X to exit and press y to save changes.</p><p>Next we need to amend the .profile file so that netatalk is restarted when the Pi boots up and loads the .profile file. In the Terminal type:</p><pre>nano .profile</pre><p>This opens the .profile file which shows some text:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eABsM0uWyO59fl1M4J-n5g.png" /><figcaption>the .profile file when opened in nano</figcaption></figure><p>Scroll to the very bottom and insert the following command:</p><pre>sudo systemctl restart netatalk</pre><p>Press ctrl+x to exit and press Y to save changes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GcfaT_BHPGjGfSi5MvOMQQ.png" /></figure><p>That’s all there is to it! Now every time the Pi is restarted it will be shown in Finder on the Mac OS. To prove this restart the Pi by issuing the following command:</p><pre>sudo reboot</pre><p>Allow a few minutes for the Raspberry Pi to reboot and log back in.</p><p>On the Mac open a Finder window which should show an icon pertaining to the Raspberry Pi on the left-hand side. Click on this then click on the ‘Connect As’ button on the right-hand side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ci_2awZh4oNksaXEzuROfg.png" /></figure><p>Click on the ‘Connect’ button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*GhXpxn4V36zTmT3PGrXvwA.png" /></figure><p>Enter the user credentials for the Raspberry Pi user (mine is pi) and click ‘Connect’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*NEJflVoCL1HLJEoFMq3ZSw.png" /></figure><p>An icon should be now present in the Finder window:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BNs5wGVQ6G0z46B04MBCgQ.png" /></figure><p>Double-click on the icon to access the home directory of user pi on the Raspberry Pi:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FBJ483R7Hu_EzLvMnGS-2w.png" /></figure><p><strong>Now let’s get the Pi accessible in Windows</strong></p><p>I think that instead of copy/pasting information that is already available in the public domain I’m just going to give the link of a YouTuber who has already done this and explained it concisely: <a href="https://www.youtube.com/watch?v=8FkiOfEgyvM&amp;t=74s">https://www.youtube.com/watch?v=8FkiOfEgyvM&amp;t=74s</a>. Follow ‘Arcade Spinners’ steps verbatim and you’ll be able to connect to your Raspberry Pi via Windows and be able to map a network drive to the Pi too.</p><p>One caveat of networking the Pi in Windows is that it does not appear in the ‘Network Neighbourhood’ area of networked computers. You can only access it via the \\{host_name} command in Windows. The reason being is because Microsoft have deprecated the SMBv1 discovery system. If you require the Pi to be seen in ‘Network Neighbourhood’ you need to run a Web Service Discovery Host deamon (wsdd). Thankfully, a developer has published this on his <a href="https://github.com/christgau/wsdd">GitHub page</a>. However, this does requires Python 3.</p><p>The Raspberry Pi OS by default uses Python version 2 despite Python versions 2 and 3 being installed by default. So we just need to make a minor change so the Pi uses Python 3 by default so the wsdd script will run seamlessly.</p><p>In a Terminal type the following:</p><pre>python --version</pre><p>This lists the version of Python being used by default. Mine shows version 2.7.16:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*q_dp5dcHk1MDodM941O4rA.png" /></figure><p>I need to change this to use Python version 3 installation instead every single time I log into the Pi.</p><p>Enter the following command to edit the .bashrc file:</p><pre>nano ~/.bashrc</pre><p>This is a hidden file residing in the user’s home directory (in my case pi) that behaves like a shell script every time the specific user opens a terminal. It helps configure the users environment so it already contains multiple vital commands.</p><p>Simply scroll to the very bottom and enter the following command:</p><pre>alias python=&#39;/usr/bin/python3&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Ww5mZwwSFIyh_7LBEdCiw.png" /></figure><p>Press ctrl+X to exit and click on Y to save changes.</p><p>We can simply run the contents of the .bashrc script (to save you from logging out and back in again) by typing the following command:</p><pre>source ~/.bashrc</pre><p>Now check the version of Python by typing:</p><pre>python --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*7_uwAR_4070kE75mhd8Seg.png" /></figure><p>It should now show some version of Python 3 in use.</p><p>To run the wsdd file simply follow the GitHub <a href="https://github.com/christgau/wsdd#generic-installation-instructions">Generic Installation Instructions.</a></p><p>Assuming the wsdd file is in your home directory, run the deamon in the background simply type the following command:</p><pre>~/wsdd &amp;</pre><p>Now you may see a load of error output similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s4Pu-zPjUMcbJfCRE2Kssg.png" /></figure><p>Don’t worry, the errors are non-fatal. Simply press ctrl+X a few times to get back to the terminal. Once your back in the terminal enter the following command:</p><pre>jobs</pre><p>This shows the background processes running on the Pi:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*5fE5v9Z-3sbgQFRv71elFQ.png" /></figure><p>Now, if you check the ‘Network Neighbourhood’ on a Windows machine on the same network the Raspberry Pi should be visible:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ab7ZoHwkjzUDljcxxC3oAA.png" /></figure><p>NOTE: the wsdd process must be running continuously for the Pi to be shown in Network Neighbourhood. The moment the wsdd process is killed on the Pi it will no longer be visible in the Network Neighbourhood.</p><p>I hope this worked for you on both your Windows and Mac computers as it did for me. If so please leave a clap. If you have any comments, concerns or questions don’t hesitate to reply…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31c12e4e19d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to install a fan onto a Raspberry Pi and make it run dynamically]]></title>
            <link>https://medium.com/codex/how-to-install-a-fan-onto-a-raspberry-pi-and-make-it-run-dynamically-4ff0e59985fc?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ff0e59985fc</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[computing]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[hobby]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Tue, 14 Sep 2021 18:48:15 GMT</pubDate>
            <atom:updated>2021-09-16T18:37:48.228Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M--Dz_yZxIOVjZ_9" /><figcaption>Photo by <a href="https://unsplash.com/@stefanbc?utm_source=medium&amp;utm_medium=referral">Stefan Cosma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://medium.com/codex/what-is-the-raspberry-pi-and-why-you-should-buy-one-aaae7f417b63">In my previous article I wrote about what a Raspberry Pi was and why you should consider buying one</a>. One of the main gripes with the current fourth generation Raspberry Pi is that it does become quite hot under heavy load. The fourth generation Raspberry Pi does “throttle” the CPU which means that it slows the processing down so to prevent the device from over-heating. This is good but you really want the Pi to perform well and be cooled accordingly. So what you really need a good cooling solution for your Raspberry Pi. Add to this the fact that the Raspberry Pi does not ship with a case so we could do with this too.</p><p>There are two cooling solutions for the Raspberry Pi; active cooling and passive cooling. Active cooling involves the use of a physical rotating fan to cool the central processing unit (CPU) whereas passive cooling involves the use of heat sinks; pieces of jagged metal to dissipate the heat. Active cooling is far more effective than passive cooling at reducing the temperature of the CPU which was the reason I opted for a fan to cool my Raspberry Pi. <a href="https://www.youtube.com/watch?v=AVfvhEJ9XD0">(If you don’t believe me check out YouTuber Chris Barnett’s video of comparing cooling solutions on a Raspberry Pi 4)</a>.</p><p>So a case with a mounted fan would be ideal, hence I purchased the ‘<a href="https://www.amazon.co.uk/gp/product/B07Y8DQ5ST/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&amp;psc=1">GeeekPi Raspberry Pi 4 Acrylic Case, Raspberry Pi 4 Case with Fan(Blue Light) and Raspberry Pi 4 Heatsinks For Raspberry Pi 4 Model B, Compatible with Raspberry Pi ICE Tower Fan(Black and Clear)</a>’ from Amazon for £6.49 ($8.96).</p><p>When it arrived, I connected it up to my Pi and voila, it started up and the fan spun up and did its job cooling the Pi constantly. But I wanted to take things a little further and thought about dynamically controlling the fan according to the CPU temperature. After a bit of Googling I came across the following site: <a href="https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python">https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python</a>. “Bees knees” I thought until I got to part 3 — build the test circuit. This was where hit an impasse. The problem I faced was not having a breadboard and circuit also I’m no electrical engineer so knowing how to make this was a little too complex for my liking.</p><p>After some more Googling I came across this site: <a href="https://www.tindie.com/products/jeremycook/ez-fan2-tiny-raspberry-pi-fan-controller/">https://www.tindie.com/products/jeremycook/ez-fan2-tiny-raspberry-pi-fan-controller/</a> An engineer by the name of Jeremy Cook has created a minute printed circuit board (PCB) that sits between the fan connectors and the GPIO connectors of the Raspberry Pi. So I purchase it, with the following add-ons: Clear Heat Shrink, Female ~8cm connector wires which came to $9.95 plus shipping to the UK which cost $15 (more than the item, but I thought it would be worth it), which brings the total cost to $23.99 USD. (Note if you are in the UK check out the <a href="https://thepihut.com/collections/raspberry-pi-cooling/products/fan-controller-for-raspberry-pi">Fan Controller for Raspberry Pi</a> sold on thePiHut for only £4.20)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TuVLiwbUvxSVqyilgvLLyQ.png" /><figcaption>Ensure you purchase the additional options if you don’t already have them</figcaption></figure><p>Check out Jeremy Cook’s YouTube video on how he made it and installed it; <a href="https://www.youtube.com/watch?v=AdjU_AVcZTA">https://www.youtube.com/watch?v=AdjU_AVcZTA</a>. At 5:59 Jeremy shows a GPIO schematic of how to connect the wires to the EZ Fan 2.</p><p>Here’s my installation of the EZ Fan 2 connector:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-W2eHh6eIC7FATdRImsiw.jpeg" /><figcaption>Remember to test the fan and microchip before heating the shrink-wrap</figcaption></figure><p>Notice, green wire is on the top, yellow in the middle and blue at the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6zJQ0wgJr1_xQxfPHC3ksQ.jpeg" /><figcaption>I broke off one of the connectors of the spare wire and used it as a spacer in GPIO port 4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3s-ea3r3hkAsYLCDh6KbA.jpeg" /></figure><p>GPIO ports 2, 6 and 8 were used as per schematic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*9nRHK_-aqZYwPtP77vAkqQ.png" /></figure><p>Blue wire — port 2; 5V power</p><p>Connector spacer — port 4; 5V power</p><p>Green wire — port 6; Ground</p><p>Yellow wire — port 8; GPIO 14 (TXD)</p><p><strong>Now for the shell script to make it work dynamically</strong></p><p>Access the following link: <a href="https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python">https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python</a> and scroll down to part 4 — Use the install script and follow the steps verbatim (Pre-requisites: give your Raspberry Pi a static IP address, connect it to your router either via ethernet (preferred) or WiFi. You’ll also need to enable secure shell (SSH) on the Raspberry Pi and SSH into it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*HKj4z2cSQvHy4qcwtOo4dQ.png" /><figcaption>I created a directory in my home directory called check_fan and placed the fancontrol.sh script in there</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*5LSyaEp-COzoF9O7vpKUng.png" /><figcaption>access the check_fan directory using the cd command</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*zNQ24jkKkNtCzD4_gV3fHg.png" /><figcaption>listing the contents of the check_fan directory (ls -altr) shows the presence of fancontrol.sh so use the cat command to examine the contents of fancontrol.sh. This shows that fancontrol.py is accessed which is present in the /usr/local/bin directory</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*JHo6c3O8Yvc0g1rvRin3eQ.png" /><figcaption>change directory to the /usr/local/bin directory using the cd command and listing the contents using ls -altr shows the presence of the fancontrol.py file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*9OlyGySwMKV-K6ZFXwe01g.png" /><figcaption>enter nano fancontrol.py to edit this file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iySFpeZ1oNxQvEF1Lw_YLg.png" /><figcaption>The only values you need to alter are highlighted in red. I’ve set my ON_THRESHOLD TO 50 AND OFF_THRESHOLD TO 40. Save your changes and exit this file</figcaption></figure><p>That’s it! All done. Since we’ve used the installer script in step 4 of <a href="https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python">https://howchoo.com/g/ote2mjkzzta/control-raspberry-pi-fan-temperature-python</a> it has already been registered to run on boot.</p><p>Reboot the Raspberry Pi with the following command:</p><pre>sudo reboot</pre><p>This will reboot your Pi and your fan should be running dynamically.</p><p>Time to test it…</p><ol><li>Access the check_fan directory and create a file called measure_temp.py in nano</li><li>Copy/paste this into the file:</li></ol><pre>#!/bin/bash</pre><pre>while [ true ]</pre><pre>do</pre><pre>myTemp=`/opt/vc/bin/vcgencmd measure_temp | egrep -o &#39;[0-9]*\.[0-9]*&#39;`</pre><pre>myDate=`date &#39;+%Y/%m/%d %H:%M:%S&#39;`</pre><pre>echo $myTemp $myDate</pre><pre>sleep 3</pre><pre>done</pre><p>3. Save the file and exit using the ctrl+z keys</p><p>4. Give the file executable attribute by typing:</p><pre>chmod +x measure_temp.py</pre><p>5. The run above script:</p><pre>./measure_temp.py</pre><p>The moment the temperature rises to above 51 degrees the fan is activated and the temperature is bought down to 40 degrees after which the fan switches off.</p><p>So there you have an inexpensive fan and a script to dynamically control the fan of your Raspberry Pi. Please leave a comment if you have any questions, concerns or comments. If you’ve managed to replicate this and it’s worked for you please leave a clap… :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ff0e59985fc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/how-to-install-a-fan-onto-a-raspberry-pi-and-make-it-run-dynamically-4ff0e59985fc">How to install a fan onto a Raspberry Pi and make it run dynamically</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the Raspberry Pi and why you should buy one]]></title>
            <link>https://medium.com/codex/what-is-the-raspberry-pi-and-why-you-should-buy-one-aaae7f417b63?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaae7f417b63</guid>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[hobby]]></category>
            <category><![CDATA[computing]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Sat, 11 Sep 2021 17:27:45 GMT</pubDate>
            <atom:updated>2021-09-15T12:20:39.038Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*wfDns4m2SQAFeziJcKOyHg.png" /><figcaption>Image courtesy of <a href="http://www.adafruit,ci/">www.adafruit</a>.com</figcaption></figure><p>The Raspberry Pi is a single-board computer that debuted in 2012 and is now in its fourth generation. It is one of the best-selling British computers of all time and as of May 2021 has sold over 40 million boards globally. Here I’m going to explain why you should buy and one and what you can do with it.</p><p>Firstly, it is a computer to learn things on. You need an existing computer already with an internet connection to download the Raspberry Pi OS operating system and load it to the memory card which is inserted into the Raspberry Pi. It can connect to a TV/monitor with a HDMI lead and you can use your existing keyboard and mouse with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*WEHfhH7qdtCgmcDHrawIpA.jpeg" /><figcaption>The Raspberry Pi OS interface</figcaption></figure><p>It runs open-source software called Linux which means there’s no license like Microsoft Windows but still gives you all the functionality of a computer with a guided user interface (GUI) akin to Windows. The Microsoft Office equivalent on the Raspberry Pi is called Open Office which has most of the functionality of Microsoft Office but is completely free. It even has VBA (albeit some functions (APIs) are not supported) which can allow you to create macros. The Raspberry Pi OS contains it’s own web browser called Chromium which is like Chrome only suited for the Raspberry Pi.</p><p><strong>So What Can you use it for?</strong></p><p>Learn and operate Linux</p><p>First and foremost, you can learn to use the Linux operating system via a Terminal on a Raspberry Pi. This is an open-source command line operating system which is far more powerful and flexible than the command-prompt in Windows. Many large corporations use UNIX-based servers including financial institutions and software houses. Learning to navigate in Linux, edit files in editors such as nano/vi and write shell scripts (programmable Linux scripts) can help you massively if you work for corporations that utilise this.</p><p>Learn Programming languages, SQL and connect up hardware accessories</p><p>You can install programming languages like Python and Scratch onto it and even databases such as MySQL and load schemas to aid or brush up your understanding of SQL. Great for budding coders and computer scientists alike. What’s more, you can create all kinds of projects using the Pi such as temperature monitors, light sensors, motion sensor CCTV to name but a few. The shear possibilities are endless, check out the website <a href="http://www.thepihut.com/">www.thepihut.com</a> for the range of accessories available.</p><p>Check out this link for a comprehensive list of things you can use a Raspberry Pi for: <a href="https://www.makeuseof.com/tag/different-uses-raspberry-pi/">https://www.makeuseof.com/tag/different-uses-raspberry-pi/</a></p><p><strong>So what do I use a Raspberry Pi for?</strong></p><p>I personally use my Raspberry Pi as a ‘headless’ unit; one that is connected to the home router via ethernet cable, and I remotely access it via a Terminal on my Mac computer.</p><p>One of the best uses for a Raspberry Pi for me at least are to run a private VPN so I’m able to access my home CCTV and home network access storage (NAS) drive remotely from anywhere in the world securely. This is achieved by a program called WireGuard which has a client installed on each of my devices; iPhone, iPad, MacBook that connect to the home network.</p><p>PiHole is another excellent program which removes the bulk of the nuisance adverts that plague websites making your surfing experience that little bit more enjoyable.</p><p>Deluge is a torrenting application that is accessed via a browser and instead of using a computer to download torrents the Raspberry Pi can do so with ease. This way any malicious files (which you’ve inadvertently downloaded) are stored on the Pi in a Linux operating system and are unlikely to cause harm to your other venerable Windows and Mac computers. If you happen to own a NAS drive (which I do) you can simply transfer files from the Raspberry Pi to the NAS drive easily. This way the downloaded files are available for all computers that are on my home network.</p><p>Recently I’ve been learning to ‘dockerise’ my applications (namely PiHole, WireGuard and Deluge). This allows better use of the Raspberry Pi resources by “virtualisation” of the Linux operating system (check out one of my favourite YouTubers; Network Chuck’s clip for more info — <a href="https://www.youtube.com/watch?v=9FtERdqKa2s">https://www.youtube.com/watch?v=9FtERdqKa2s</a>).</p><p>Conclusion</p><p>I’d recommend the 4GB Raspberry Pi 4 Model B which costs between £50 to £60 ($69 — $83) from eBay or Amazon or thePiHut.com. This is a perfect computer for children to learn computing skills (and to give them a break from their smart phones or game consoles) on or even people working in IT that want to learn about more computing and tinkering. You’ll need a power supply cord, a case, a fan and a mouse and keyboard and don’t forget a micro HDMI lead to connect it to a monitor/TV.</p><p>In subsequent articles I’ll explain how I installed and configured a dynamic fan (which actively monitors the CPU temperature and switches the fan on and off accordingly), how I configured WireGuard, PiHole and Deluge via Docker. Stick around…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaae7f417b63" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/what-is-the-raspberry-pi-and-why-you-should-buy-one-aaae7f417b63">What is the Raspberry Pi and why you should buy one</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Start the day right with a good oral hygiene routine and end the day the same way]]></title>
            <link>https://miteshparmar1.medium.com/start-the-day-right-with-a-good-oral-hygiene-routine-and-end-the-day-the-same-way-20334578b860?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/20334578b860</guid>
            <category><![CDATA[good-habits]]></category>
            <category><![CDATA[aesthetics]]></category>
            <category><![CDATA[general-health]]></category>
            <category><![CDATA[oral-health]]></category>
            <category><![CDATA[personal-hygiene]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 07:47:11 GMT</pubDate>
            <atom:updated>2021-08-08T07:47:11.619Z</atom:updated>
            <content:encoded><![CDATA[<h4>Good oral hygiene is paramount to healthy teeth and gums and keeping your pearly whites white (or off-white as in my case). Implement this routine to keep your oral hygiene at it’s best…</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*jd54bb0xHrJDo3o7TwTr_g.jpeg" /><figcaption>image courtesy of onlinecourses24x7.com</figcaption></figure><p>Good gum health sports the aesthetics of a good smile and highlights the overall health of an individual. Whenever you meet or speak to someone have you noticed how your focus is on their teeth the moment they smile. The mouth is where peoples eyes fixate on like it or not, so it’s vital to keep your smile looking as healthy as possible.</p><p>I’m fortunate enough to have a dentist who was my childhood neighbour and good friend. He’s been looking after my teeth for several years now and I wouldn’t change him for the world. One day I went for lunch at his place and the conversation turned to oral hygiene. The one statement he mentioned that has stuck with me was “<em>It’s a bloody good job everyone doesn’t look after their teeth like you do, otherwise I wouldn’t be paid the money I am!</em>” This statement made me laugh and is also ingrained in my memory. Yet my brushing routine is so simple and so effective the only thing I pay my dentist for is a routine check up which involves a scale and polish semi-annually. I’ve never had any tooth rot or serious gum problems in my life.</p><p>I thought I’d share with you my oral hygiene routine to keep my teeth and gums looking their best. Being a software programmer I tend to think in algorithms (I think this is the norm of most programmers). An algorithm is simply a sequence of steps to accomplish a task. I’ve implemented an algorithm to my dental brushing technique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lufv53bw7KLyWlEuOiy3g.jpeg" /><figcaption>My bathroom cabinet shelf dedicated to my oral hygiene (the manual toothbrush is for guests)</figcaption></figure><h4>Flossing is not enough!</h4><p>My dentist has recommended inter-dental sticks combined with flossing and brushing. These sticks have little brushes which allow you to clean out any food debris and plaque that has built up in the gaps. I use the TEPE interdental brushes (<a href="https://www.amazon.co.uk/dp/B0010EOND0/ref=redir_mobile_desktop?_encoding=UTF8&amp;aaxitk=9ab9db9c59ed9481405616e2a1e63f6c&amp;hsa_cr_id=1765670470402&amp;pd_rd_plhdr=t&amp;pd_rd_r=101f2a23-a202-459e-b2f5-57936cf8c6fc&amp;pd_rd_w=TWXEh&amp;pd_rd_wg=FnFds&amp;ref_=sbx_be_s_sparkle_mcd_asin_0_img">https://www.amazon.co.uk/dp/B0010EOND0/ref=redir_mobile_desktop?_encoding=UTF8&amp;aaxitk=9ab9db9c59ed9481405616e2a1e63f6c&amp;hsa_cr_id=1765670470402&amp;pd_rd_plhdr=t&amp;pd_rd_r=101f2a23-a202-459e-b2f5-57936cf8c6fc&amp;pd_rd_w=TWXEh&amp;pd_rd_wg=FnFds&amp;ref_=sbx_be_s_sparkle_mcd_asin_0_img</a>) since they have different sizes to use in the different sized gaps in between your teeth. Typically I use these every other day as well as flossing. It is imperative to use this after eating sweet popcorn so those sugar coated kernels are removed from the gaps in your teeth.</p><h4>Use an electric toothbrush</h4><p>Electric toothbrushes are far more superior than a manual tooth brush. I have the Oral B Braun electric toothbrush from circa 2009 which I believe was over-engineered. It doesn’t have the bells and whistles of todays electric toothbrush like the 30-second pulse to inform you that a quarter of your mouth is complete or the red light to inform you your pressing too hard. Yet this toothbrush just keeps on going. The battery lasts for almost 5 days before dying and after charging for 24 hours it’s rearing to go.</p><h4>Buy a good water-resistant stop-watch</h4><p>If you spend too much time brushing your teeth for too long you will end up brushing the enamel off the teeth. This is known as toothbrush abrasion which exposes the tooth roots which could rot. That’s why is important to time yourself so you don’t spend too much time brushing but enough time to clean them throughly. I bought a water resistant stop-watch from eBay for less than £3 ($4.20) which I keep in the bathroom cabinet. I use this every time I brush my teeth and gums.</p><p>Here’s my complete teeth and gum brushing algorithm:</p><ol><li>Place a small amount of toothpaste on the brush head and run it under the tap for a second to soften it.</li><li>Start the stop-clock and start brushing the very back of the bottom right set of teeth using a slow back and forth motion. The brush head should swing through almost 180 degrees. Monitor the stop-clock as the seconds progress (towards 30 seconds) bring the brush slowly towards the front centre of the mouth continuing the slow back and forth motion.</li><li>Once 30 seconds have passed repeat this process for the remaining 3 quarters of your teeth; bottom left set starting at the very back, then the top right starting at the very back followed by the top left also starting at the very back.</li><li>After 2 minutes you’ve completed all 4 quarters of your mouth. For the next 30 seconds bite your teeth together so your front top teeth are in-line with your bottom front teeth and slowly brush up and down from one side of your mouth to the other to brush the top and bottom set concurrently. As the clock progresses from 2 minutes to 2 minutes 30 seconds you will have brushed the entire top and bottom set from one side to the other.</li><li>The stop-clock should read 2 minutes and 30 seconds so for the next 30 seconds brush your upper gums starting from the back of one end slowly moving the toothbrush to the other end so it ends on the other side after 30 seconds.</li><li>Repeat step 5 for your lower gums.</li></ol><p>The total time taken to brush your teeth and gums should be 3 minutes 30 seconds. Let the brush do all the work and don’t press hard. <strong>NOTE: At no point do I use a rapid up and down motion across my teeth as with a manual tooth brush.</strong></p><h4>Clean the tongue with a tongue scraper</h4><p>Using a tongue scraper can help prevent bad breath (halitosis) by removing volatile sulphur compounds (VSCs). Use it immediately after brushing your teeth. Tongue scrapers are available in metal or plastic. They tend to be either a spoon-like shape or a U-shaped metal device with two handles.</p><p>Here is my tongue scraping algorithm:</p><ol><li>After brushing open the mouth wide and place the tongue scraper on the furthest reachable point on the back of the tongue.</li><li>Apply gentle pressure and pull the scraper forward toward the tip of the tongue. There should not be any pain when you do this.</li><li>Rinse the scraper with warm water and repeat if necessary.</li><li>Rinse your mouth with water and split it out.</li><li>Clean the tongue scraper with soap and warm water regularly</li><li>Clean the tongue scraper thoroughly with soap and warm water.</li></ol><h4>Use mouthwash to freshen breath</h4><p>Finally, use mouth wash to freshen your breath and you’re ready for the day ahead or a good nights sleep.</p><p>Apply this technique the moment you wake up and just before bedtime every day and you shouldn’t have any tooth decay /gum disease issues for the rest of your life. Also ensure that you don’t eat too many sugary foods. I generally have a fizzy drink shared with someone else once every 3–4 days (my fizzy drink of choice is Dr. Pepper with rum). Drinking any acidic drinks 30 minutes to one hour before bedtime is an absolute no no since brushing your teeth after consuming this would be akin to taking wire wool to a new paint job on a car.</p><p>Any questions please let me know. I hope this article is of benefit to you. If so please leave a clap…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20334578b860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Forget diets, simply cut out your refined sugars and integrate intermittent fasting into your…]]></title>
            <link>https://miteshparmar1.medium.com/forget-diets-simply-cut-out-your-refined-sugars-and-integrate-intermittent-fasting-into-your-8fa80d6dcbd3?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fa80d6dcbd3</guid>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[weight-loss]]></category>
            <category><![CDATA[lifestyle]]></category>
            <category><![CDATA[diet]]></category>
            <category><![CDATA[slimming]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Thu, 15 Apr 2021 16:49:26 GMT</pubDate>
            <atom:updated>2021-04-15T16:49:26.941Z</atom:updated>
            <content:encoded><![CDATA[<h3>Forget diets, simply cut out your refined sugars and integrate intermittent fasting into your lifestyle…</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZU6_vBHvCYVIu86bwYrD_w.jpeg" /></figure><p>You heard me right, forget about diets, forget about calorie counting, forget about points and only eating certain foods with a certain number of points. Forget about diet classes. The more you restrict yourself from the food and drinks you like the more likely it is to fall off the wagon! If you want to loose weight and be in shape just cut out as much refined sugar as you can and fast 2–3 times per week on non-consecutive days. It really is that simple!</p><p>My journey into intermittent fasting started in 2016, I was 36 years old and realised that eating thrice a day I had a small but apparent gut. This was despite eating healthy foods and attending the gym 3 to 4 times per week. I decided to book a health assessment at my gym (which was free to members on a quarterly basis). My measurements were taken and I was given a health score of 65 out of 100. Not bad I thought, but not great. I told my assessor (who was also a fitness instructor) that I wanted to loose the weight around my midriff. He told me to cut out all my sugar and if I’d heard of intermittent fasting. So basically, drink my tea and coffee with no added sugar or syrups, don’t eat sweets and no fizzy drinks (only the odd cordial). At almost the same time me and my wife (who is the same age as me) watched a documentary on intermittent fasting on the BBC presented by Dr. Mike Mosely who gave an in-depth insight into why fasting works so well. I also bought the book ‘The Fast Diet’ (<a href="https://www.amazon.co.uk/Fast-Diet-Healthy-Revised-Updated/dp/1780722370/ref=sr_1_3?dchild=1&amp;keywords=5%3A2+diet&amp;qid=1617777162&amp;sr=8-3">https://www.amazon.co.uk/Fast-Diet-Healthy-Revised-Updated/dp/1780722370/ref=sr_1_3?dchild=1&amp;keywords=5%3A2+diet&amp;qid=1617777162&amp;sr=8-3</a>). After reading it, we both thought I’d give it go and fast on Tuesdays and Thursdays; days which were mundane and predictable, also days which didn’t involve us socialising with anyone.</p><p>Within a matter of weeks our body weight started to fall. For me it was most obvious around the waist, I went from a waist size 34” to between 31” and 32”. I had to use my dad’s hole punch kit to put a new hole at the end of my leather belts. The fat around my neck disappeared too and I was able to close the top button of my work shirts for the first time in ages. My gut disappeared, and my body started to adopt the “V-shape”. My abdominal muscles became more visible through my T-shirt and I actually enjoyed wearing fitted clothing. We felt a whole lot better too. My wife told me my snoring had eased and she could get a better nights sleep (especially on the nights I wasn’t drinking alcohol). As for her, she started looking more shapely too and some of her old dresses she bought in her late 20’s/early 30’s started to fit her better. The fat around the triceps disappeared. We both felt lighter, more energetic and much more comfortable from fasting only twice a week.</p><p>We continued this fasting programme twice per week, eating the foods we enjoyed on the days we didn’t fast and drinking alcohol perhaps once or twice per week. After six months of this we both noticed that our body weight would not drop anymore. We both hit a plateau stage and if we wanted to loose any more weight we’d have to fast an extra day in the week. I tried this on a Saturday for a few weeks and I noticed that I did loose a little more weight around the waist. My waist went to a size 31” which was exactly where I wanted to be. I have been fasting 2–3 days a week ever since.</p><p><strong>The fast days</strong></p><p>We aim for a “hearty” breakfast; salmon on toast or avocado and poached egg on toast. Eating protein kept us fuller for longer. We skipped lunch and ate a small evening meal. The foods we ate were omelettes of two eggs each or a Caesar salad. I aimed at keeping my daily intake around 600 700 calories; 350 in the morning and 350 in the evening. I had a pint glass on my desk which I filled with water and drank throughout the day, this also helped keep the hunger pangs at bay which would typically occur in the afternoon. The one thing I did notice was that my breath started to smell unpleasant, akin to rotting flesh. This was because my body was undergoing “ketosis”; instead of burning glucose; body’s immediate source of energy it was burning fat. This was alleviated by chewing some sugar free gum (especially if I was talking to someone face to face).</p><p><strong>The non-fast days</strong></p><p>The one thing we needed to be aware of was not to overeat the day after the fast. Just a bowl of cereal for breakfast and a salad for lunch, but more importantly we could enjoy the foods we loved eating and looked forward to these on the weekends. Chocolate eclairs, almond croissants, chocolate chip cookies, as long as it was in moderation and balanced with plenty of fresh fruit and vegetables we enjoyed it.</p><p><strong>Intermittent fasting won’t get you ripped</strong></p><p>I still have body fat but it is around the 10–15% which is a good healthy level. I can still pinch my belly fat sitting down but it’s far less than an inch. This is known as “subcutaneous fat”; good fat which sits below the skin. What has gone is my visceral fat; dangerous fat that surrounds organs and can lead to heart disease. I’ll never look like a professional body builder doing this; that requires eating six small meals a day of pretty much the same thing each day and no sweet treats at all for months on end (only having a single “cheat” day per week).</p><p><strong>Making fasting part of my lifestyle</strong></p><p>At the gym I spoke to a fitness instructor who was of muscular build. He informed me that he did the 16:8 several times a week; eat for 8 hours of the day and fast for 16. So, if I was to do this all I needed to do was swap my skipping lunch for skipping breakfast or dinner. So, this is what I’ve integrated into my lifestyle. Tuesdays and Thursdays I have breakfast and lunch and skip dinner. I ensure that 4pm is the cut-off time after which I don’t eat anything and only drink water. By doing this the fasting period is stretched to as long as possible; from 4pm to 7–8am the next day; 16 hours. I’m no movie-star, nor do I intend to be. I just wanted my clothes to fit better and be in shape and reduce the risk of heart disease and diabetes, that’s all that really matters to me and my wife.</p><p>As my fitness instructor mentioned “the diet is the clay, the gym is the scalpel, not the other way round’. 70–80% of your body weight is defined by your diet. The other 20–30 % is defined by your exercise regime. If you do more cardio-vascular exercises you’ll be more leaner. If you do more weight-based training, you’ll me more muscular. If you combine the two you’ll be leaner and more muscular providing you eat the right amount of proteins and carbohydrates. If you’ve never hit the gym (you can’t here in the UK due to lockdown) and you want to integrate fasting into your lifestyle to loose weight just plan which days suit you during the week and be strict on yourself. I recommend the book I bought by Dr. Mike MosIey and this has worked wonders for me and my wife and it should for you too (NOTE: consult your doctor if you have any medical conditions before you do fast. It’s not recommended for pregnant women or those with diabetes but there are other variations of this).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fa80d6dcbd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embed TensorBoard into your Google Colab window when using Google Drive with 2 lines of code]]></title>
            <link>https://medium.com/codex/embed-tensorboard-into-your-google-colab-window-when-using-google-drive-with-2-lines-of-code-a3e3320d9386?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3e3320d9386</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[google-colab]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Tue, 13 Apr 2021 14:51:11 GMT</pubDate>
            <atom:updated>2021-04-13T14:51:11.973Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PziIo0yWh9K9ZRhc-DEhsw.png" /></figure><p>Google Colab provides an embedded Jupyter Notebook which can integrate with your Google Drive to access files. Its ace-card is the free use of GPU (graphical processing unit) which would otherwise be a very costly purchase if used on your local computer. It provides a perfect environment for all your machine learning / deep learning projects.</p><p>Tensorboard is the “eyes and ears” of your neural network model that has been trained. It graphs the accuracy and the loss of your model that has undergone training thus allowing you to visualize the results in an accuracy graph and a loss graph.</p><p>We shall use YouTuber sendex’s DogvsCat tutorial on Tensorboard model analysis as a worked example: <a href="https://pythonprogramming.net/tensorboard-analysis-deep-learning-python-tensorflow-keras/">https://pythonprogramming.net/tensorboard-analysis-deep-learning-python-tensorflow-keras/</a></p><h4>Pre-requisites:</h4><p>1. Tutorials part 1 to part 5 on Introduction to Deep Learning by sendex</p><p>2. Google Drive access (requires a Google account)</p><h4>Let’s get started:</h4><p>Open Google Colab and mount your Google Drive using the folder icon on the left-hand side, then click on the last folder to mount your Google Drive:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*ZY_aKpr1Iit4eLeI3Rl5aA.png" /></figure><p>Click on ‘CONNECT TO GOOGLE DRIVE’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*dszb9m-b38E3sZ_Rhf3mTg.png" /></figure><p>Create a ‘logfiles’ folder and within that create a ‘catvsdoglogs’ folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*BjIinhdSe4iUE4Yyzwm-NA.png" /></figure><p>Click on the ‘logfiles’ directory, right-mouse click, and select ‘Copy path’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*0_IEKq4hX_IKQ9-Mbo3rhA.png" /></figure><p>The first code cell contains the import statements and the global variables. Paste the clipboard contents into a variable called ‘pathoflogsdir’ and equate the first parameter of TensorBoard; log_dir to pathoflogsdir + ‘catvsdoglogs/{}’</p><p>Execute the code cell to ensure the NAME variable is correctly shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*n-_HNUs9ijccE1pVxoKR8g.png" /></figure><p>Click on the datasets folder, right-click and select ‘Copy path’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*-Z9bu4Ppeoq9mdrdrzfJiA.png" /></figure><p>In the second code cell paste the clipboard contents and assign them to a variable called ‘path’. Run the code cell to ensure both variables X and y are of type numpy.ndarray.</p><p>NOTE: use the np.asarray function to convert y from a list to a numpy array:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*qx5Irii_2ahzncKByOOVnw.png" /></figure><p>On the final line of the third code, cell ensure the final parameter shows</p><pre>callbacks=[tensorboard]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lkxMDhx7cvC3HH0rDfv9mw.png" /></figure><p>Copy the path of the ‘catvsdoglogs’ folder again from the left-hand side:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*ZCJo10xGG4uJFafs8KPMhg.png" /></figure><p>In the final code cell, the first line should be %load_ext tensorboard. The second line should show %tensorboard –logdir= {paste text from clipboard}:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YORvBzzsI5HnWvX_9zoKEQ.png" /></figure><p>Scroll back to the first code cell that was executed and highlight the name that was shown and copy the name variable to the clipboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*5pPixm4xZ-eUQhCnzsuawg.png" /></figure><p>Paste (Ctrl + V) the clipboard contents and insert double-quote to close off the string value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A59gRfJKJeOOVkLDBohePw.png" /></figure><p>Click on ‘Runtime’ and click on ‘Change runtime type’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*2BLQUWzYb4v2ug35AkowzA.png" /></figure><p>Click on the down arrow and select ‘GPU’ from the drop-down list and click on ‘SAVE’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*ZYPlSCfvxGYU8RToNOUOlw.png" /></figure><p>Click on Runtime and click on ‘Run all’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*xiuuFaNNaS_HbLebGX66tg.png" /></figure><p>This will display the tensorboard results in the current browser tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h0Gb_gxShhOD5YhZnPb_Zw.png" /></figure><p>Happy Colab coding and analyzing the results in tensorboard! If this article helped you please leave a clap.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3e3320d9386" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/embed-tensorboard-into-your-google-colab-window-when-using-google-drive-with-2-lines-of-code-a3e3320d9386">Embed TensorBoard into your Google Colab window when using Google Drive with 2 lines of code</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dealing with Deprecation in TensorFlow — Fixing a Convolutional Neural Network model using a…]]></title>
            <link>https://medium.com/codex/dealing-with-deprecation-in-tensorflow-fixing-a-convolutional-neural-network-model-using-a-worked-dc3113b93049?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc3113b93049</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[colab]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[convolutional-network]]></category>
            <category><![CDATA[tensorflow]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Mon, 05 Apr 2021 07:11:11 GMT</pubDate>
            <atom:updated>2021-04-05T21:19:22.434Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dealing with Deprecation in TensorFlow — Fixing a Convolutional Neural Network model using a worked example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*VEwaEHeWX0ys4ob8dQHCAg.jpeg" /></figure><p>Deprecation occurs in all software and AI libraries are no exception. In fact, the TensorFlow libraries are notorious for being deprecated. TensorFlow is Google’s deep learning library which was launched in 2015 and has been evolving ever since.</p><p>I’m following YouTuber sentdex who has created a series of excellent follow-along machine learning and deep learning tutorials. Here is an example of a convolutional neural network (CNN) that was created by sentdex in 2018 and it worked seamlessly until TensorFlow deprecated one of its functions. (The tutorial can be found here: <a href="https://pythonprogramming.net/convolutional-neural-network-deep-learning-python-tensorflow-keras/">https://pythonprogramming.net/convolutional-neural-network-deep-learning-python-tensorflow-keras/</a>)</p><p>I’d like to share with you the approach I took to resolve this issue for two reasons; one, you can get this CNN algorithm working in your environment (I’m using Google Colab which I highly recommend), but more importantly if you encounter a similar issue, you can apply the same methodology that I have done to fix your deprecated algorithm and get it working again.</p><p>Let’s get started…</p><p>Pre-requisites:</p><p>1. Complete the previous two tutorials in the Deep Learning module:</p><p>Introduction to Deep Learning — Deep Learning basics with Python, TensorFlow and Keras p.1 (<a href="https://pythonprogramming.net/introduction-deep-learning-python-tensorflow-keras/">https://pythonprogramming.net/introduction-deep-learning-python-tensorflow-keras/</a>) and Loading in your own data — Deep Learning basics with Python, TensorFlow and Keras p.2 (<a href="https://pythonprogramming.net/loading-custom-data-deep-learning-python-tensorflow-keras/">https://pythonprogramming.net/loading-custom-data-deep-learning-python-tensorflow-keras/</a>). This will result is creation of the pickled objects; X.pickle and y.pickle</p><p>2. Mount your Google Drive in Colab. If you don’t know how to do this, follow my article titled: ‘Mounting Google Drive in Google Colab with 3 mouse clicks’: <a href="https://miteshparmar1.medium.com/mounting-google-drive-in-google-colab-with-3-mouse-clicks-8d38d681aad5/">https://miteshparmar1.medium.com/mounting-google-drive-in-google-colab-with-3-mouse-clicks-8d38d681aad5\</a></p><p>I placed the import statements in the first code-cell and the loading of the pickled objects in the second code-cell. Executing each using the play button resulted in no errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*o3gqIaFS71rmhPgcDTSDOA.png" /></figure><p>The third code cell contains the code for building and training the CNN model. Executing this after the above resulted in two errors shown below (also notice how line 27 the model.fit() function is highlighted in squiggly red):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOjYOCRLCPS1C2zgE-GINw.png" /></figure><p>Immediately the first error points to line 27; model.fit() function. The second error is an internal tensorflow python script which is being called that points to line 1359; “arrays found following type in the input: {}”.format(unsplitable)).</p><p>Just above this line in blue it states “`validation_split` is only supported for Tensors or Numpy “.</p><p>What does the above error message mean?</p><p>By the looks of things it means our code has errored because we’ve supplied parameter validation_split in the model.fit() function. The sentence in blue tells us that validation_split is only supported for datatypes that are either Tensors or Numpy.</p><p>So this is our issue. But the error description is somewhat brief so we’ll delve deeper to get a better understanding.</p><p>We know that ‘model’ is a variable of type Sequential right? If you’re sceptical you can always use the print(type()) function to check any variable data-type which you declare below the assignment of the variable as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2x5jHF_7nYo1kwWV18neA.png" /></figure><p>Next let’s Google search Tensorflow Sequential to get more information on it…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*x5yQAAKHIvKZtAu-jDzJeQ.png" /></figure><p>The search first result is the official Tensorflow documentation webpage so click on that…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*sSEaEdjKu5pNdysY_H0iAw.png" /></figure><p>Displayed is the Sequential function details of the Tensorflow API; the one place any developer must to go to find details of how a function pertaining to the Tensorflow library works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6eaiUIcnKlti34T_l7bGg.png" /></figure><p>We know from the highlighted squiggly red line in our code that model.fit() is where the error occurs so scroll this webpage and find the fit function:</p><p>The first function is strike-lined since it is no longer applicable and has been replaced by the one with a green background. If you look closely and compare the two you can see that some parameters have changed e.g. verbose=1 has become verbose=’auto’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*7OgOfIuM3_GQbD9dmznunQ.png" /></figure><p>Scrolling further down to the parameters section shows the following for x and y:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*NLSy_IXydMUK2_vgtxf1oQ.png" /></figure><p>This is the crux of this problem! Basically, it tells us that x; the first parameter and y; the second parameter can ONLY be of a few types as stipulated.</p><p>Going back to our script, we can examine the datatypes of our loaded pickled objects; X and y using the type() function nested within print() function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*i71bf9o0B2j7jtRh4JCPqg.png" /></figure><p>It shows us that X is a numpy.ndarray and y is a list object.</p><p>So from examining the Tensorflow API, we know that X is a supported datatype:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*V9E6xQ9AXftb2NoMFDrNAw.png" /></figure><p>And, we also know that y is an unsupported datatype:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*I7jOuOQJPYrD9DUtJC5mGQ.png" /></figure><p>As stated, y can ONLY be of type Numpy array(s) or TensorFlow tensor(s) and it should be consistent with x.</p><p>In our case since X is of type Numpy.ndarray we NEED y to also be of type Numpy.ndarray.</p><p>So how do we convert a standard Python list object into a Numpy.ndarray object?</p><p>Let’s Google it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*30wcesPODHRQwAfNxUOaeQ.png" /></figure><p>First result is the official numpy documentation so let’s click that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*G90C4ySXFhq5FKp-ObpRkQ.png" /></figure><p>So we need to use the numpy.asarray() function as stipulated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPPkdvihVNtKp9pugmzmoA.png" /></figure><p>As stated, the input data can be anything that can be converted into an array. This includes a list object. Since y has a datatype of type list we can use this function.</p><p>I inserted the ‘import numpy as np’ in code-cell 1 and executed it to reload the imports. In the second code-cell I simply insert the highlighted and one-liner comment above it to explain what it does. I executed code cell 2 and the print statement shows both X and y datatypes to be of type numpy.ndarray():</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TUbYJVJ5SFVItu4gohsYGA.png" /></figure><p>Executing the third cell code shows training, albeit incredibly slowly!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nv9Z3dWaC-GX2fhYRfDaUA.png" /></figure><p>Click on Runtime -&gt; Interrupt execution to halt the training in its tracks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*5WJLp0gdL-4dnSuSEe829g.png" /></figure><p>It’s time to make use of Colab’s free GPU.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fcourteousknobbykatydid&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fcourteousknobbykatydid-flash&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FCourteousKnobbyKatydid-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbeb84ddd2da01a768b780ab7f1d1947/href">https://medium.com/media/dbeb84ddd2da01a768b780ab7f1d1947/href</a></iframe><p>Click on Runtime -&gt; Change runtime type</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*_3gFDPzJAdgnbym5cLzJQQ.png" /></figure><p>From the dropdown under Hardware accelerator select ‘GPU’ and click ‘SAVE’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*tELyF7O3ETSgojeSxvHqHg.png" /></figure><p>Runtime -&gt; Run all:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*6kDwvlspcppXGcwV8jcHyA.png" /></figure><p>Training should now be considerably faster as it’s utilising the GPU instead of the CPU:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjW5J32zudO3Yxn2fh-laA.png" /></figure><p>I hope this article facilitates your understanding of deprecation and accessing the relevant APIs to fix the issue. Happy Colab training your fixed convoluted neural network. Any questions or comments just leave in the response section…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc3113b93049" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/dealing-with-deprecation-in-tensorflow-fixing-a-convolutional-neural-network-model-using-a-worked-dc3113b93049">Dealing with Deprecation in TensorFlow — Fixing a Convolutional Neural Network model using a…</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Properly pickle out to a path in Python when using Google Colab]]></title>
            <link>https://medium.com/codex/properly-pickle-out-to-a-path-in-python-when-using-google-colab-741f0905e68b?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/741f0905e68b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Fri, 02 Apr 2021 14:06:00 GMT</pubDate>
            <atom:updated>2021-04-02T14:06:00.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1lc7AlQSraq4FOOZNfgww.jpeg" /></figure><p>On your journey in learning machine/deep learning using Google Colab, at some point you will need to save out your trained model so it can be used at a later date. In the world of Python this is known as “pickling” (check out the official Python documentation of a detailed description: <a href="https://docs.python.org/3/library/pickle.html)">https://docs.python.org/3/library/pickle.html</a>).</p><p>If you’re using Google Colab and you want the pickled objects to be saved in your Google Drive you need to specify the exact path where you’d like the model to be saved.</p><p>Allow me to demonstrate…</p><p>Let’s look at an example code by YouTuber sentdex: Loading in your own data — Deep Learning basics with Python, TensorFlow and Keras (<a href="https://pythonprogramming.net/loading-custom-data-deep-learning-python-tensorflow-keras/?completed=/introduction-deep-learning-python-tensorflow-keras/">https://pythonprogramming.net/loading-custom-data-deep-learning-python-tensorflow-keras/?completed=/introduction-deep-learning-python-tensorflow-keras/</a>)</p><p>At the very bottom of the tutorial the following code is shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*HpvmAC4WuFnk4sREGYQ2Cw.png" /></figure><p>If we were to follow this verbatim Python would create two pickled objects: X.pickle and y.pickle but where would it be saved in Colab?</p><p>First and foremost, mount your Google Drive by clicking on the left most bottom icon then clicking the right icon:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/1*j112egEpFIPsseueCXh3XA.png" /></figure><p>Click on ‘CONNECT TO GOOGLE DRIVE’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*FQxQWA2KxxGO38knndHzwQ.png" /></figure><p><strong>Side note:</strong></p><p>I created a new folder in my Google Drive called ‘ugly images’ which is in the same location as the Dog and Cat folders:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvZV-jQgkjphSnceruF9tw.png" /></figure><p>Then I created this small function to move across any images caught by the exception clause; any ugly images which were present in the Dog and Cat folders. This helped clean out the images in the Dog and Cat folders.</p><p>I also created a counter variable so see how many times this loop executed for the Dog and Cat folders:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkPF4_gf4GP4M_-PRIh9Fg.png" /></figure><p>Don’t forget to include import shutil at the top in the import statements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*1T7ZL2havN5Mqk64uHSPHw.png" /></figure><p>Be warned: this script took over 1 hour to execute initially, so be patient. Subsequent executions only less than 2 minutes.</p><p><strong>Back to the main article:</strong></p><p>Let’s run the code to see where it places the pickled files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXZGFgkMQPoMUXk517RVow.png" /></figure><p>Execution of this ‘cell code’ results in the X.pickle and y.pickle appearing in the root directory. Note: it is NOT placed in your Google Drive that has been mounted.</p><p>So what can we do?</p><p>Option 1: Manually move the pickle files into a dataset directory in Google Drive by dragging and dropping:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*dr1mYXsjWZUUsHcA1DFLZQ.png" /></figure><p>This method does work:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*zQEQW2st_iPLxQZm7Th5Uw.png" /></figure><p>Option 2: Best method: Specify the path to the directory in our code when we pickle:</p><p>Right mouse click on the folder you would like to place the pickle files and click on ‘Copy path’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*4kjMd4luoy2N-oKx4IDzLA.png" /></figure><p>Scroll down to the bottom of the Python script where it states import pickle. Create a new variable called ‘path’ and paste the value copied to the clipboard. Ensure there is a forward slash at the end of the path (very important, otherwise it doesn’t work!). In the two pickle_out statements include the ‘path +’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7KPmt-pcdZR9wlQIru3IYQ.png" /></figure><p>Runtime -&gt; Run all:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*lUy1uwQeoVxk4USYmqi3Jg.png" /></figure><p>Lo and behold, the pickled files appear exactly where I want them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*GOg5yEyvjrIlchKsOu2l4Q.png" /></figure><p>In the final ‘code cell’ declare the path variable and assign it to the datasets location as shown. Include the ‘path +’ in the two pickle_in statements (as above). When this ‘code cell’ is executed on it’s own it doesn’t show any error messages meaning it ran seamlessly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*3xcNc_gfjWbIhqgSpHui6g.png" /></figure><p>Happy Colab pickling your trained objects…</p><p>Any questions or comments, feel free to leave in the response section…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=741f0905e68b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/properly-pickle-out-to-a-path-in-python-when-using-google-colab-741f0905e68b">Properly pickle out to a path in Python when using Google Colab</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dealing with deprecation in Machine Learning libraries — A step-by-step guide to resolving using…]]></title>
            <link>https://medium.com/codex/dealing-with-deprecation-in-machine-learning-libraries-a-step-by-step-guide-to-resolving-using-an-cb69ca6f4e10?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb69ca6f4e10</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 14:28:56 GMT</pubDate>
            <atom:updated>2021-03-31T18:44:35.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dealing with deprecation in Machine Learning libraries — A step-by-step guide to resolving using an example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2GeuvEfv8ITIRsNqmCzag.jpeg" /></figure><p>All software functions regardless of language evolve over time and as a result the functions that were used become obsolete and stop working. In my case, what was once only a few weeks or months ago a fully functioning machine learning / deep learning algorithm now sits a broken python script that didn’t run. In the programming world this is known as deprecation and Python machine learning libraries are no exception. So how do we deal with this?</p><p>Here I’ll demonstrate the problem of deprecation pertaining to a machine learning tutorial and how I went about fixing it. The aim of this article is to educate you if you’re not adept with the API documentation of libraries so if you suffer the same fate, you too can fix your programs with ease.</p><p>If you’ve read my initial Medium article titled ‘Getting Started with AI’ (<a href="https://miteshparmar1.medium.com/getting-started-with-ai-ml-nn-a-beginners-guide-b1659d6bffd7">https://miteshparmar1.medium.com/getting-started-with-ai-ml-nn-a-beginners-guide-b1659d6bffd7</a>) I talk about a YouTuber by the name of sentdex that has follow-along tutorials of learning machine learning and deep learning. One of his tutorials titled ‘Part 35 — Handling Non-Numerical Data for Machine Learning (<a href="https://pythonprogramming.net/working-with-non-numerical-data-machine-learning-tutorial/?completed=/machine-learning-clustering-introduction-machine-learning-tutorial/">https://pythonprogramming.net/working-with-non-numerical-data-machine-learning-tutorial/?completed=/machine-learning-clustering-introduction-machine-learning-tutorial/</a>) was written in June 2016 and unfortunately now (March 2021) has two deprecated functions so following this tutorial to the letter, copying and executing this code verbatim will not work.</p><p>Let’s examine this tutorial and go through the steps of how to fix it…</p><p>I’ve inserted the notes at the very top of the Python script in a ‘text cell’ with the links to the website and YouTube video. Then my import statements are inserted in the first ‘code cell’, shown at the bottom:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ml5ODkTyXm8EQwt7DjlT_Q.png" /></figure><p>I’ve mounted my Google Drive (as shown in the left hand column) and referenced the dataset accordingly. The second line assigns a variable ‘df’ to the dataset (which is a Pandas Dataframe object. NOTE: you can use the print(type(df)) function to determine the type of object df is). The last line in the cell code is to examine the data loaded using pd.read_excel(path). Executing this code cell shows the data present in a nice, neat table as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1yq_c9nibFR0JGLQcmnMvw.png" /></figure><p>Immediately below this I inserted a ‘text cell’ to state what needs to be done next (as stated by sentdex in this tutorial). Then I inserted another ‘code cell’ and entered the code which omits two columns from the loaded table (df.drop(columns=[‘body’, ‘name’]). The line errors when this code cell is executed: df.convert_objects as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWRi03Cpz2PjvPoBBz54jA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ctepk4ZIYBHjo1Hr6Bp0tg.png" /></figure><p>Our error is immediately telling us ‘DataFrame’ object has no attribute ‘convert_objects’ and highlights the erroneous code with a squiggly red line (line 5 of the code cell).</p><p>When a developer reads this, it immediately means that the convert_objects function of the Pandas DataFrame library does not exist.</p><p>Q. So what do we do next?</p><p>A. Use Google to do some investigation…</p><p>Hop on over to Google and type in our library name; Pandas, object name; dataframe and the function name; convert_objects and hit Enter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*j6xo_-CXccR4xeJZaI49wA.png" /></figure><p>The very first result in Google is the official pandas documentation, also known as the API (application programming interface. It’s the documentation of detailed descriptions defined by the developers of the library on how to use the functions and structure the code) so let’s take a look at this. Click on the link…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FfYsvjpdQvHPudD_pSyP9g.png" /></figure><p>Lo and behold, the documentation states “Deprecated since version 0.21.0”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmSC_lHE-3hl0qXhjjY5WA.png" /></figure><p>This is the crux of our problem! Basically, we are using a version greater than 0.21.0 which does not support this convert_objects function. Notice just above the ‘Deprecated’ red box highlighted states “<em>Attempt to infer better dtype for object columns</em>”. This is a description of what the convert_objects function does (dtype means data-types).</p><p>Unfortunately, this API documentation does not tell us what other alternative function to use instead either (probably because it’s not maintained and has been superseded).</p><p>So it’s back to Google and search for “pandas dataframe convert datatype” and press Enter:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*GAp1zmJKMUqCudKOhyA0LQ.png" /></figure><p>Our first result is the pandas official latest documentation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*VguIv6VMAZ1kkL88_qyTBQ.png" /></figure><p><strong>Side note:</strong></p><p>Version 1.2.3 is the latest version of Pandas, if you Google ‘what is the latest version of pandas’ it will tell you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*2HbXpkkvtIVS7bLzCkCN-A.png" /></figure><p>In Colab just below the ‘import numpy as np’ insert ‘print(pd.__version__)’ and execute that cell code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*L3FGifckK_jolq4wBLjvpA.png" /></figure><p>Ok, so Colab is not running the latest version of Pandas but is running version 1.1.5 which is more recent than sentdex’s tutorial with the deprecated function. Don’t worry, you don’t have to update Pandas in Colab. This version will still work.</p><p><strong>Back to the main article:</strong></p><p><a href="https://pandas.pydata.org/">https://pandas.pydata.org/</a> is the official site of the most recent Pandas API documentation. So click on that first link shown in Google.</p><p>Now we need a function starting with ‘convert’ so let’s type this into the search bar and hit enter. The first function shown in the results list is pandas.DataFrame.convert_dtypes. This looks like it may be of interest so click the link…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CObXJyLA7zTURofG9hkVyQ.png" /></figure><p>The latest Pandas API documentation highlights in yellow the word we are searching for, in our case ‘convert’. The description highlighted in red reads “Convert columns to best possible dtypes using dtypes supporting pd.NA”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f7IKrdvLXPYczSdzj0Fktg.png" /></figure><p>Looks like we’re onto a winner with this function! Scroll down to the Notes section for a more detailed description:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*5-TVcRYDwXnnTgIrTxt4uw.png" /></figure><p>The first paragraph tells us exactly what this function will do; attempt to convert a Series or a Series in a DataFrame to dtypes that support pd.NA. The second highlighted section tells us that this function will attempt to convert any integer datatypes into an appropriate integer extension type ( I don’t want to teach you to “suck eggs” but I thought I’d mention this so you read it rather than skim over it).</p><p>Scrolling further down shows an excellent example, starting with creating a Pandas dataframe object of various datatypes, displaying the datatypes, creating a variable; dfn of the convert_dtypes() function and then displaying the datatypes once this function is run:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*C1IiPVaSw6oSiLPaFjqRDA.png" /></figure><p>As shown, NaN values are replaced with &lt;NA&gt; and a comparison of the data-types shows that what were ‘object’ datatypes are now converted into ‘string’ or ‘boolean’. int32 has become Int32 and in column e float64 datatype has become Int64.</p><p>Scrolling to the final part of the page shows us another example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*eBntmJK6WoRyJpCf76h-sQ.png" /></figure><p>Fundamentally it shows us that if NaN is present, the convert_dtypes() function will change it to &lt;NA&gt; which can be dealt with in our Python script.</p><p>This convert_dtypes() function is the “bees knees”! It’s exactly what we need to replace the deprecated unsupported convert_object() function.</p><p>Let’s put it in our Python script, comment out the deprecated function and write a comment just above it. Executing everything up to this ‘code cell’ now shows another error, this time pointing to the next line; df.fillna(inplace=True) as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l8f8pPaPDQWIvBIzIiEm7Q.png" /></figure><p>The error states: ValueError: Must specify a fill ‘value’ or ‘method’</p><p>So back in the latest Pandas API documentation search for fillna:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eKWx-bTSl0uvBbpiqssnwA.png" /></figure><p>From the list returned the one of interest is the one that states DataFrame.fillna since this is the function we are using. So click this link:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*Nf-HXcJb5puMxtADFGLtcg.png" /></figure><p>Unfortunately, this documentation doesn’t inform us as to which arguments are mandatory or optional (this is bad API documentation on behalf of the developers of Pandas). Highlighted in red is what we’re interested in; ‘value’ and ‘method’ which are the first two parameters.</p><p>Now, from our error reported in Colab the fillna arguments cannot be blank (when sentdex made this tutorial Pandas it did allow it, but subsequent versions don’t). This means we MUST specify a parameter. Scroll down to see an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*Do-jGa7hB8E3d5CePSlJhg.png" /></figure><p>Again, we see the creation of a DataFrame object of various datatypes and containing NaN. Since we don’t want to swap out NaN with 0 the df.fillna(0) is not an option. But the second highlighted box shows when we use df.fillna(method=’ffill’) non-null values are handled by propagating NaN values forwards or backwards.</p><p>Now I don’t know about you, but “Propagating non-null values backwards or forwards” is too woolly a description. It doesn’t give me a precise description of what this parameter actually does (I really do wish the developers would give a more detailed description, but hey, we can but wish). Examining the first and last red box highlighted above shows the columns A, B and C being shifted slightly to the left. But since we can use this and we MUST specify a parameter let’s give it a try…</p><p>…Copy/paste it into the bottom of the code cell in Colab, give it a comment and then insert a df.head() function on the last line of the code cell to examine the data once executed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*PsT9tnbV46aI62f9mJ1KBA.png" /></figure><p>With the cursor in the current code cell click on Runtime, Run before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y5a9QmPRo6Gkp4WXrlPLHQ.png" /></figure><p>This loads all the previous code before this code cell into memory.</p><p>Then manually execute this code cell using the play icon highlighted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kimda7oMfctKy_gQOqYZCQ.png" /></figure><p>Our data is shown in the bottom panel and no errors are reported so these two lines have been fixed by applying the new Pandas supported functions.</p><p>I can inform you that in this tutorial by sentdex only these two lines were the only deprecated functions. I hope you can follow this article seamlessly and apply these principals to your deprecated functions to revive your Python code.</p><p>Any question or comments just leave in the response section. Happy machine learning coding in Colab…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb69ca6f4e10" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/dealing-with-deprecation-in-machine-learning-libraries-a-step-by-step-guide-to-resolving-using-an-cb69ca6f4e10">Dealing with deprecation in Machine Learning libraries — A step-by-step guide to resolving using…</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Structure your code better in Google Colab with Text and Code Cells]]></title>
            <link>https://miteshparmar1.medium.com/structure-your-code-better-in-google-colab-with-text-and-code-cells-b6fa73feec20?source=rss-59cc59fea6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6fa73feec20</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <dc:creator><![CDATA[Mitesh Parmar]]></dc:creator>
            <pubDate>Tue, 30 Mar 2021 08:43:39 GMT</pubDate>
            <atom:updated>2021-03-30T08:43:39.720Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*pimj8lXWwZnqLs2xVCV2Aw.png" /></figure><p>Google Colab is a cloud based Jupyter Notebook that allows you to run and execute your Python code remotely and save your work into your personal Google Drive. It’s ace card is the availability of the free graphics processing units (GPU) to allow fast training.</p><p>One of the excellent features of Colab that all developers should take full advantage of is the use of text and code compartmentalisation. Basically, splitting your code up into chucks of code and text in code cells and text cells respectively. This will facilitate eligibility and give you well defined checkpoints so you can visualise your data’s structure as you code.</p><p>Allow me to demonstrate…</p><p>Opening a new Google Colaboratory file shows the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XozPyOVQ9rOJ4PdF510PKw.png" /></figure><p>To insert a text cell you can either click on the ‘+ Text’ button in the top left of the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*IQng0bbtYxlD4ThR8aNEKQ.png" /></figure><p>Or you can hover your mouse over the top of the code cell which shows both Code and Text buttons and click on the Text button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7eFO4HAzNa-ScBhYTEOAmQ.png" /></figure><p>Simply double-click or press enter to start writing your text:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*L5ucRp6ddnYaFScPCLIvig.png" /></figure><p>Colab presents you will a series of text editor icons which allow you to do functions found in most text editors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*ueDPD7kbyiT_AIBtqv199g.png" /></figure><p>The final icon toggles the textual display to the right side of the screen instead of the default below the editing area:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sto7_fRzXuxE3xUvhArIag.png" /></figure><p>Once you’ve entered your text, simply click back into the grey-coloured box to enter your Python code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMvNZENJOoTffQMspuUqyQ.png" /></figure><p>As I’ve followed the machine learning tutorials on <a href="http://www.pythonprogramming.net/">www.pythonprogramming.net</a> I’ve structured my exercises like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpvyimWCFs8qxikjWYmB9g.png" /></figure><p>I’ve used a text cell for the hyperlinks and synopsis. The first cell code imports a non-native python module and the second cell code imports the libraries and starts my coding. I usually add a short comment above each line of code so reading over this and debugging is easier and its also good programming practice.</p><p>Scrolling down shows df.head() being the last code in the second code cell (section 3). Notice how Colab doesn’t need a print(df.head()) statement. Colab simply interprets the df.head() function and displays the data in a nice neat table for visualisation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MTsiJX01OshAdLgBjM4Aeg.png" /></figure><p>This is a good checkpoint to ensure your data is as you expect it to be. At the very bottom I’ve inserted a text cell to explain what we’re looking at when the df.head() is run.</p><p>Scrolling further down shows the final code cell (section 4) and the last code is the df.head() function which displays the Pandas dataframe object which has been drastically altered from before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81QSpHRAV-srEUmza_m9cQ.png" /></figure><p>To execute all code cells from top to bottom click on Runtime and click ‘Run all’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvfJ-TwbuDbluTeQreEBzg.png" /></figure><p>Conclusion: By using multiple text cells and code cells has helped me to structure my text and code better and create multiple checkpoints which help visualise the data as we code and alter the data object.</p><p>I hope this article helps you do this too. Happy Colab coding…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6fa73feec20" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>