<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Salim Oyinlola - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Salim Oyinlola - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Thu, 28 May 2026 16:46:23 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/salimcodes/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Become a Microsoft Learn Student Ambassador ]]>
                </title>
                <description>
                    <![CDATA[ The Microsoft Learn Student Ambassadors program is a student-focused program designed to empower students to become advocates and leaders in the tech ecosystem.  Microsoft Learn Student Ambassadors are student leaders who collaborate with Microsoft t... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-become-a-microsoft-learn-student-ambassador/</link>
                <guid isPermaLink="false">66ba2dc92045fa5eb7a55321</guid>
                
                    <category>
                        <![CDATA[ Microsoft ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Students ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Mon, 14 Aug 2023 16:11:33 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/08/asdfghjkl-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The <a target="_blank" href="https://mvp.microsoft.com/studentambassadors">Microsoft Learn Student Ambassadors</a> program is a student-focused program designed to empower students to become advocates and leaders in the tech ecosystem. </p>
<p>Microsoft Learn Student Ambassadors are student leaders who collaborate with Microsoft to help fellow students learn about technology and engage with various Microsoft technologies and services.</p>
<p>It is important to note that Microsoft Learn Student Ambassadors <strong>are not employees of Microsoft</strong>. While they work closely with Microsoft and have access to certain resources, training, and support from the company, they do not receive regular employee compensation. </p>
<p>Instead, student ambassadors often receive benefits such as networking opportunities, skill development, and recognition within the tech community. </p>
<h2 id="heading-responsibilities-of-microsoft-learn-student-ambassadors">Responsibilities of Microsoft Learn Student Ambassadors</h2>
<p>At the very high level, the responsibilities of student ambassadors include encouraging their peers to use <a target="_blank" href="https://learn.microsoft.com/en-us/">Microsoft Learn</a>, Microsoft's educational platform. It offers free resources, tutorials, and courses on various Microsoft technologies in a bid to help students build skills that open doors. </p>
<p>Student Ambassadors also represent Microsoft technologies on their campuses. In this capacity, Ambassadors engage with faculty and students to showcase the benefits of these tools for education and innovation. </p>
<p>Student Ambassadors are required to complete a variety of pre-determined activities in order to advance through the well-defined program milestones. As you complete these program milestones you can unlock additional program benefits. </p>
<p>You go through these milestones in the following order: new to alpha, alpha to beta, and beta to gold. With each milestone achievement, program certificates are updated. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-117.png" alt="Image" width="600" height="400" loading="lazy">
<em>The different milestones</em></p>
<p>To attain the Alpha milestone, new student ambassadors are required to complete a learn path on Microsoft Learn within four months of joining the program. </p>
<p>To reach the Beta milestone, first you need to complete the program's technical onboarding as a alpha student ambassador. Then you must host and report an approved event or actively participate in a Student Ambassadors project within twelve months of joining the program. </p>
<p>Finally, to achieve the highest milestone in the program (Gold), you are required to go above and beyond program expectations by demonstrating significant reach and impact. </p>
<h2 id="heading-how-to-apply-to-be-a-microsoft-learn-student-ambassador">How to Apply to Be a Microsoft Learn Student Ambassador</h2>
<p>Before applying, it is important to note the following: </p>
<ul>
<li>The minimum age requirement for applicants is <strong>16 years</strong>.</li>
<li>Full-time enrollment in an accredited academic institution (such as a College or University) is <strong>required</strong> for applicants.</li>
<li>Applications are restricted to individual persons and not open to corporate entities.</li>
<li>Individuals who are Microsoft employees or current contractors are ineligible to apply. </li>
</ul>
<p>If you meet these qualifications, you can apply to become a Student Ambassador.</p>
<p>The most important thing to know about the application process for the Microsoft Learn Student Ambassador program is that the application is open all year long. But applications are only reviewed (and applicants are gotten back to) quarterly – in January, April, July and October. </p>
<p>You can find the application form <a target="_blank" href="https://mvp.microsoft.com/studentambassadors">here</a>. The application consists of four major parts – privacy and terms, personal information, academic institution, and application questions. Let's go through each one now.</p>
<h3 id="heading-privacy-and-terms">Privacy and terms</h3>
<p>In the privacy and terms section, you are required to agree to the <a target="_blank" href="https://privacy.microsoft.com/en-US/privacystatement">Microsoft Privacy Statement</a> and confirm your eligibility for the program. </p>
<p>By completing this section, you accept that as you submit your application, your information will be shared with the Microsoft program lead who manages Microsoft Learn Student Ambassadors selection in your region. </p>
<p>Also in this section, you are informed that if your application is not accepted, although all the information you provided will be removed from their servers within twelve months of the application submission date. You can request removal of your application data at any time without constraints. </p>
<h3 id="heading-personal-information">Personal information</h3>
<p>In the personal information section, the required prompts include your name, contact email address, date of birth, gender, pronoun and country or region. </p>
<p>You can also enter your preferred programming language in this section (but this particular question is not required). </p>
<p>In this section, you can also add the social media profiles you use for community leadership as an allusion to your online influence and network. </p>
<h3 id="heading-academic-institution">Academic institution</h3>
<p>In the academic institution section, as the name implies, the prompts are aimed at getting the country and region of your academic institution, its name, your degree program and your expected graduation date. </p>
<p>The available options include Computer Science, Electrical Engineering, Software Engineering, Systems Engineering, Engineering - Other, Information Systems, Cyber Security, Business and Others). You'll also be asked to list your degree level (the selections accessible are Bachelor, Master and PhD).</p>
<h3 id="heading-application-questions">Application questions</h3>
<p>In the application questions section, as an applicant, you are required to answer the following three questions. </p>
<ul>
<li><em>Tell us about one specific technical skill you have learned, and how you were guided to learning it. How would you use that experience to be a better Student Ambassador? (Guide)</em></li>
<li><em>Tell us about a specific time you welcomed a new person into one of your communities. How would you use that experience to be a better Student Ambassador? (Welcome)</em></li>
<li><em>Tell us about a specific event you have planned that connected diverse audiences together. How would you use that experience to be a better Student Ambassador? (Connect)</em></li>
</ul>
<p>Now, here's the catch. Whilst every applicant gets to answer all three questions, each applicant also gets the opportunity to answer any two of their choice with written responses and one as a video response. I think this is an attempt to get applicants to demonstrate their public speaking skills. </p>
<p>The video must be <strong>under two minutes</strong> and should be recorded in a quiet space without background noise. The written responses, on the other hand, must be a <strong>minimum of 100 character</strong>s and <strong>maximum of 2000 characters</strong> each. </p>
<p>Also, the video response's link has to be publicly accessible to anyone with the link. If an applicant chooses to record their video in any language that is not English, they must include English subtitles. </p>
<p>There's an option to pick from a list of technologies and highlight which ones interest you. </p>
<p>Finally, in <strong>more than 100 characters</strong> and <strong>less than 1000 characters</strong>, you can share the link to your Microsoft Learn profile (if you have one) and provide the reviewing team with details about your engagements within your community, both in online and on-campus settings. </p>
<p>In that space, you can also let them know about any organizations you are part of, particularly if you hold leadership roles. Feel free to share any additional information you consider important in this section. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-111.png" alt="Image" width="600" height="400" loading="lazy">
<em>The list of technologies to choose from</em></p>
<p>The application process/essays may seem quite lengthy. But the good thing about it is that the essay portal automatically saves your application as you go, so you can leave at any time and come back later to continue your application. </p>
<h2 id="heading-benefits-of-being-a-microsoft-learn-student-ambassador">Benefits of Being a Microsoft Learn Student Ambassador</h2>
<p>The benefits of being a Microsoft Learn Student Ambassador are many. First, you benefit from comprehensive technical and leadership training and gain access to Microsoft's extensive array of learning materials. You also get to connect with a worldwide community of students who share your enthusiasm for building the future you envision. </p>
<p>In my opinion, the biggest thing student ambassadors stand to gain is the community they become a part of alongside fellow ambassadors. This community offers an extensive network of peers, mentors, and professionals who are all invested in the same mission. It becomes a platform for collaboration, knowledge-sharing, and personal growth. </p>
<p>Here are a few other benefits that are accessible as you progress through the milestones: </p>
<h3 id="heading-benefits-of-the-new-milestone">Benefits of the New Milestone</h3>
<p>Microsoft 365: This is a product family of productivity software, collaboration and cloud-based services owned by Microsoft. As a student ambassador in the new milestone, you get Microsoft 365 subscriptions. </p>
<p>The Microsoft 365 subscriptions include full Office desktop apps such as Word, Excel, Outlook, PowerPoint, Access and Publisher for Windows PCs, as well as access to additional OneNote features. </p>
<h3 id="heading-benefits-of-the-alpha-milestone">Benefits of the Alpha Milestone</h3>
<p>In addition to the benefits that comes with the new milestone, student ambassadors get access to <a target="_blank" href="https://www.microsoft.com/en-us/d/visual-studio-enterprise-subscription/dg7gmgf0dst4?activetab=pivot:overviewtab">Visual Studio Enterprise</a>. This annual subscription provides Student Ambassadors with $150 monthly Azure credit, license keys to various Microsoft Products, and many other benefits. </p>
<p>In addition, in line with the program's dedication to the growth of student ambassadors, student ambassadors in the Alpha milestone and beyond get free access to LinkedIn Learning.</p>
<h3 id="heading-benefits-of-the-beta-milestone">Benefits of the Beta Milestone</h3>
<p>In addition to the existing benefits, upon reaching this milestone, student ambassadors get a Beta swag box. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-115.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Microsoft Learn Student Ambassador Beta Swag Box</em></p>
<h3 id="heading-benefits-of-the-gold-milestone">Benefits of the Gold Milestone</h3>
<p>On top of the previous benefits, student ambassadors who achieve this milestone get a Gold swag box, more program leadership opportunities, consideration for special events and activities, and consideration for MVP mentorship and nomination. This is the highest milestone in the program. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/08/image-116.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Microsoft Learn Student Ambassador Gold Swag Box</em></p>
<h3 id="heading-windows-insider-for-student-ambassadorshttpswwwmicrosoftcomen-uswindowsinsiderstudentambassadors"><a target="_blank" href="https://www.microsoft.com/en-us/windowsinsider/studentambassadors">Windows Insider for Student Ambassadors</a></h3>
<p>Finally, one last benefit I want to touch on is the Windows Insider Program for Student Ambassadors.</p>
<p>Thanks to the Windows Insider Program's collaboration with Microsoft Learn Student Ambassadors, when Student Ambassadors become part of the Windows Insider Program, they will get a chance to preview upcoming Windows features and offer input to influence the direction Windows takes in the future.</p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>Once you graduate from the Microsoft Learn Student Ambassador program at the Gold milestone, you will be eligible for nomination to the Windows Insider Most Valuable Professional (MVP) program. </p>
<p>This prestigious status comes with exclusive interaction opportunities with the Windows engineering team, special event invitations, and complimentary subscriptions to tools such as Visual Studio Enterprise, Office 365, and LinkedIn Premium. You you will receive a personalized award kit to commemorate this achievement.</p>
<p>I hope this guide helps you apply for the program and know what to expect! Thanks for reading.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Get a GitHub Student Developer Pack ]]>
                </title>
                <description>
                    <![CDATA[ For many students who are passionate about technology, limited access to crucial tools and resources is a common challenge.  Fortunately, the GitHub Student Developer Pack comes to the rescue. This pack provides students with exclusive access to a va... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/github-student-developer-pack/</link>
                <guid isPermaLink="false">66ba2dc37787ec7052709306</guid>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ open source ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Students ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Fri, 14 Jul 2023 17:35:43 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/07/GitHub-Pack.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>For many students who are passionate about technology, limited access to crucial tools and resources is a common challenge. </p>
<p>Fortunately, the GitHub Student Developer Pack comes to the rescue. This pack provides students with exclusive access to a variety of top-notch developer tools, allowing them to learn through practical experience.</p>
<h2 id="heading-what-is-the-github-student-developer-pack">What is the GitHub Student Developer Pack?</h2>
<p>The Student Developer Pack is made up of a selection of benefits generously provided by GitHub's partners and collaborators. These partners joined forces with GitHub to extend these valuable offers to verified students. </p>
<p>Why? Because they understand that the most effective way to support future developers is by offering hands-on experience with industry-standard products and tools. </p>
<p>In essence, the GitHub Student Developer Pack eliminates the obstacles faced by students who are passionate about technology but may not have the resources to pay full price for all these tools. </p>
<p>The pack grants students access to a collection of resources and empowers them to acquire firsthand knowledge and skills through the use of cutting-edge tools. </p>
<p>In this article, I will touch on some of the highlights of the GitHub Student Developer Pack and how you can access to it. </p>
<h2 id="heading-highlights-of-the-student-developer-pack">Highlights of the Student Developer Pack</h2>
<p>This pack comes with a plethora of offers across different domains in the tech space. For every speciality, there's likely an offer that'll help you get ahead in your career and access the best developer tools used in that industry for free. </p>
<p>These tools cover many topics, including Cloud Computing, Design, Game Development, Infrastructure and APIs, Internet of Things (IoT), Marketing, Mobile Development, Security Analytics and more. So it's fair to say no stone is left unturned with this pack.</p>
<p>Here are some examples of what you'll have access to:</p>
<h3 id="heading-microsoft-azurehttpsazuremicrosoftcomen-usget-startedazure-portal"><a target="_blank" href="https://azure.microsoft.com/en-us/get-started/azure-portal">Microsoft Azure</a></h3>
<p>Access to the pack comes with Microsoft Azure's free access to 25+ Microsoft Azure cloud services plus $100 in Azure credit.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-55.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-namecheaphttpswwwfreecodecamporgnewsp7a1de6ae-8338-434f-b9f6-5fc5f21aaf65github20student20developer20pack"><a target="_blank" href="https://www.freecodecamp.org/news/p/7a1de6ae-8338-434f-b9f6-5fc5f21aaf65/GitHub%20Student%20Developer%20Pack">Namecheap</a></h3>
<p>As part of the GitHub Student Developer Pack, Namecheap offers free one-year registration on a <code>.me</code> domain that comes with an SSL certificate.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-60.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-digitaloceanhttpswwwdigitaloceancom"><a target="_blank" href="https://www.digitalocean.com/">DigitalOcean</a></h3>
<p>With the pack, you will get access to $200 credit valid for one year to pay for cloud infrastructure services such as virtual servers, storage, and networking resources. on DigitalOcean in a pay-as-you-go basis. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-56.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-educativehttpswwweducativeio"><a target="_blank" href="https://www.educative.io/">Educative</a></h3>
<p>With the GitHub Student Developer pack, as a student, you will get access to six free months of 60+ courses covering in-demand topics. This can help you learn to code, grow your skills, and even succeed in tech interviews. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-57.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-1passwordhttps1passwordcom"><a target="_blank" href="https://1password.com/">1Password</a></h3>
<p>The importance of security cannot be overemphasized. With access to 1Password, you can ensure the security of your accounts by monitoring password breaches and identifying other security issues. </p>
<p>As a student, this enables you to maintain the safety of your online accounts. With the Student Developer Pack, you will get 1Password free for a year.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-58.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>And then, my personal favourite...</p>
<h3 id="heading-the-github-campus-experts-programhttpsgithubcampusexpert">The <a target="_blank" href="https://githubcampus.expert/">GitHub Campus Experts Program</a></h3>
<p>The GitHub Campus Expert program is geared towards empowering University students to become student leaders while advocating for technology and open-source collaboration. </p>
<p>Campus Experts are trained to organize events, mentor other students, and foster/build a strong tech community on their respective campuses. </p>
<p>But it's important to note that the GitHub Student Developer Pack is a prerequisite for being able to apply for the program. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-59.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In all, the pack provides students with a wide range of essential developer tools and resources that are typically expensive or require paid subscriptions for free. Being able to use and learn these tools can help take your career to the next level.</p>
<p>If you're curious, you can take a look at <a target="_blank" href="https://githubcampus.expert/salimcodes/">my GitHub Campus Experts profile here</a>. </p>
<h2 id="heading-what-are-the-requirements-to-get-a-student-developer-pack">What Are the Requirements to Get a Student Developer Pack?</h2>
<p>To be eligible for the GitHub Student Developer Pack, you must meet the following requirements:</p>
<ul>
<li>You must be a minimum of 13 years of age.</li>
<li>You must have a user account on <a target="_blank" href="http://github.com/">GitHub</a>.</li>
<li>You must possess a school-issued email address that can be verified, or alternatively, provide documents as evidence of your current student status.</li>
<li>At the point of your application, you must be currently registered in a program that grants a degree or diploma.</li>
</ul>
<p>To gain further insights into the application process and the types of documents that are accepted, I encourage you to check the comprehensive <a target="_blank" href="https://docs.github.com/en/education/explore-the-benefits-of-teaching-and-learning-with-github-education/github-global-campus-for-students/apply-to-github-global-campus-as-a-student">Education documentation</a>.</p>
<h2 id="heading-how-do-i-get-this-pack">How Do I Get this Pack?</h2>
<p>First, you'll need to visit <a target="_blank" href="https://education.github.com/pack">GitHub Education</a>. Sign in with your GitHub Account by clicking the <code>Sign-in</code> button on the top-right corner.</p>
<p>Then click on the <code>Sign up for Student Developer Pack</code> button.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-62.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You will be required to fill a form. The questions in the form are as follows:</p>
<ul>
<li><em>What e-mail address do you use for school?</em></li>
</ul>
<p>If you have a school-issued email, select (or add) it. It is important to note that these email addresses must be verified.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-69.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>From my experience, selecting a school-issued email address gives you the best chance of a speedy review.</p>
<p>If you don’t have a school-issued email, follow the prompts to fill out some additional information. You will still be eligible even if you only have a personal email address, as long as you can provide alternative documentation to verify your current student status.</p>
<ul>
<li><em>What is the name of your school?</em></li>
</ul>
<p>This prompt is automatically filled out if you provided a valid student email. However, if your school is not listed, then you need to enter your school's full name and continue. You will be asked to provide further information about your school on the next page.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1633154255978/mFEqZnsYT0.png?auto=compress,format&amp;format=webp" alt="image.png" width="712" height="180" loading="lazy"></p>
<ul>
<li><em>How do you plan to use GitHub? and then click 'Continue'</em></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1633154287946/QwLzuBdTa.png?auto=compress,format&amp;format=webp" alt="image.png" width="721" height="252" loading="lazy"></p>
<p>And boom!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1633154457652/bBQUlc78a.png?auto=compress,format&amp;format=webp" alt="image.png" width="1348" height="420" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1633677026578/95gJIOpSx.png?auto=compress,format&amp;format=webp" alt="image.png" width="498" height="310" loading="lazy"></p>
<p>Yes, it is that easy. By following the steps I have outlined, you can unlock a world of opportunities and resources that can elevate your career to new heights. Armed with the GitHub Student Developer Pack, you now have access to a variety of tools, software licenses, and educational resources that can accelerate your learning and growth.</p>
<p>Finally, I share my articles on <a target="_blank" href="https://twitter.com/SalimOpines">Twitter</a> if you enjoyed this article and want to see more.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Gradient Descent – Machine Learning Algorithm Example ]]>
                </title>
                <description>
                    <![CDATA[ What is the Gradient Descent Algorithm? Gradient descent is probably the most popular machine learning algorithm. At its core, the algorithm exists to minimize errors as much as possible.  The aim of gradient descent as an algorithm is to minimize th... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/gradient-descent-machine-learning-algorithm-example/</link>
                <guid isPermaLink="false">66ba2dc6de9370f66eeb0a97</guid>
                
                    <category>
                        <![CDATA[ algorithms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Gradient-Descent  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Mon, 24 Oct 2022 13:53:51 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/10/pexels-pixabay-159751.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <h2 id="heading-what-is-the-gradient-descent-algorithm">What is the Gradient Descent Algorithm?</h2>
<p>Gradient descent is probably the most popular machine learning algorithm. At its core, the algorithm exists to minimize errors as much as possible. </p>
<p>The aim of gradient descent as an algorithm is to minimize the cost function of a model. We can tell this from the meanings of the words ‘<em>Gradient</em>’ and ‘<em>Descent</em>’. </p>
<p>While gradient means the gap between two defined points (that is the cost function in this context), descent refers to downward motion in general (that is minimizing the cost function in this context). </p>
<p>So in the context of machine learning, Gradient Descent refers to the iterative attempt to minimize the prediction error of a machine learning model by adjusting its parameters to yield the smallest possible error.</p>
<p>This error is known as the Cost Function. The cost function is a plot of the answer of the question “<em>by how much does the predicted value differ from the actual value?”</em>. While the way to evaluate cost functions often differs for different machine learning models, in a simple linear regression model, it is usually the root mean squared error of the model.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-166.png" alt="Image" width="600" height="400" loading="lazy">
<em>A 3D plot of the cost function of a simple linear regression model with M representing the minimum point</em></p>
<p>It is important to note that for the simpler models like the linear regression, a plot of the cost function is usually bow-shaped, which makes it easier to ascertain the minimum point. However, this is not always the case. For more complex models (for instance neural networks), the plot might not be bow-shaped. It is possible for the cost function to have multiple minimum points as shown in the image below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-39.png" alt="Image" width="600" height="400" loading="lazy">
<em>A 3D plot of the cost function of a neural network. Source: <a target="_blank" href="https://www.coursera.org/lecture/machine-learning/gradient-descent-2f2PA">Coursera</a></em></p>
<h2 id="heading-how-does-gradient-descent-work">How Does Gradient Descent Work?</h2>
<p>Firstly, it is important to note that like most machine learning processes, the gradient descent algorithm is an iterative process. </p>
<p>Assuming you have the cost function for a simple linear regression model as <em>j(w,b)</em> where <em>j is</em> a function of <em>w</em> and <em>b,</em> the gradient descent algorithm works such that it starts off with some initial random guess for <em>w</em> and <em>b</em>. The algorithm will keep tweaking the parameters <em>w</em> and <em>b</em> in an attempt to optimize the cost function, <em>j.</em> </p>
<p>In linear regression, the choice for the initial values does not matter much. A common choice is zero. </p>
<p>The perfect analogy for the gradient descent algorithm that minimizes the cost-function <em>j</em>(<em>w</em>, <em>b</em>) and reaches its local minimum by adjusting the parameters <em>w</em> and <em>b</em> is hiking down to the bottom of a mountain or hill (as shown in the 3D plot of the cost function of a simple linear regression model shown earlier). Or, trying to get to the lowest point of a golf course. In either case, they will make repetitive short steps till they make it to the bottom of the mountain or hill.</p>
<h2 id="heading-the-gradient-descent-formula">The Gradient Descent Formula</h2>
<p><strong>Here's the formula for gradient descent: b = a - γ Δ f(a)</strong></p>
<p>The equation above describes what the gradient descent algorithm does. </p>
<p>That is <em>b</em> is the next position of the hiker while <em>a</em> represents the current position. The minus sign is for the minimization part of the gradient descent algorithm since the goal is to minimize the error as much as possible. γ in the middle is a factor known as the learning rate, and the term Δf(a) is a gradient term that defines the direction of the minimum point. </p>
<p>As such, this formula tells the next position for the hiker/the person on the golf course (that is the direction of the steepest descent). It is important to note that the term <em>γΔ f(a)</em> is subtracted from <em>a</em> because the goal is to move against the gradient, toward the local minimum.</p>
<h2 id="heading-what-is-the-learning-rate">What is the Learning Rate?</h2>
<p>The learning rate is the determinant of how big the steps gradient descent takes in the direction of the local minimum. It determines the speed with which the algorithm moves towards the optimum values of the cost function. </p>
<p>Because of this, the choice of the learning rate, γ, is important and has a significant impact on the effectiveness of the algorithm. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-42.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If the learning rate is too big as shown above, in a bid to find the optimal point, it moves from the point on the left all the way to the point on the right. In that case, you see that the cost function has gotten worse.  </p>
<p>On the other hand, if the learning rate is too small, then gradient descents will work, albeit very slowly. </p>
<p>It is important to pick the learning rate carefully.</p>
<h2 id="heading-how-to-implement-gradient-descent-in-linear-regression">How to Implement Gradient Descent in Linear Regression</h2>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Linear_Regression</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, X, Y</span>):</span>
        self.X = X
        self.Y = Y
        self.b = [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>]

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">update_coeffs</span>(<span class="hljs-params">self, learning_rate</span>):</span>
        Y_pred = self.predict()
        Y = self.Y
        m = len(Y)
        self.b[<span class="hljs-number">0</span>] = self.b[<span class="hljs-number">0</span>] - (learning_rate * ((<span class="hljs-number">1</span>/m) * np.sum(Y_pred - Y)))
        self.b[<span class="hljs-number">1</span>] = self.b[<span class="hljs-number">1</span>] - (learning_rate * ((<span class="hljs-number">1</span>/m) * np.sum((Y_pred - Y) * self.X)))

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">predict</span>(<span class="hljs-params">self, X=[]</span>):</span>
        Y_pred = np.array([])
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> X: X = self.X
        b = self.b
        <span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> X:
            Y_pred = np.append(Y_pred, b[<span class="hljs-number">0</span>] + (b[<span class="hljs-number">1</span>] * x))

        <span class="hljs-keyword">return</span> Y_pred

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_current_accuracy</span>(<span class="hljs-params">self, Y_pred</span>):</span>
        p, e = Y_pred, self.Y
        n = len(Y_pred)
        <span class="hljs-keyword">return</span> <span class="hljs-number">1</span>-sum(
            [
                abs(p[i]-e[i])/e[i]
                <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(n)
                <span class="hljs-keyword">if</span> e[i] != <span class="hljs-number">0</span>]
        )/n
    <span class="hljs-comment">#def predict(self, b, yi):</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">compute_cost</span>(<span class="hljs-params">self, Y_pred</span>):</span>
        m = len(self.Y)
        J = (<span class="hljs-number">1</span> / <span class="hljs-number">2</span>*m) * (np.sum(Y_pred - self.Y)**<span class="hljs-number">2</span>)
        <span class="hljs-keyword">return</span> J

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">plot_best_fit</span>(<span class="hljs-params">self, Y_pred, fig</span>):</span>
                f = plt.figure(fig)
                plt.scatter(self.X, self.Y, color=<span class="hljs-string">'b'</span>)
                plt.plot(self.X, Y_pred, color=<span class="hljs-string">'g'</span>)
                f.show()


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    X = np.array([i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">11</span>)])
    Y = np.array([<span class="hljs-number">2</span>*i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">11</span>)])

    regressor = Linear_Regression(X, Y)

    iterations = <span class="hljs-number">0</span>
    steps = <span class="hljs-number">100</span>
    learning_rate = <span class="hljs-number">0.01</span>
    costs = []

    <span class="hljs-comment">#original best-fit line</span>
    Y_pred = regressor.predict()
    regressor.plot_best_fit(Y_pred, <span class="hljs-string">'Initial Best Fit Line'</span>)


    <span class="hljs-keyword">while</span> <span class="hljs-number">1</span>:
        Y_pred = regressor.predict()
        cost = regressor.compute_cost(Y_pred)
        costs.append(cost)
        regressor.update_coeffs(learning_rate)

        iterations += <span class="hljs-number">1</span>
        <span class="hljs-keyword">if</span> iterations % steps == <span class="hljs-number">0</span>:
            print(iterations, <span class="hljs-string">"epochs elapsed"</span>)
            print(<span class="hljs-string">"Current accuracy is :"</span>,
                regressor.get_current_accuracy(Y_pred))

            stop = input(<span class="hljs-string">"Do you want to stop (y/*)??"</span>)
            <span class="hljs-keyword">if</span> stop == <span class="hljs-string">"y"</span>:
                <span class="hljs-keyword">break</span>

    <span class="hljs-comment">#final best-fit line</span>
    regressor.plot_best_fit(Y_pred, <span class="hljs-string">'Final Best Fit Line'</span>)

    <span class="hljs-comment">#plot to verify cost function decreases</span>
    h = plt.figure(<span class="hljs-string">'Verification'</span>)
    plt.plot(range(iterations), costs, color=<span class="hljs-string">'b'</span>)
    h.show()

    <span class="hljs-comment"># if user wants to predict using the regressor:</span>
    regressor.predict([i <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">10</span>)])

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>:
    main()
</code></pre>
<p>At its core, you can see that the block of code trains a gradient descent algorithm for a linear regression machine learning model using <code>0.01</code>  as its learning rate on <code>100</code> steps. </p>
<p>Upon running the code above, the output shown is given below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-43.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-44.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, it is important to note that the gradient descent algorithm is especially important in the artificial intelligence and machine learning domains as the models must be optimized for accuracy.  </p>
<p>In this article, you learnt what the Gradient Descent algorithm is, how it works, its formula, what learning rate is, and the importance of picking the right learning rate. You also saw a code illustration of how Gradient Descent works. </p>
<p>Finally, I share my writings on Artificial Intelligence, Machine Learning and Microsoft Azure on <a target="_blank" href="https://twitter.com/SalimOpines">Twitter</a> if you enjoyed this article and want to see more.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Validate your Machine Learning Models Using TensorFlow Model Analysis ]]>
                </title>
                <description>
                    <![CDATA[ My first deployed Machine Learning model was a failure. It was a simple Diabetes Diagnosis Model for potential diabetes mellitus patients – and quite frankly, I was beyond excited on deployment.  But the excitement soon disappeared when I received fe... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-validate-machine-learning-models-with-tensorflow-model-analysis/</link>
                <guid isPermaLink="false">66ba2dd5c346e93df556affb</guid>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ TensorFlow ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Validation ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Wed, 05 Oct 2022 14:37:09 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/10/pexels-pixabay-159275.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>My first deployed Machine Learning model was a failure. It was a simple Diabetes Diagnosis Model for potential diabetes mellitus patients – and quite frankly, I was beyond excited on deployment. </p>
<p>But the excitement soon disappeared when I received feedback from users. Simply put, the users felt the model was bad. </p>
<p>I was saddened by this, but looking back, they were correct. The model may have performed well in terms of top-level metrics. But from the perspective of the consumer, if a machine learning model provides a poor forecast, that person's experience with the model will be bad. </p>
<p>The issue was that specific model features, or slices of data, were causing the model to perform poorly. </p>
<p>In short, before deploying any machine learning model, the onus is on machine learning engineers to assess it, make sure it satisfies strict quality standards, and acts as predicted for all pertinent slices of data.</p>
<h2 id="heading-what-is-tensorflow-model-analysis">What is TensorFlow Model Analysis?</h2>
<p>To enable Machine Learning engineers to look at the performance of their models at a deeper level, Google created <a target="_blank" href="https://www.tensorflow.org/tfx/guide/tfma">TensorFlow Model Analysis (TFMA)</a>. According to the docs, "TFMA performs its computations in a distributed manner over large amounts of data using Apache Beam."</p>
<p>TFMA, as a tool, enables you to really dig into the model's performance and understand how it varies on different slices of data. It provides support for calculating metrics that were used at training time (that is built-in metrics) as well as metrics defined after the model was saved as part of the TFMA configuration settings. </p>
<p>In this tutorial, you will analyze and evaluate results on a previously trained machine learning model. The model you will use is trained for a <a target="_blank" href="https://github.com/tensorflow/tfx/tree/master/tfx/examples/chicago_taxi_pipeline">Chicago Taxi Example</a>, which uses the <a target="_blank" href="https://data.cityofchicago.org/Transportation/Taxi-Trips/wrvz-psew">Taxi Trips dataset</a> released by the city of Chicago. You can check out the full dataset <a target="_blank" href="https://bigquery.cloud.google.com/dataset/bigquery-public-data:chicago_taxi_trips">here</a>. </p>
<p>When you are done with this tutorial, you will be able to use Apache Beam to do a full pass over the specified evaluation dataset. Also, you will not only have a more accurate calculation of metrics, but you'll be able to scale up to massive evaluation datasets, since Beam pipelines can be run using distributed processing back-ends.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li>Fundamental knowledge of Apache Beam. The <a target="_blank" href="https://beam.apache.org/documentation/programming-guide/">Beam Programming Guide</a> is a great place to start.</li>
<li>Fundamental understanding of the workings of machine learning models. </li>
<li>A new Google Colab notebook to run the Python code in your Google Drive. You can set this up by following this <a target="_blank" href="https://www.freecodecamp.org/news/google-colaboratory-python-code-in-your-google-drive/">tutorial</a>.</li>
</ul>
<h2 id="heading-step-1-how-to-install-tensorflow-model-analysis-tfma">Step 1 – How to Install TensorFlow Model Analysis (TFMA)</h2>
<p>With your Google Colab notebook ready, the first thing to do is to pull in all the dependencies. This will take a while.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-23.png" alt="Image" width="600" height="400" loading="lazy">
<em>A blank (new) notebook in dark mode</em></p>
<p>Rename the file from <code>Untitled.ipynb</code> to <code>TFMA.ipynb</code>. </p>
<pre><code class="lang-python">!pip install -U pip
!pip install tensorflow-model-analysis`
</code></pre>
<p>The first line upgrades <code>pip</code> to the latest version. <code>pip</code> is the package management system used to install and manage software packages written in Python. It stands for “preferred installer program”. The second line will install TensorFlow Model Analysis, TFMA.  </p>
<p>Now, after that is done, restart the runtime before running the cells below. It is important to restart the runtime before running the cells.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-26.png" alt="Image" width="600" height="400" loading="lazy"></p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> sys
<span class="hljs-keyword">assert</span> sys.version_info.major==<span class="hljs-number">3</span> 
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">import</span> apache_beam <span class="hljs-keyword">as</span> beam
<span class="hljs-keyword">import</span> tensorflow_model_analysis <span class="hljs-keyword">as</span> tfma
</code></pre>
<p>This block of code imports the needed libraries – <code>sys</code>, <code>tensorflow</code>, <code>apache_beam</code> and <code>tensorflow_model_analysis</code>. You use the <code>assert sys.version_info.major==3</code> command to verify that the notebook is being run using Python 3. </p>
<h2 id="heading-step-2-how-to-load-the-dataset">Step 2 – How to Load the dataset</h2>
<p>You will download the <code>tar</code> file and extract it.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> io, os, tempfile
TAR_NAME = <span class="hljs-string">'saved_models-2.2'</span>
BASE_DIR = tempfile.mkdtemp()
DATA_DIR = os.path.join(BASE_DIR, TAR_NAME, <span class="hljs-string">'data'</span>)
MODELS_DIR = os.path.join(BASE_DIR, TAR_NAME, <span class="hljs-string">'models'</span>)
SCHEMA = os.path.join(BASE_DIR, TAR_NAME, <span class="hljs-string">'schema.pbtxt'</span>)
OUTPUT_DIR = os.path.join(BASE_DIR, <span class="hljs-string">'output'</span>)

!curl -O https://storage.googleapis.com/artifacts.tfx-oss-public.appspot.com/datasets/{TAR_NAME}.tar
!tar xf {TAR_NAME}.tar
!mv {TAR_NAME} {BASE_DIR}
!rm {TAR_NAME}.tar
</code></pre>
<p>The dataset downloaded is in the <code>tar</code> file format. It includes the training datasets, evaluation datasets, the data schema and the training and serving saved models along with eval saved models. You will need all of them in this tutorial.</p>
<h2 id="heading-step-3-how-to-parse-the-schema">Step 3 – How to Parse the Schema</h2>
<p>You need to parse the downloaded schema so that you can use it with TFMA. </p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> google.protobuf <span class="hljs-keyword">import</span> text_format
<span class="hljs-keyword">from</span> tensorflow.python.lib.io <span class="hljs-keyword">import</span> file_io
<span class="hljs-keyword">from</span> tensorflow_metadata.proto.v0 <span class="hljs-keyword">import</span> schema_pb2
<span class="hljs-keyword">from</span> tensorflow.core.example <span class="hljs-keyword">import</span> example_pb2

schema = schema_pb2.Schema()
contents = file_io.read_file_to_string(SCHEMA)
schema = text_format.Parse(contents, schema)
</code></pre>
<p>You will parse the schema using the <code>text_format</code> method of the <code>google.protobuf</code> library to convert the protobuf message to text format and TensorFlow's <code>schema_pb2</code>.</p>
<h2 id="heading-step-4-how-to-use-the-schema-to-create-tfrecords">Step 4 – How to Use the Schema to Create TFRecords</h2>
<p>The next course of action would be to give TFMA access to our dataset. For this, we need to create a <code>TFRecords</code> file.  We used our schema to create it, since it gives us the correct type for each feature.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> csv
datafile = os.path.join(DATA_DIR, <span class="hljs-string">'eval'</span>, <span class="hljs-string">'data.csv'</span>)
reader = csv.DictReader(open(datafile, <span class="hljs-string">'r'</span>))
examples = []
<span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> reader:
  example = example_pb2.Example()
  <span class="hljs-keyword">for</span> feature <span class="hljs-keyword">in</span> schema.feature:
    key = feature.name
    <span class="hljs-keyword">if</span> feature.type == schema_pb2.FLOAT:
      example.features.feature[key].float_list.value[:] = (
          [float(line[key])] <span class="hljs-keyword">if</span> len(line[key]) &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">else</span> [])
    <span class="hljs-keyword">elif</span> feature.type == schema_pb2.INT:
      example.features.feature[key].int64_list.value[:] = (
          [int(line[key])] <span class="hljs-keyword">if</span> len(line[key]) &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">else</span> [])
    <span class="hljs-keyword">elif</span> feature.type == schema_pb2.BYTES:
      example.features.feature[key].bytes_list.value[:] = (
          [line[key].encode(<span class="hljs-string">'utf8'</span>)] <span class="hljs-keyword">if</span> len(line[key]) &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">else</span> [])
  <span class="hljs-comment"># Add a new column 'big_tipper' that indicates if the tip was &gt; 20% of the fare. </span>
  <span class="hljs-comment"># TODO(b/157064428): Remove after label transformation is supported for Keras.</span>
  big_tipper = float(line[<span class="hljs-string">'tips'</span>]) &gt; float(line[<span class="hljs-string">'fare'</span>]) * <span class="hljs-number">0.2</span>
  example.features.feature[<span class="hljs-string">'big_tipper'</span>].float_list.value[:] = [big_tipper]
  examples.append(example)
tfrecord_file = os.path.join(BASE_DIR, <span class="hljs-string">'train_data.rio'</span>)
<span class="hljs-keyword">with</span> tf.io.TFRecordWriter(tfrecord_file) <span class="hljs-keyword">as</span> writer:
  <span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> examples:
    writer.write(example.SerializeToString())
!ls {tfrecord_file}
</code></pre>
<p>It is worthy of note that TFMA supports a number of different model types including TF Keras models, models based on generic TF2 signature APIs, as well TF estimator-based models. However, for this tutorial, you will configure a Keras-based model. </p>
<p>In your Keras <a target="_blank" href="https://www.tensorflow.org/tfx/model_analysis/setup">setup</a>, you will add your metrics and plots manually as part of the configuration (see the <a target="_blank" href="https://www.tensorflow.org/tfx/model_analysis/metrics">metrics</a> guide for information on the metrics and plots that are supported).</p>
<h2 id="heading-step-5-how-to-set-up-and-run-tfma-using-keras">Step 5 – How to Set Up and Run TFMA using Keras</h2>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow_model_analysis <span class="hljs-keyword">as</span> tfma
</code></pre>
<p>You'll finally call and use the instance of <code>tfma</code> that you previously imported at this point. </p>
<pre><code class="lang-python"><span class="hljs-comment"># You will setup tfma.EvalConfig settings</span>
keras_eval_config = text_format.Parse(<span class="hljs-string">"""
  ## Model information
  model_specs {
    # For keras (and serving models) we need to add a `label_key`.
    label_key: "big_tipper"
  }

  ## You will post training metric information. These will be merged with any built-in
  ## metrics from training.
  metrics_specs {
    metrics { class_name: "ExampleCount" }
    metrics { class_name: "BinaryAccuracy" }
    metrics { class_name: "BinaryCrossentropy" }
    metrics { class_name: "AUC" }
    metrics { class_name: "AUCPrecisionRecall" }
    metrics { class_name: "Precision" }
    metrics { class_name: "Recall" }
    metrics { class_name: "MeanLabel" }
    metrics { class_name: "MeanPrediction" }
    metrics { class_name: "Calibration" }
    metrics { class_name: "CalibrationPlot" }
    metrics { class_name: "ConfusionMatrixPlot" }
    # ... add additional metrics and plots ...
  }

  ## You will slice the information
  slicing_specs {}  # overall slice
  slicing_specs {
    feature_keys: ["trip_start_hour"]
  }
  slicing_specs {
    feature_keys: ["trip_start_day"]
  }
  slicing_specs {
    feature_values: {
      key: "trip_start_month"
      value: "1"
    }
  }
  slicing_specs {
    feature_keys: ["trip_start_hour", "trip_start_day"]
  }
"""</span>, tfma.EvalConfig())
</code></pre>
<p>It's also important that you create a <code>tfma.EvalSharedModel</code> that points at the Keras model.</p>
<pre><code class="lang-python">keras_model_path = os.path.join(MODELS_DIR, <span class="hljs-string">'keras'</span>, <span class="hljs-string">'2'</span>)
keras_eval_shared_model = tfma.default_eval_shared_model(
    eval_saved_model_path=keras_model_path,
    eval_config=keras_eval_config)

keras_output_path = os.path.join(OUTPUT_DIR, <span class="hljs-string">'keras'</span>)
</code></pre>
<p>And then you finally run TFMA, ending this step.</p>
<pre><code class="lang-python">keras_eval_result = tfma.run_model_analysis(
    eval_shared_model=keras_eval_shared_model,
    eval_config=keras_eval_config,
    data_location=tfrecord_file,
    output_path=keras_output_path)
</code></pre>
<p>Now that you have run the evaluation, look at the visualizations using TFMA. For the following examples, you can visualize the results from running the evaluation on the Keras model. </p>
<p>To view metrics, you will use <code>[tfma.view.render_slicing_metrics](https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/view/render_slicing_metrics)</code>. By default, the views will display the <code>Overall</code> slice. To view a particular slice, you can either use the name of the column (by setting <code>slicing_column</code>) or provide a <a target="_blank" href="https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/SlicingSpec"><code>tfma.SlicingSpec</code></a>.</p>
<h2 id="heading-step-6-how-to-visualize-the-metrics-and-plots">Step 6 – How to Visualize the Metrics and Plots</h2>
<p>At this point, it is important that you note that the columns used in the dataset are as follows: </p>
<ul>
<li><code>pickup_community_area</code></li>
<li><code>fare</code></li>
<li><code>trip_start_month</code></li>
<li><code>trip_start_hour</code></li>
<li><code>trip_start_day</code></li>
<li><code>trip_start_timestamp</code></li>
<li><code>pickup_latitude</code></li>
<li><code>pickup_longitude</code></li>
<li><code>dropoff_latitude</code></li>
<li><code>dropoff_longitude</code></li>
<li><code>trip_miles</code></li>
<li><code>pickup_census_tract</code></li>
<li><code>dropoff_census_tract</code></li>
<li><code>payment_type</code></li>
<li><code>company</code></li>
<li><code>trip_seconds</code></li>
<li><code>dropoff_community_area</code>, and </li>
<li><code>tips</code> </li>
</ul>
<p>For a first trial and as an example, you can set <code>slicing_column</code> to look at the <code>trip_start_hour</code> feature from our previous <code>slicing_specs</code>. You are then able to visualize the column. </p>
<pre><code class="lang-python">tfma.view.render_slicing_metrics(keras_eval_result, slicing_column=<span class="hljs-string">'trip_start_hour'</span>)
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-27.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-28.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>On running this, you will see that the metrics visualization supports the following interactions:</p>
<ul>
<li>Click and drag to pan</li>
<li>Scroll to zoom</li>
<li>Right click to reset the view</li>
<li>Hover over the desired data point to see more details.</li>
<li>Select from four different types of views using the selections at the bottom.</li>
</ul>
<p>Note that your initial <code>tfma.EvalConfig</code> has created a whole list of <code>slicing_specs</code>, which you can visualize by updating slice information passed to <code>tfma.view.render_slicing_metrics</code>. Here you can select the <code>trip_start_day</code> slice (days of the week).</p>
<pre><code class="lang-python">tfma.view.render_slicing_metrics(keras_eval_result, slicing_column=<span class="hljs-string">'trip_start_day'</span>)
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-29.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-31.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>TFMA also supports creating feature crosses to analyze combinations of features. To test this, you will create a cross between <code>trip_start_hour</code> and <code>trip_start_day</code>.</p>
<pre><code class="lang-python">tfma.view.render_slicing_metrics(
    keras_eval_result,
    slicing_spec=tfma.SlicingSpec(
        feature_keys=[<span class="hljs-string">'trip_start_hour'</span>, <span class="hljs-string">'trip_start_day'</span>]))
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-32.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Now, crossing the two columns creates a lot of combinations! But you will narrow down your cross to only look at <em>trips that start at 1pm</em>. Then, you will select <code>binary_accuracy</code> from the visualization as shown below.</p>
<pre><code class="lang-python">tfma.view.render_slicing_metrics(
    keras_eval_result,
    slicing_spec=tfma.SlicingSpec(
        feature_keys=[<span class="hljs-string">'trip_start_day'</span>], feature_values={<span class="hljs-string">'trip_start_hour'</span>: <span class="hljs-string">'13'</span>}))
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-33.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-34.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-7-how-to-track-your-models-performance-over-time">Step 7 – How to Track Your Model's Performance Over Time</h2>
<p>You'll use your training dataset for training your model. It will hopefully be representative of your test dataset and the data that will be sent to your model in production.  </p>
<p>But while the data in inference requests may remain the same as your training data, in many cases it will start to change enough so that the performance of your model will change.</p>
<p>That means that you need to monitor and measure your model's performance on an ongoing basis, so that you can be aware of and react to changes.  </p>
<p>Let's look at how TFMA can help.</p>
<pre><code class="lang-python">output_paths = []
<span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">3</span>):
  <span class="hljs-comment"># Create a tfma.EvalSharedModel that points to our saved model.</span>
  eval_shared_model = tfma.default_eval_shared_model(
      eval_saved_model_path=os.path.join(MODELS_DIR, <span class="hljs-string">'keras'</span>, str(i)),
      eval_config=keras_eval_config)

  output_path = os.path.join(OUTPUT_DIR, <span class="hljs-string">'time_series'</span>, str(i))
  output_paths.append(output_path)

  <span class="hljs-comment"># Run TFMA</span>
  tfma.run_model_analysis(eval_shared_model=eval_shared_model,
                          eval_config=keras_eval_config,
                          data_location=tfrecord_file,
                          output_path=output_path)

  eval_results_from_disk = tfma.load_eval_results(output_paths[:<span class="hljs-number">2</span>])

tfma.view.render_time_series(eval_results_from_disk)
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-35.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Using the <code>tfma</code>, you can validate and evaluate your machine learning models across different slices of data. </p>
<p>You can see from the image above that you can evaluate the <code>auc</code> (area under the curve), <code>auc_precision_recall</code>, <code>binary_accuracy</code>, <code>binary_crossentropy</code>, <code>calibration</code>, <code>example_count</code>, <code>mean_label</code>, <code>mean_prediction</code>, <code>precision</code>, and <code>recall</code> metrics of the machine learning model. </p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Finally, it is important that TFMA can be configured to evaluate multiple models at the same time. Typically, you do this to compare a new model against a baseline (such as the currently serving model) to determine what the performance differences in metrics (for example AUC) are relative to the baseline. </p>
<p>When thresholds are configured, TFMA will produce a <a target="_blank" href="https://www.tensorflow.org/tfx/model_analysis/api_docs/python/tfma/ValidationResult"><code>tfma.ValidationResult</code></a> record indicating whether the performance matches expectations.  </p>
<p>If at this point, you have questions about the difference between evaluating machine learning models using <a target="_blank" href="https://www.freecodecamp.org/news/how-to-evaluate-machine-learning-models-using-tensorboard/">TensorBoard</a> and TensorFlow Metrics Analysis (TFMA), this is a valid concern. Both are tools for providing the measurements and visualizations needed during the Machine Learning workflow. </p>
<p>But it is important to note that you use them in different stages of the development process. At a high level, you use TensorBoard to analyze the training process itself while TFMA is concerned with the deep analysis of the 'finished' trained model.</p>
<p>Thank you for reading!  </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Create Serverless Logic with Azure Functions ]]>
                </title>
                <description>
                    <![CDATA[ What is Serverless Computing? Serverless computing is a cloud computing model where backend services are provided on a pay-as-you-use basis.  In this model, developers get to create and run development code without having to manage or provision serve... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-create-serverless-logic-with-azure-functions/</link>
                <guid isPermaLink="false">66ba2dccc346e93df556aff9</guid>
                
                    <category>
                        <![CDATA[ Azure ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Azure Functions ]]>
                    </category>
                
                    <category>
                        <![CDATA[ serverless ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Mon, 26 Sep 2022 22:35:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/09/pexels-sagui-andrea-618833.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <h2 id="heading-what-is-serverless-computing"><strong>What is Serverless Computing?</strong></h2>
<p>Serverless computing is a cloud computing model where backend services are provided on a pay-as-you-use basis. </p>
<p>In this model, developers get to create and run development code without having to manage or provision servers. As such, they get to focus solely on writing the business logic (or front-end development) code instead. </p>
<p>Microsoft Azure provides a wide range of options for designing this kind of architecture. However, the most frequently used methods are Azure Logic Apps and Azure Functions which will be the main focus of this article. </p>
<h2 id="heading-what-are-azure-functions"><strong>What are Azure Functions?</strong></h2>
<p>Azure Functions is the serverless computing model on Microsoft Azure platform for creating serverless applications. It enables developers to host their business logics without the need for infrastructure. </p>
<p>The code for Azure functions can be written in a wide range of programming languages including C#, JavaScript, and Python, amongst others. Like other cloud services, it operates on a pay-per-use basis, where you only pay for the resources you consume. </p>
<p>By the end of this tutorial, you will be able to:</p>
<ul>
<li>Create an Azure function app in the Azure portal.</li>
<li>Exercise a function using triggers.</li>
<li>Monitor and test your Azure function from the Azure portal.</li>
</ul>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<p>You will need a valid and active Microsoft Azure account to follow along with this tutorial. You can use either:</p>
<ul>
<li><a target="_blank" href="https://azure.microsoft.com/en-us/free/">Free Azure Trial</a>: With this option, you will start with $200 Azure credit and will have 30 days to use it, in addition to free services.</li>
<li><a target="_blank" href="https://azure.microsoft.com/en-us/free/students/">Azure for Students</a>: This offer is available for students only. With this option, you will start with $100 Azure credit with no credit card required and access to popular services for free whilst you have your credit.</li>
</ul>
<h2 id="heading-step-1-create-your-azure-function-app"><strong>Step 1 – Create your Azure Function App</strong></h2>
<p>To establish a serverless computing resource for your business logic using Azure Functions, it is essential to create an Azure Function application. Having created a valid and active Microsoft Azure account, navigate to the <a target="_blank" href="https://portal.azure.com/">portal</a>. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-128.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Select <code>Create a resource</code> </li>
<li>Select the <code>Create</code> button underneath the <code>Function App</code> pane. </li>
<li>On clicking the button, a page where you enter the details of your project appears as shown below. </li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-129.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-130.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-131.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Enter the configuration details for this tutorial under the <code>Basics</code> tab before clicking the <code>Review + create</code> button</p>
<ul>
<li>Enter the <code>Subscription</code> available on your account. Note that your subscription might not be <code>Visual Studio Enterprise Subscription</code> as shown in mine. </li>
<li>For the <code>Resource group</code>, if you have created one before, you could use it. However, if you have not created one or are not familiar with Azure resource group, create a new one by using the <code>Create new</code> button. </li>
</ul>
<p>At its core, a resource group is used to group similar Azure services on your Azure subscription together to make managing them easier. </p>
<ul>
<li>For the <code>Function App name</code> option, enter a globally unique app name. It is important to note that this name is will become part of the base URL for your service. </li>
<li>For the <code>Publish</code> option, select <code>Code</code>. </li>
<li>Choose <code>Node.js</code> for the <code>Runtime Slack</code> option since this tutorial's function examples were implemented using that language.</li>
<li>Leave the <code>Version</code> option as default.</li>
<li>Select the region that is geographically nearest to you when filling out the <code>Region</code> choice. A region is a collection of physical server data centers. Given that my base of operations is in Lagos, Nigeria, I chose <code>South Africa North</code>.</li>
<li>For the <code>Operating System</code>, select one that conforms with your selection of runtime.</li>
<li>For the <code>Plan</code> option, select <code>Consumption (Serverless)</code>. The plan you choose will determine how your app scales and what features are enabled.  </li>
<li>At this point, you can then click the <code>Review + create</code> button.</li>
</ul>
<p>The validation and deployment process usually takes up to three minutes. When the validation and deployment processes are both completed for the Azure Function set up, you can then verify that your Azure function app is running.</p>
<h2 id="heading-step-2-verify-that-your-azure-function-app-is-running"><strong>Step 2 – Verify that your Azure Function App is Running</strong></h2>
<p>Once the deployment process is done, select <code>Go to resource</code>. Your function's App pane will now appear. To open it in a browser, select the <code>URL</code> link in the <code>Essentials</code> section. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-132.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>With the message above, you will see a standard Azure functions web app page appear: <em>Your Function 4.0 app is up and running.</em> </p>
<h2 id="heading-step-3-run-your-code-on-demand-with-azure-functions"><strong>Step 3 – Run your Code On-Demand with Azure Functions</strong></h2>
<p>With the function app created, the next step is to build and configure the function. To do this, you have to understand what Triggers and Bindings are. </p>
<blockquote>
<p>Triggers cause a function to run. A trigger defines how a function is invoked and a function must have exactly one trigger. Triggers have associated data, which is often provided as the payload of the function. Binding to a function is a way of declaratively connecting another resource to the function; bindings may be connected as <em>input bindings</em>, <em>output bindings</em>, or both. Data from bindings is provided to the function as parameters. – <a target="_blank" href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings?tabs=csharp">Microsoft Learn Documentation</a></p>
</blockquote>
<p>In general, Azure Functions run in response to an event. This event is known as a <strong>Trigger</strong> and <strong>Bindings</strong> are used to connect resources to a function. The typical triggers on Azure range from a blob storage that runs a function when a blob is created or updated to a timer that runs a function on a schedule.</p>
<p>To run your code on Azure Functions, you need to first create your function to run your code within the function app using the template. </p>
<p>To do this, click the <code>Function</code> tag on the menu bar on the left of your functions app's home page. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-134.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li>Click the <code>+ Create</code> button to create the function. </li>
<li>Select the <code>Azure Queue Storage trigger</code> template. This trigger runs the functions app when it detects that a message has been added to an Azure storage queue. </li>
<li>Leave everything else as its default value. </li>
<li>Click the <code>Create</code> button to create the function. </li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-135.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Given that the function was created with a template, several other files will be created automatically. These files comprises of a source code and a configuration file. </p>
<ul>
<li>Click on the <code>Code + Test</code> button on the left pane and open the <code>function.json</code> file by selecting it from the dropdown. </li>
<li>Replace the block of code it shows with the one below. </li>
</ul>
<pre><code class="lang-python">{
  <span class="hljs-string">"bindings"</span>: [
    {
      <span class="hljs-string">"name"</span>: <span class="hljs-string">"order"</span>,
      <span class="hljs-string">"type"</span>: <span class="hljs-string">"queueTrigger"</span>,
      <span class="hljs-string">"direction"</span>: <span class="hljs-string">"in"</span>,
      <span class="hljs-string">"queueName"</span>: <span class="hljs-string">"myqueue-items"</span>,
      <span class="hljs-string">"connection"</span>: <span class="hljs-string">"MY_STORAGE_ACCT_APP_SETTING"</span>
    },
    {
      <span class="hljs-string">"name"</span>: <span class="hljs-string">"$return"</span>,
      <span class="hljs-string">"type"</span>: <span class="hljs-string">"table"</span>,
      <span class="hljs-string">"direction"</span>: <span class="hljs-string">"out"</span>,
      <span class="hljs-string">"tableName"</span>: <span class="hljs-string">"outTable"</span>,
      <span class="hljs-string">"connection"</span>: <span class="hljs-string">"MY_TABLE_STORAGE_ACCT_APP_SETTING"</span>
    }
  ]
}
</code></pre>
<p>This block of code sets the trigger for the function as <strong>when a message is added to the queue named <code>myqueue-items</code>.</strong> Furthermore, it sends the return value to the <code>outTable</code>. </p>
<ul>
<li>Save and <em>Test/Run</em> the function whilst leaving the testing details as their default values and run the function app. </li>
<li>You will see the output shown below.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-136.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The fact that the outcome automatically displays on the <strong>Output tab</strong> suggests that the function app functions well. Because there isn't any business logic applied to the function, the graphic above is blank.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In this tutorial, you have seen that serverless computing is a great option for hosting business logic code in the cloud. You have seen that with serverless offers such as Azure Functions, you can write your business logic in the language of your choice.</p>
<p>Also, it is important to note that not only does the use of serverless computing solutions avoid the over-allocation of infrastructure (because they can be created and destroyed on demand), but they are also event driven. Event driven in the sense that they run only in response to an event (called a 'trigger'), such as a message being added to a queue, or receiving an HTTP request.</p>
<p>Finally, I share my writings on <a target="_blank" href="https://twitter.com/SalimOyinlola">Twitter</a> if you enjoyed this article and want to see more.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Evaluate Machine Learning Models using TensorBoard with TensorFlow ]]>
                </title>
                <description>
                    <![CDATA[ A key part of the Machine Learning pipeline is finding a model that best represents your data and will function effectively on future datasets.  By virtue of their very nature, Machine Learning models improve iteratively. There is hardly any machine ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-evaluate-machine-learning-models-using-tensorboard/</link>
                <guid isPermaLink="false">66ba2dcf0ecf2905f20d3648</guid>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ TensorFlow ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Wed, 14 Sep 2022 18:31:32 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/09/TensorFlow_Logo_with_text.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A key part of the Machine Learning pipeline is finding a model that best represents your data and will function effectively on future datasets. </p>
<p>By virtue of their very nature, Machine Learning models improve iteratively. There is hardly any machine learning model that is trained perfectly on the first try. Usuaully, several iterations are required. </p>
<p>As you would imagine, these models have to be evaluated to make them better. In other words, a machine learning model needs to be assessed before it can be improved on. </p>
<p><a target="_blank" href="https://www.tensorflow.org/tensorboard/get_started">TensorBoard</a> was developed to give machine learning engineers a more in-depth look at the performance of their models. </p>
<h2 id="heading-what-is-tensorboard"><strong>What is TensorBoard?</strong></h2>
<p>TensorBoard's basic functionality is to deliver the metrics and visualizations you need for your Machine Learning workflow. It allows you to monitor loss and accuracy, view and assess error graphs, and perform many other tasks. </p>
<p>TensorBoard uses graph concepts to represent the data flow and model actions whilst allowing you to see the graph topologies and parameters of complex, huge models. It also has a very user-friendly and basic UI.</p>
<p>In this tutorial, you will analyze and evaluate results on a trained machine learning model. The model you will use will be trained for a <a target="_blank" href="https://www.tensorflow.org/api_docs/python/tf/keras/datasets/mnist">MNIST handwritten digits dataset</a>. It uses the MNIST (Modified National Institute of Standards and Technology) database, which contains an ample collection of handwritten digits. This dataset is commonly used for training various image processing systems.</p>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<p>To complete this tutorial, you will need:</p>
<ol>
<li>Fundamental understanding of the workings of Machine Learning models.</li>
<li>A new Google Colab notebook to run the Python code in your Google Drive. You can set this up by following this <a target="_blank" href="https://www.freecodecamp.org/news/google-colaboratory-python-code-in-your-google-drive/">tutorial</a>.</li>
</ol>
<h2 id="heading-step-1-how-to-set-up-tensorboard"><strong>Step 1 – How to Set Up TensorBoard</strong></h2>
<p>Since TensorBoard comes automatically with TensorFlow, you don't need to install it using <code>pip</code> in this setup. Also, since TensorFlow comes pre-installed when you create a new notebook on Google Colab, TensorBoard comes pre-installed as well. So, when setting TensorBoard up, you only need to import <code>tensorflow</code> .  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-157.png" alt="Image" width="600" height="400" loading="lazy">
<em>A blank (new) notebook in dark mode</em></p>
<ul>
<li>Load the <code>tensorboard</code> extension using the <code>%load_ext</code> magic in your notebook. </li>
<li>After doing this, import the necessary libraries (that is, <code>tensorflow</code> and <code>datetime</code>) as shown below:</li>
</ul>
<pre><code class="lang-python">%load_ext tensorboard
</code></pre>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">import</span> datetime
</code></pre>
<p>At this point, you have successfully imported an instance of <code>TensorBoard</code> and set it up. You can now get started.</p>
<h2 id="heading-step-2-how-to-create-and-train-the-model"><strong>Step 2 – How to Create and Train the Model</strong></h2>
<p>In this tutorial, you will use the MNIST dataset, which includes tiny 28 x 28-pixel handwritten single-digit greyscale images. The dataset, which is one of the pre-installed datasets offered by <code>Keras</code> is frequently used to develop Machine Learning models for digit recognition. </p>
<ul>
<li>Create an instance of the dataset and name it <code>mnist</code>.</li>
<li>Split the data into train sets and test sets. A train set is a subset of the original data that is used to train the machine learning model while a test set is the subset that is used to check the accuracy of the model. </li>
<li>Standardize all the values of your train and test sets. This implies normalizing the image to the [0,1] range.</li>
<li>Define a function that will be used to train the machine learning model on your dataset. The <code>Sequential</code> Keras model will be used. </li>
</ul>
<pre><code class="lang-python">mnist = tf.keras.datasets.mnist
</code></pre>
<pre><code class="lang-python">(x_train, y_train),(x_test, y_test) = mnist.load_data()
</code></pre>
<pre><code class="lang-python">x_train, x_test = x_train/<span class="hljs-number">255.0</span>, x_test/<span class="hljs-number">255.0</span>
</code></pre>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_model</span>():</span>
  <span class="hljs-keyword">return</span> tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=(<span class="hljs-number">28</span>, <span class="hljs-number">28</span>)),
    tf.keras.layers.Dense(<span class="hljs-number">512</span>, activation=<span class="hljs-string">'relu'</span>),
    tf.keras.layers.Dropout(<span class="hljs-number">0.2</span>),
    tf.keras.layers.Dense(<span class="hljs-number">10</span>, activation=<span class="hljs-string">'softmax'</span>)
  ])
</code></pre>
<p>You will use the <code>Sequential</code> Keras model. At its core, it groups a linear stack of layers into <code>tf.keras.Model</code> whilst providing training and inference features on this model.</p>
<p>The <code>.Flatten()</code> layer flattens the input without affecting the batch size. The input shape in this example is 28 x 28 since the images from the dataset are 28×28-pixel grayscale images of handwritten single-digits. The first <code>.Dense()</code> layer is a regular densely connected NN layer. </p>
<p>The activation function used is 'relu' and the dimensionality of its output space is 512. The <code>.Dropout()</code> layer drops some of the input with the fraction of the input units dropped in this tutorial given as 0.2. </p>
<p>Finally, like the first one, the second. <code>Dense</code> layer is also your regular densely connected NN layer. The activation function we're using is 'softmax' and the dimensionality of its output space is ten.</p>
<ul>
<li>Call the defined function for the model like this: </li>
<li>With the defined function called, train the model with suitable parameters.</li>
<li>Using the <code>datatime</code> library you previously imported, place the logs in a timestamped subdirectory to allow easy selection of different training runs.</li>
</ul>
<pre><code class="lang-python">model = create_model()
</code></pre>
<pre><code class="lang-python">model.compile(optimizer=<span class="hljs-string">'adam'</span>,
              loss=<span class="hljs-string">'sparse_categorical_crossentropy'</span>,
              metrics=[<span class="hljs-string">'accuracy'</span>])
</code></pre>
<p>The logs are important because the TensorBoard will read from the logs to display the various visualizations with respect to the time at the point. </p>
<pre><code class="lang-python">log_dir = <span class="hljs-string">"logs/fit/"</span> + datetime.datetime.now().strftime(<span class="hljs-string">"%Y%m%d-%H%M%S"</span>)
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=<span class="hljs-number">1</span>)
</code></pre>
<ul>
<li>Finally, train (or fit) the machine learning model on three epochs (iterations).</li>
</ul>
<pre><code class="lang-python">model.fit(x=x_train, 
          y=y_train, 
          epochs=<span class="hljs-number">3</span>, 
          validation_data=(x_test, y_test), 
          callbacks=[tensorboard_callback])
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-158.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-3-how-to-evaluate-the-model"><strong>Step 3 – How to Evaluate the Model</strong></h2>
<p>To start TensorBoard within your notebook, run the code below:</p>
<pre><code class="lang-python">%tensorboard --logdir logs/fit
</code></pre>
<p>You can now view the dashboards showing the metrics for the model on tabs at the top and evaluate and improve your machine learning models accordingly.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-159.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-step-4-how-to-improve-the-model"><strong>Step 4 – How to Improve the Model</strong></h2>
<p>Since the point of evaluating your Machine Learning models is to gain better insight to improve the algorithm, it is imperative that we enhance our model. With these visuals, you can now see the in-depth performance of the model.</p>
<ul>
<li>The <code>Scalars</code> dashboard can be used to observe other scalar values such as training efficiency and learning rate. It demonstrates how the metrics and loss fluctuate with each epoch. </li>
<li>As the name implies, the <code>Graphs</code> dashboard is used to visualize your model. </li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-160.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Graph with the tensorboard</em></p>
<p>To improve this model, you will adjust the number of epochs from 3 to 6 and see how the model performs.</p>
<p>In general, the number of epochs is the number of iterations over the entire training dataset the machine learning model is trained on.</p>
<p>Intuitively, increasing this number almost always improves the performance of your machine learning model. To do this, you will run the code as follows:</p>
<pre><code class="lang-python">model.fit(x=x_train, 
          y=y_train, 
          epochs=<span class="hljs-number">6</span>, 
          validation_data=(x_test, y_test), 
          callbacks=[tensorboard_callback])
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-161.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>With the change we made, you can then generate another TensorBoard like this:</p>
<pre><code>%tensorboard --logdir logs/fit
</code></pre><p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-162.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>From the newly generated visuals, you can see that there is a remarkable improvement in the model's performance.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In this article, you learned how you can use TensorBoard to assess and improve your Machine Learning model's performance.</p>
<p>If at this point you have questions about the difference between TensorBoard and TensorFlow Metrics Analysis (TFMA), this is a valid concern. After all, both are tools for providing the measurements and visualizations needed during the Machine Learning workflow.</p>
<p>But it is important to note that you use each of these tools in distinct stages of the development process. At its core, TensorBoard is used to analyze the training process itself, while TFMA is concerned with the analysis of the 'finished' trained model.</p>
<p>Finally, I share my writings on <a target="_blank" href="https://twitter.com/SalimOyinlola">Twitter</a> if you enjoyed this article and want to see more.</p>
<p>Thank you for reading :)</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Read and Write Data using Azure Databricks ]]>
                </title>
                <description>
                    <![CDATA[ Azure Databricks is a data analytics platform hosted on Microsoft Azure that helps you analyze data using Apache Spark.  Databricks helps you create data apps more quickly. This in turn brings to light valuable insights from your data and helps you c... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-read-and-write-data-using-azure-databricks/</link>
                <guid isPermaLink="false">66ba2dd292031ccc9bfc64d6</guid>
                
                    <category>
                        <![CDATA[ Azure ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data analysis ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data analytics ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Salim Oyinlola ]]>
                </dc:creator>
                <pubDate>Mon, 12 Sep 2022 18:49:37 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/09/download--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Azure Databricks is a data analytics platform hosted on Microsoft Azure that helps you analyze data using Apache Spark. </p>
<p>Databricks helps you create data apps more quickly. This in turn brings to light valuable insights from your data and helps you create robust Artificial Intelligence solutions. </p>
<p>Azure Databricks also combines the strength of Databricks as an end-to-end Apache Spark platform with the scalability and security of Microsoft's Azure platform. </p>
<p>In this tutorial, you will learn how to get started with the platform in Microsoft Azure and see how to perform data interactions including reading, writing, and analyzing datasets. By the end of this tutorial, you will be able to use Azure Databricks to read multiple file types, both with and without a schema. </p>
<h3 id="heading-prerequisites"><strong>Prerequisites</strong></h3>
<p>You will need a valid and active Microsoft Azure account.</p>
<ul>
<li><a target="_blank" href="https://azure.microsoft.com/en-us/free/">Free Azure Trial</a>: With this option, you will start with $100 Azure credit and will have 30 days to use it in addition to free services.</li>
<li><a target="_blank" href="https://azure.microsoft.com/en-us/free/students/">Azure for Students</a>: This offer is available for students only. With this option, you will start with $100 Azure credit with no credit card required. You'll get access to popular services for free whilst you have your credit.</li>
</ul>
<h2 id="heading-how-to-create-your-databricks-workspace"><strong>How to Create Your Databricks Workspace</strong></h2>
<p>You must create an Azure Databricks workspace in your Azure subscription before you can utilize Azure Databricks. Go to the <a target="_blank" href="https://portal.azure.com/">Azure portal</a> to do this. As long as you've created a valid and active Microsoft Azure account, this will function.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-137.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Microsoft Azure Home Page</em></p>
<p>Once there, click the <code>Create a resource</code> button.</p>
<p>On the search prompt in the Create a resource page, search for <code>Azure Databricks</code> and select the <code>Azure Databricks</code> option.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-138.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Microsoft Azure page showing the list of popular resources</em></p>
<p>Open the <code>Azure Databricks</code> tab and create an instance. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-140.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Azure Databricks pane.</em></p>
<p>Click the blue <code>Create</code> button (arrow pointed at it) to create an instance. </p>
<p>Then enter the project details before clicking the <code>Review + create</code> button.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-142.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Azure Databricks configuration page</em></p>
<p>It is important to note that the <code>Subscription</code> option shown above will differ from yours. It will depend on the Azure subscription you have available on your account. </p>
<p>Fill the <code>Workspace name</code> field with a globally unique name. Mine is named <code>salim-freeCodeCamp-databricks1</code>. </p>
<p>Enter the location closest to where you are in the <code>Region</code> option. A region is a set of physical data centers that serve as servers. Since I am based in Lagos, Nigeria, I selected <code>South Africa North</code>. </p>
<p>Select the <code>Standard</code> option which includes Apache Spark with Azure AD in the <code>Pricing Tier</code> option. </p>
<p>With all the configurations set, click the <code>Review + create</code> button. The validation process usually takes about two minutes. </p>
<p>With the validation and deployment processes completed for the workspace, launch the workspace using the <code>Launch Workspace</code> button that appears. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-144.png" alt="Image" width="600" height="400" loading="lazy">
<em>The home page for the created instance of Azure databricks - <code>salim-freeCodeCamp-databricks</code></em></p>
<p>Click on the button and you will automatically be signed in using the Azure Directory Single Sign On.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-145.png" alt="Image" width="600" height="400" loading="lazy">
<em>Signing into the workspace of the integration of Microsoft Azure and Databricks</em></p>
<p>The Microsoft Azure Databricks home page will come up in a new tab as shown below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-146.png" alt="Image" width="600" height="400" loading="lazy">
<em>The Microsoft Azure Databricks home page</em></p>
<p>With the workspace launch, create a cluster using the <code>Create a cluster</code> option on the left of the page.</p>
<p>After you have clicked the button and you have created any prior, you will pick one and build on it. Else, you will have to create a new cluster using the <code>Create Cluster</code> button. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-148.png" alt="Image" width="600" height="400" loading="lazy">
<em>Set the configurations for the Azure Databricks cluster</em></p>
<p>To create the cluster, you have to set the configurations. Choose the <code>Single node</code> option, changing from the <code>Multi node</code> default option, and maintain the other options as default. </p>
<p>Click the <code>Create Cluster</code> button at the bottom of the page. Note that this will take a few minutes and that if the dataset is large, you can explore the <code>Multi node</code> option. </p>
<p>Having created the cluster, import some ready-to-use notebooks by navigating to <code>Workspace</code> <code>&gt;</code> <code>Users</code> <code>&gt;</code> <code>your_account</code> on the left taskbar.</p>
<p>Right-click and select the <code>Import</code> option on the dropdown menu.</p>
<p>With the cluster created, you will then have to import some ready to use notebooks. </p>
<p>To do this, using the left taskbar, you will navigate through <code>Workspace</code> <code>&gt;</code> <code>Users</code> <code>&gt;</code> <code>your_account</code> . Then right-click to see the dropdown menu. You will then select the <code>Import</code> option on the dropdown menu.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-150.png" alt="Image" width="600" height="400" loading="lazy">
<em>The <code>import</code> button will be used to import the dataset to be used</em></p>
<p>Once you click on the <code>Import</code> button, you will then select the <code>URL</code> option and paste the following URL:</p>
<pre><code>https:<span class="hljs-comment">//github.com/salimcodes/microsoft-learning-paths-databricks-notebooks/blob/master/data-engineering/DBC/03-Reading-and-writing-data-in-Azure-Databricks.dbc</span>
</code></pre><p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-151.png" alt="Image" width="600" height="400" loading="lazy">
<em>The database folder named <code>03-Reading-and-writing-data-in-Azure-Databricks.dbc</code> will be used,</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-152.png" alt="Image" width="600" height="400" loading="lazy">
<em>You will see he list of files in the <code>03-Reading-and-writing-data-in-Azure-Databricks.dbc</code> database folder</em></p>
<p>The image above is what the workspace will like after downloading the file. As such, you have created a Databricks workspace. </p>
<h2 id="heading-how-to-read-the-data-in-csv-format"><strong>How to Read the Data in CSV Format</strong></h2>
<p>Open the file named <code>Reading Data - CSV</code>.</p>
<p>Upon opening the file, you will see the notebook shown below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-153.png" alt="Image" width="600" height="400" loading="lazy">
<em>You will see that the cluster created earlier has not been attached.</em></p>
<p>On the top left corner, you will change the dropdown which initially shows <code>Detached</code> to your cluster's name. Mine is named <code>Salim Oyinlola's freeCodeCamp Cluster</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-154.png" alt="Image" width="600" height="400" loading="lazy">
<em>The cluster initially created is now attahed to the python notebook</em></p>
<p>With your cluster attached, you will then run all the cells one after the other.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/image-261.png" alt="image-261" width="600" height="400" loading="lazy">
<em>Running the first cell of the python notebook will initialize the classroom variables &amp; function, mount the dataset and create user-specific database</em></p>
<p>At its core, the notebook simply reads the data in <code>csv</code> format. Then it adds an option that tells the reader that the data contains a header and to use that header to determine our column names. </p>
<p>You can also add an option that tells the reader to infer each column's data types (also known as a schema).</p>
<p>It is important to note that data can be read in different formats such as JSON (with or without schemas), parquet, and table and views. To achieve this, you can simply run the respective notebooks for each format.</p>
<h2 id="heading-how-to-write-data-into-a-parquet-file"><strong>How to Write Data into a Parquet File</strong></h2>
<p>Just as there are many ways to read data, there are many ways to write data. But in this notebook, we'll get a quick peek of how to write data back out to Parquet files.</p>
<p>Apache Parquet is a column storage file format that Hadoop systems (such as Spark and Hive) use. The file format is cross-platform, language independent, and it stores data in a column layout using a binary representation.</p>
<p>Parquet files, which effectively store large datasets, have the extension <code>.parquet</code>.</p>
<p>Like what you did when reading data, you will also run the cells one after the other.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/image-275.png" alt="image-275" width="600" height="400" loading="lazy">
<em>The cell to write data into a parquet file</em></p>
<p>Integral to writing into the parquet file is creating a DataFrame. You will be creating one by running this cell.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/image-276.png" alt="image-276" width="600" height="400" loading="lazy">
<em>This cell shows that the existing files are being overwritten</em></p>
<p>The <code>.mode"overwrite"</code> method shown below implies that by writing DataFrame to parquet files, you are replacing existing files.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/image-277.png" alt="image-277" width="600" height="400" loading="lazy">
<em>The file has been written and saved in an output location.</em></p>
<p>At its core, the notebook reads a <code>.tsv</code> file (the same used to read for the <code>.csv</code> file) and writes it back out as a Parquet file.</p>
<h2 id="heading-how-to-delete-the-azure-databricks-instance-optional"><strong>How to Delete the Azure Databricks Instance (Optional)</strong></h2>
<p>Finally, the Azure resources that you created in this tutorial can incur ongoing costs. To avoid such costs, it is important to delete the resource or resource group that contains all those resources. You can do that by using the Azure portal.</p>
<ul>
<li>Navigate to the Azure portal.</li>
<li>Navigate to the resource group that contains your Azure Databricks instance.</li>
<li>Select <code>Delete resource group</code>.</li>
<li>Type the name of the resource group in the confirmation text box.</li>
<li>Select <code>Delete</code>.</li>
</ul>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In this tutorial, you have learned the basics about reading and writing data in Azure Databricks.</p>
<p>You now understand the basics of Azure Databricks, including what it is, how to install it, how to read CSV and parquet files, and how to read parquet files into the Databricks file system (DBFS) using compression options.</p>
<p>Finally, I share my writings on <a target="_blank" href="https://twitter.com/SalimOpines">Twitter</a> if you enjoyed this article and want to see more.</p>
<p>Thank you for reading :)</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
