<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tavishi on Medium]]></title>
        <description><![CDATA[Stories by Tavishi on Medium]]></description>
        <link>https://medium.com/@tavishi.1402?source=rss-639c4ec34ac7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0t9JSQEoXLyl3uXejbh0pQ.jpeg</url>
            <title>Stories by Tavishi on Medium</title>
            <link>https://medium.com/@tavishi.1402?source=rss-639c4ec34ac7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 08:57:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tavishi.1402/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Blog Scraping Demystified: A Step-by-Step Guide with Selenium and newspaper3k]]></title>
            <link>https://medium.com/@tavishi.1402/blog-scraping-demystified-a-step-by-step-guide-with-selenium-and-newspaper3k-5d6219540ec0?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d6219540ec0</guid>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Thu, 30 Nov 2023 16:39:45 GMT</pubDate>
            <atom:updated>2023-11-30T17:10:04.419Z</atom:updated>
            <content:encoded><![CDATA[<p>In the realm of web scraping, two powerful Python libraries, Selenium and newspaper3k, stand out for their ability to extract valuable information from websites. In this article, we’ll delve into the world of web scraping and demonstrate the use of these libraries to gather blog information from the website ‘<a href="https://dataconomy.com/">Dataconomy</a>.’</p><p>For those unfamiliar with these tools, Selenium is a web testing library, and newspaper3k is a library designed for parsing news articles. Additionally, we’ll touch upon the roles of other essential libraries, such as Requests and BeautifulSoup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hYI1FhGAPdhCXXvcTnnPRw.jpeg" /></figure><h3>Selenium and newspaper3k: A Brief Overview</h3><h4>Selenium</h4><p>Selenium is a widely-used open-source framework for automating web browsers. It provides a convenient way to simulate user interactions with a web page, making it an excellent choice for tasks like web scraping. By controlling a browser programmatically, Selenium allows developers to navigate websites, interact with page elements, and retrieve data dynamically.</p><h4>newspaper3k</h4><p>newspaper3k is a Python library specifically crafted for extracting and curating information from news articles. It simplifies the process of scraping textual content, metadata from articles, and many more things on various websites. With newspaper3k, developers can easily parse and analyze the content of news articles, making it a valuable tool for web scraping projects focused on news or blog articles.</p><h3>Additional Libraries: Requests and BeautifulSoup</h3><h4>Requests</h4><p>Requests is a Python library simplifying HTTP requests. It’s crucial for fetching web content, making it a fundamental tool for web scraping. Developers use it to interact with websites, retrieve HTML, and handle various HTTP methods due to its user-friendly syntax and versatility.</p><h4>BeautifulSoup</h4><p>BeautifulSoup is a Python library tailored for parsing HTML and XML files. It transforms complex documents into a navigable tree structure, facilitating web scraping tasks. With its intuitive syntax, developers can quickly extract specific data from web pages, making it an essential companion to streamline the extraction process when combined with requests.</p><h3>Project Workflow</h3><h4>Objective</h4><p>The primary goal of this project is to collect article-related data from various blogs across different categories on the Dataconomy website.</p><h4>Workflow</h4><ol><li><strong>Category Navigation:</strong> The project begins by navigating to a specific category on the Dataconomy website (such as Machine Learning, Artificial Intelligence, Blockchain, etc).</li><li><strong>Blog Information Scraping:</strong> Once in a category, the script utilizes Selenium to scrape information related to all the blogs within that specific category. This includes extracting blog titles, URLs, and other relevant details.</li><li><strong>Blog URL Visit:</strong> After obtaining the information for each blog in a category, the script proceeds to visit the URLs of these blogs. This step is crucial for extracting detailed article-related data.</li><li><strong>Article Data Extraction:</strong> Using the newspaper3k library in conjunction with Requests and BeautifulSoup, the script fetches the HTML content from each blog’s URL. It then parses this content to extract valuable article-related data. This includes information such as the article title, author, text content, and many more.</li><li><strong>Iteration through Categories:</strong> The project doesn’t stop with one category. It systematically repeats the entire process for all the blogs present in other categories on the Dataconomy website. This ensures a comprehensive extraction of article-related data from diverse topics.</li></ol><h3>Grasping the project workflow, let’s begin coding!</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FBWEY1LI6WdaN2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fbook-books-read-BWEY1LI6WdaN2&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcm8wNGJlOXR6eTd4dmg5Nms2NjdkZHJqc3ZqYzFpMmc1M2N6MDkzYyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FBWEY1LI6WdaN2%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="305" frameborder="0" scrolling="no"><a href="https://medium.com/media/461ac1285fd3c566b7be05c5bb9548ca/href">https://medium.com/media/461ac1285fd3c566b7be05c5bb9548ca/href</a></iframe><p><strong>Install the necessary libraries.</strong></p><pre># Install the necessary libraries<br>!pip install selenium<br>!pip install requests<br>!pip install newspaper3k<br>!pip install beautifulsoup4</pre><p><strong>Import essential modules and libraries.</strong></p><pre># Import necessary libraries and modules<br>import os <br>import re <br>import requests <br>from newspaper import Article <br>from bs4 import BeautifulSoup <br>from selenium import webdriver <br>from selenium.webdriver.common.keys import Keys<br>from selenium.webdriver.common.by import By <br>from selenium.webdriver.chrome.options import Options <br>from selenium.common.exceptions import NoSuchElementException<br>from selenium.webdriver.common.action_chains import ActionChains <br>import time</pre><p><strong>Selenium Configuration</strong>.</p><ul><li>Configure Selenium options for headless browsing using Chrome.</li><li>Maximize the browser window and navigate to <a href="https://dataconomy.com/">Dataconomy</a>.</li></ul><pre># Configure Selenium options by setting up headless browsing using Chrome<br>options = Options()<br>options.add_argument(&quot;--headless=new&quot;)<br>driver = webdriver.Chrome(options=options)<br>driver.maximize_window()<br>driver.get(&quot;https://dataconomy.com/&quot;)</pre><p><strong>Dictionaries Initialization.</strong></p><ul><li>Initialize dictionaries to store blog information.</li></ul><pre># Initialize dictionaries to store blog information<br>blogs_URL = {}<br>blogs_title_set = {}<br>blogs_title = {}</pre><p><strong>Function to Navigate to a Specific Category URL.</strong></p><ul><li>Define a function (go_to_category) to navigate to a specific category URL.</li></ul><pre># Function to navigate to a specific category URL<br>def go_to_category(driver, category_URL):<br>    <br>    driver.get(category_URL)</pre><p><strong>List of URLs for Different Blog Categories.</strong></p><ul><li>Define a list of URLs for different blog categories.</li></ul><pre># List of URLs for different blog categories<br>category_sub_URLs = [&quot;news&quot;, &quot;topics/data-science/artificial-intelligence&quot;, &quot;topics/data-science/big-data&quot;, &quot;topics/data-science/machine-learning&quot;, &quot;tech-trends/blockchain-tech-trends&quot;, &quot;cybersecurity&quot;, &quot;topics/fintech&quot;, &quot;gaming&quot;, &quot;topics/internet-of-things&quot;, &quot;startups&quot;, &quot;industry/energy-environment&quot;, &quot;industry/finance&quot;, &quot;industry/healthcare&quot;, &quot;industry/industrial-goods-and-services&quot;, &quot;industry/marketing-sales&quot;, &quot;industry/retail-and-consumer-industry&quot;, &quot;industry/technology-and-it-industry&quot;, &quot;industry/transportation-and-logistics&quot;]</pre><p><strong>Function to Scrape Blogs from a Given Category.</strong></p><ul><li>The function initially scrapes information related to the first four blogs from a given category, since they are repeated on every page of that particular category.</li><li>Then, it continues scraping blogs from subsequent pages.</li></ul><pre># Function to scrape blogs from a given category<br>def scrape_blogs(driver, category_sub_URLs, blogs_URL, blogs_title, blogs_title_set):<br>    <br>    # Loop through each category URL<br>    for category_sub_URL in category_sub_URLs:<br>        go_to_category(driver, f&quot;%%htmltps://dataconomy.com/category/{category_sub_URL}/&quot;)<br><br>        # Scrape the first four blogs<br>        for i in range(1,5):<br><br>            blog = driver.find_element(By.CLASS_NAME, f&#39;jeg_hero_item_{i}&#39;)<br>            blog_category = blog.find_element(By.CLASS_NAME, &#39;jeg_post_category&#39;).text<br>            blog_title_tag = blog.find_element(By.CLASS_NAME, &#39;jeg_post_title&#39;)<br><br>            # Check and update dictionaries with blog information<br>            if blog_category not in blogs_title:<br>                blogs_title[blog_category] = []<br>                blogs_URL[blog_category] = []<br>                blogs_title_set[blog_category] = set()<br><br>            # Store blog information only if the blog has not been visited yet<br>            if blog_title_tag.text not in blogs_title_set[blog_category]:<br>                blogs_title_set[blog_category].add(blog_title_tag.text)<br>                blogs_title[blog_category].append(blog_title_tag.text)<br>                blogs_URL[blog_category].append(blog_title_tag.find_element(By.TAG_NAME, &#39;a&#39;).get_attribute(&quot;href&quot;))<br><br>        page_no = 1<br>        <br>        # Continue scraping blogs from subsequent pages<br>        while True:<br>            try:<br>                remaining_blogs = driver.find_elements(By.CLASS_NAME, &#39;jeg_pl_md_1&#39;)<br><br>                for blog in remaining_blogs:<br><br>                    blog_category = blog.find_element(By.CLASS_NAME, &#39;jeg_post_category&#39;).text<br>                    blog_title_tag = blog.find_element(By.CLASS_NAME, &#39;jeg_post_title&#39;)<br><br>                    # Check and update dictionaries with blog information<br>                    if blog_category not in blogs_title:<br>                        blogs_title[blog_category] = []<br>                        blogs_URL[blog_category] = []<br>                        blogs_title_set[blog_category] = set()<br><br>                    # Store blog information only if the blog has not been visited yet<br>                    if blog_title_tag.text not in blogs_title_set[blog_category]:<br>                        blogs_title_set[blog_category].add(blog_title_tag.text)<br>                        blogs_title[blog_category].append(blog_title_tag.text)<br>                        blogs_URL[blog_category].append(blog_title_tag.find_element(By.TAG_NAME, &#39;a&#39;).get_attribute(&quot;href&quot;))<br><br>                print(f&quot;Page {page_no} over...&quot;)<br>                page_no += 1<br><br>                # Scroll to the end of the page<br>                webdriver.ActionChains(driver).send_keys(Keys.END).perform()<br><br>                # Navigate to the next page<br>                next_page_button = driver.find_element(By.XPATH, &quot;//a[@class=&#39;page_nav next&#39;]&quot;)<br>                webdriver.ActionChains(driver).move_to_element(next_page_button).click(next_page_button).perform()<br><br>            except NoSuchElementException:<br>                print(f&quot;All Blogs from https://dataconomy.com/category/{category_sub_URL}/ Registered!\n&quot;)<br>                break</pre><p><strong>Call the Function to Scrape Blogs.</strong></p><pre># Call the function to scrape blogs<br>scrape_blogs(driver, category_sub_URLs, blogs_URL, blogs_title, blogs_title_set)</pre><p><strong>Function to Save Blog Information to a Text File.</strong></p><pre># Function to save blog information to a text file<br>def save_to_text_file(title, link, author_name, author_URL, date, text, summary, folder_name):<br>    <br>    # Remove invalid characters from the title to create a valid filename for the text file<br>    filename = os.path.join(folder_name, re.sub(r&#39;[\/:*?&quot;&lt;&gt;|]&#39;, &#39;&#39;, title) + &#39;.txt&#39;)<br><br>    # Create the directory if it doesn&#39;t exist<br>    os.makedirs(folder_name, exist_ok=True)<br><br>    # Open the file in write mode<br>    with open(filename, &#39;w&#39;, encoding=&#39;utf-8&#39;) as file:<br>        <br>        # Write the information to the file<br>        file.write(f&#39;Title: {title}\n\n&#39;)<br>        file.write(f&#39;Article Link: {link}\n\n&#39;)<br>        file.write(f&#39;Author: {author_name}\n\n&#39;)<br>        file.write(f&#39;Publish Date: {date}\n\n&#39;)<br>        file.write(f&#39;Article:\n{text}\n\n&#39;)<br>        file.write(f&#39;Summary: {summary}\n\n&#39;)<br>        file.write(f&#39;Other Blogs by {author_name}: {author_URL}\n&#39;)<br><br>    print(f&#39;Information saved to {filename}&#39;)</pre><p><strong>Iterate Through Blogs and Save Information.</strong></p><ul><li>Iterate through the scraped blogs and save information to text files.</li><li>Make a request to each blog’s URL using Requests and extract information using BeautifulSoup and newspaper3k.</li></ul><pre># Iterate through the blogs and save information to text files<br>for URL_category, url_list in blogs_URL.items():<br>    <br>    for url in url_list:<br>        # Add a delay to avoid overloading the server with requests<br>        time.sleep(5)<br><br>        # Make a request to the URL<br>        response = requests.get(url)<br>        html = response.text<br><br>        # Use BeautifulSoup to parse the HTML<br>        soup = BeautifulSoup(html, &#39;html.parser&#39;)<br><br>        # Find author information<br>        author = soup.find(&#39;div&#39;, class_=&#39;jeg_meta_author&#39;).find(&#39;a&#39;)<br><br>        # Create an Article object<br>        article = Article(url)<br>        article.set_html(html)<br>        article.parse()<br>        article.nlp()<br><br>        # Extract information from the article<br>        title = article.title<br><br>        filename = os.path.join(URL_category, re.sub(r&#39;[\/:*?&quot;&lt;&gt;|]&#39;, &#39;&#39;, title) + &#39;.txt&#39;)<br>        # Check if the file already exists<br>        if os.path.exists(filename):<br>            print(f&#39;File {filename} already exists. Skipping...&#39;)<br>            continue<br>        <br>        # Extract information from the article<br>        link = article.url<br>        author_name = author.text<br>        author_URL = author.get(&#39;href&#39;)<br>        date = article.publish_date.date()<br>        text = article.text<br>        summary = article.summary<br><br>        # Save information to a text file in the respective folder<br>        save_to_text_file(title, link, author_name, author_URL, date, text, summary, URL_category)</pre><h4>Here’s the whole code</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf62e17d4080cd3a30d53ab9b2f27701/href">https://medium.com/media/cf62e17d4080cd3a30d53ab9b2f27701/href</a></iframe><h4>Output</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sSfJeDTlTKtN65w1T6xFBA.png" /><figcaption><strong>Folders Belonging To Respective Categories</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LscFGN49c1NkYgvvNTw1gw.png" /><figcaption><strong>Category:</strong> <strong>Artificial Intelligence</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWSHjpeyLTO6WbwareQu6g.png" /><figcaption><strong>Article-Related Data</strong></figcaption></figure><ul><li>The information pertaining to all other blogs is likewise extracted for each blog.</li><li>Subsequently, folders are generated for individual categories, each containing blogs that fall under that specific category..</li></ul><h3>Summary</h3><p>In this script, we’ve utilized Selenium for navigating through web pages, scraping blog information from different categories on ‘<a href="https://dataconomy.com/">Dataconomy</a>.’</p><p>The script extracts blog titles, URLs, and other relevant details and organizes the information into text files for each category. This comprehensive approach involves dynamic web page interaction, HTML parsing, and article content extraction.</p><h3>Conclusion</h3><p>Web scraping with Selenium and newspaper3k opens up a world of possibilities for data extraction and analysis. By understanding the workflow and the roles of these libraries, developers can harness their power to gather valuable insights from online content. <strong>It’s crucial to approach web scraping responsibly, respecting the terms of service of the websites involved.</strong></p><h3>References</h3><ol><li><strong>Selenium Documentation: </strong><a href="https://selenium-python.readthedocs.io/">https://selenium-python.readthedocs.io/</a></li><li><strong>newspaper3k Documentation: </strong><a href="https://newspaper.readthedocs.io/en/latest/">https://newspaper.readthedocs.io/en/latest/</a></li><li><strong>Requests Documentation: </strong><a href="https://docs.python-requests.org/en/latest/">https://docs.python-requests.org/en/latest/</a></li><li><strong>BeautifulSoup Documentation: </strong><a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/">https://www.crummy.com/software/BeautifulSoup/bs4/doc/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d6219540ec0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unveiling Cinema: Movie Data Extraction using BeautifulSoup]]></title>
            <link>https://medium.com/@tavishi.1402/unveiling-cinema-interactive-movie-data-extraction-using-beautifulsoup-72434870dabd?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/72434870dabd</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[web-scraping]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Wed, 08 Nov 2023 18:42:02 GMT</pubDate>
            <atom:updated>2023-11-08T18:55:53.866Z</atom:updated>
            <content:encoded><![CDATA[<p>In the vast landscape of the internet, data is omnipresent, waiting to be discovered and utilized. <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/">BeautifulSoup</a>, a Python library, is a powerful tool that facilitates the extraction of data from HTML and XML documents. In this article, we will embark on a journey to explore the capabilities of BeautifulSoup by extracting valuable information from a webpage.</p><p>Our mission? To unveil the world of movies, specifically the “100 FRESH MOVIES TO WATCH ONLINE FOR FREE” curated by <a href="https://editorial.rottentomatoes.com/article/fresh-movies-you-can-watch-for-free-online-right-now/">Rotten Tomatoes</a>, a renowned American review-aggregation website for films and television shows.</p><h3>Understanding BeautifulSoup</h3><p>BeautifulSoup, a Python library, acts as a powerful tool in the realm of web scraping and data extraction. Its primary purpose is to parse HTML and XML documents, transforming the raw, unstructured data of web pages into a format that can be navigated, searched, and manipulated using Python code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FLhVyT3SuXeMCy06r3jSA.jpeg" /></figure><p>At its core, BeautifulSoup simplifies the process of extracting specific information from web pages. Here’s how it achieves this:</p><ol><li><strong>HTML Parsing:</strong> BeautifulSoup parses the HTML content of a webpage, breaking it down into a nested structure of tags, attributes, and text. This structured representation makes it easy for developers to access and extract specific elements from the HTML.</li><li><strong>Navigation and Search:</strong> Once the HTML is parsed, BeautifulSoup provides a range of methods and properties that allow developers to navigate the document effortlessly. Whether it’s finding a specific tag, searching for elements with specific attributes, or navigating the document tree, BeautifulSoup simplifies the process through intuitive functions.</li><li><strong>Data Extraction: </strong>BeautifulSoup allows developers to extract data from specific HTML elements based on their tags, classes, attributes, or text content. This capability is invaluable when scraping information from websites, as it enables targeted extraction of the desired data points.</li></ol><h3>Exploring Rotten Tomatoes’ Movie Selection</h3><p><a href="https://editorial.rottentomatoes.com/article/fresh-movies-you-can-watch-for-free-online-right-now/">Rotten Tomatoes</a> contains a curated list of “FRESH MOVIES,” and we aim to extract essential information about each film, such as its Title, Release Year, Tomatometer Score, Critics Consensus, Streaming URL, and the Rotten Tomatoes URL for further exploration.</p><h3>Project Workflow: A Step-by-Step Exploration</h3><ol><li><strong>Importing Essential Modules:</strong> We kick-start our adventure by importing the necessary modules, including BeautifulSoup for parsing HTML, Requests for making HTTP requests, OS for handling file operations, and Pandas for data manipulation.</li><li><strong>Fetching the Webpage:</strong> Armed with the URL, we make an HTTP request to the webpage using the Requests module. We ensure the successful loading of the page by checking its status code (200) and handling potential failures gracefully.</li><li><strong>Parsing HTML with BeautifulSoup:</strong> The raw HTML content of the page is parsed using BeautifulSoup, transforming it into a navigable and structured format. This step is pivotal, as it prepares the data for extraction.</li><li><strong>Extracting Movie Information:</strong> We define several functions, each dedicated to extracting specific details about the movies. From movie titles to streaming URLs, we meticulously navigate the HTML structure using BeautifulSoup, capturing the desired information.</li><li><strong>Storing Data and Creating a CSV File:</strong> The extracted movie data is organized into a dictionary, and subsequently, a folder is created to store the data as a CSV file. This ensures that the valuable information we’ve extracted is preserved and easily accessible for further analysis.</li></ol><h3>Let’s Explore the Extraction Process in Depth!</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxT9C25UNTwfZuk85WP%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcHlxZmk0aHM1djhrNTYyMW0ydW9teWIwdzBoNDRhZGRkNWZvMms1dSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FxT9C25UNTwfZuk85WP%2Fgiphy-downsized-large.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FxT9C25UNTwfZuk85WP%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="310" frameborder="0" scrolling="no"><a href="https://medium.com/media/7939906abc0c0e3c6f5b379a7905be27/href">https://medium.com/media/7939906abc0c0e3c6f5b379a7905be27/href</a></iframe><ul><li>Import the necessary modules.</li></ul><pre>from bs4 import BeautifulSoup<br>import os<br>import requests<br>import pandas as pd</pre><ul><li>Retrieve content from the specified URL.</li></ul><pre>url = &quot;https://editorial.rottentomatoes.com/article/fresh-movies-you-can-watch-for-free-online-right-now/&quot;<br>response = requests.get(url)</pre><ul><li>Verify the success of the request.</li></ul><pre>if response.status_code != 200:<br>    raise Exception(f&quot;Failed to load page {url}&quot;)<br>else:<br>    print(response.status_code)</pre><ul><li>Parse the HTML content of the page using BeautifulSoup.</li></ul><pre>soup = BeautifulSoup(response.text, &#39;html.parser&#39;)</pre><ul><li>Find all tags on the page containing information about movies.</li></ul><ol><li>All the information we want is inside a “div” element with the class attribute “apple-news-media-block clearfix”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44h9yL3zYPl9f2VQfGzmMg.png" /><figcaption>movie_tags = soup.find_all(“div”, class_ = “apple-news-media-block clearfix”)</figcaption></figure><pre>movie_tags = soup.find_all(&quot;div&quot;, class_ = &quot;apple-news-media-block clearfix&quot;)</pre><ul><li>Extract Rotten Tomatoes URL for each movie.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15Rd4r-fGuBBHjyIlTjfYQ.png" /><figcaption>movie_tag.find(“p”, class_ = “title”).find(“a”).get(“href”)</figcaption></figure><pre>def get_rotten_tomatoes_url(https://medium.com/movie_tags):<br>    <br>    movie_rotten_tomatoes_url_list = []<br>    <br>    for movie_tag in movie_tags:<br>        movie_rotten_tomatoes_url_list.append(movie_tag.find(&quot;p&quot;, class_ = &quot;title&quot;).find(&quot;a&quot;).get(&quot;href&quot;))<br>    <br>    return movie_rotten_tomatoes_url_list</pre><ul><li>Extract movie titles.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15Rd4r-fGuBBHjyIlTjfYQ.png" /><figcaption>movie_tag.find(“p”, class_ = “title”).find(“a”).text.strip()</figcaption></figure><pre>def get_titles(movie_tags):<br>    <br>    movie_titles_list = []<br>    <br>    for movie_tag in movie_tags:<br>        movie_titles_list.append(movie_tag.find(&quot;p&quot;, class_ = &quot;title&quot;).find(&quot;a&quot;).text.strip())<br>    <br>    return movie_titles_list</pre><ul><li>Extract movie release years.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C9dm8PkENoTLE6qaHwepZw.png" /><figcaption>movie_tag.find(“p”, class_ = “title”).find(“span”, class_ = “year”).text[1:-1].strip()</figcaption></figure><pre>def get_year(movie_tags):<br>    <br>    movie_year_list = []<br>    <br>    for movie_tag in movie_tags:<br>        movie_year_list.append(movie_tag.find(&quot;p&quot;, class_ = &quot;title&quot;).find(&quot;span&quot;, class_ = &quot;year&quot;).text[1:-1].strip())<br>    <br>    return movie_year_list</pre><ul><li>Extract Tomatometer scores.</li></ul><ol><li>The Tomatometer score — based on the opinions of hundreds of film and television critics — is a trusted measurement of critical recommendation for millions of fans.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1vlrxdtnz7d8pzWfl9JMg.png" /><figcaption>movie_tag.find(“p”, class_ = “score”).text.strip()</figcaption></figure><pre>def get_tomatometer_score(movie_tags):<br>       <br>    movie_tomatometer_scores_list = []<br>    <br>    for movie_tag in movie_tags:<br>        movie_tomatometer_scores_list.append(movie_tag.find(&quot;p&quot;, class_ = &quot;score&quot;).text.strip())<br>    <br>    return movie_tomatometer_scores_list</pre><ul><li>Extract Critics Consensus for each movie.</li></ul><ol><li>The Critics Consensus is a concise summary of what top critics think about a movie or TV show.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*85Y6DFBMrX8Vx83cvSrL3w.png" /><figcaption>movie_tag.find(“div”, class_=”details”).select(‘div &gt; p’)[0].text[19:].strip()</figcaption></figure><pre>def get_critics_consensus(movie_tags):<br>    <br>    movie_critics_consensus_list = []<br>    <br>    for movie_tag in movie_tags:<br>        movie_critics_consensus_list.append(movie_tag.find(&quot;div&quot;, class_=&quot;details&quot;).select(&#39;div &gt; p&#39;)[0].text[19:].strip())<br>    <br>    return movie_critics_consensus_list</pre><ul><li>Extract Streaming URLs for each movie.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBrBP-DkMu853cKqV1fOEA.png" /><figcaption>movie_tag.find(“div”, class_=”details”).select(‘div &gt; p’)[1].find(“a”).get(“href”)</figcaption></figure><pre>def get_streaming_url(https://medium.com/movie_tags):<br>    <br>    movie_streaming_url_list = []<br>    <br>    for movie_tag in movie_tags:<br>        try:<br>            movie_streaming_url_list.append(movie_tag.find(&quot;div&quot;, class_=&quot;details&quot;).select(&#39;div &gt; p&#39;)[1].find(&quot;a&quot;).get(&quot;href&quot;))<br>        except AttributeError:<br>            movie_streaming_url_list.append(&quot;No URL available - &quot; + movie_tag.find(&quot;div&quot;, class_=&quot;details&quot;).select(&#39;div &gt; p&#39;)[1].text[17:].strip())<br>    <br>    return movie_streaming_url_list</pre><ul><li>Save the scraped data as a CSV file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SLWgnqr0p4n6v82H_zECqw.png" /><figcaption>Movies_Data.csv</figcaption></figure><pre># Store the scraped data in a dictionary<br>movies_data = {<br>    &#39;Rotten Tomatoes URL&#39;: get_rotten_tomatoes_url(https://medium.com/movie_tags),<br>    &#39;Title&#39;: get_titles(movie_tags),<br>    &#39;Year&#39;: get_year(movie_tags),<br>    &#39;Tomatometer Score&#39;: get_tomatometer_score(movie_tags),<br>    &#39;Critics Consensus&#39;: get_critics_consensus(movie_tags),<br>    &#39;Streaming URL&#39;: get_streaming_url(https://medium.com/movie_tags)<br>}<br><br># Create a folder to store the scraped data as a CSV file<br>folder_path = &#39;Movies Data/&#39;<br>os.makedirs(folder_path, exist_ok=True)<br><br># Save the scraped data as a CSV file<br>pd.DataFrame(movies_data).to_csv(os.path.join(folder_path, f&quot;Movies_Data.csv&quot;), index=None)<br><br># Print the scraped data as a DataFrame<br>pd.DataFrame(movies_data)</pre><h4>Here’s the whole code!</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea85fb8375437384b48019efe807f7b0/href">https://medium.com/media/ea85fb8375437384b48019efe807f7b0/href</a></iframe><h3>Summary</h3><p>In this exhilarating journey, we harnessed the power of BeautifulSoup to extract intricate details about movies from a webpage curated by Rotten Tomatoes. The step-by-step exploration led us through the realms of web scraping, demonstrating the elegance and simplicity offered by this Python library. Armed with our newfound knowledge, we can delve deeper into the world of data analysis, making informed decisions, and uncovering hidden insights within the movie industry.</p><h3>References</h3><ol><li><a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/">https://www.crummy.com/software/BeautifulSoup/bs4/doc/</a></li><li><a href="https://requests.readthedocs.io/en/latest/">https://requests.readthedocs.io/en/latest/</a></li><li><a href="https://www.rottentomatoes.com/">https://www.rottentomatoes.com/</a></li><li><a href="https://pandas.pydata.org/docs/">https://pandas.pydata.org/docs/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72434870dabd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part-2 Evaluation Metrics for Classification Problems in Machine Learning]]></title>
            <link>https://medium.com/@tavishi.1402/part-2-evaluation-metrics-for-classification-problem-in-ml-86217c08ded?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/86217c08ded</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 17:42:41 GMT</pubDate>
            <atom:updated>2023-06-12T13:24:34.524Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h4>A Comprehensive Guide to Evaluating Model Accuracy and Effectiveness of Machine Learning Classification Model</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*8BOo72WZltCif3RzoQWSzg.png" /></figure><p>Machine Learning encompasses two main problem types: regression and classification. Regression models are suitable for scenarios where the dependent variable is continuous, while classification techniques are utilized when the dependent variable is categorical.</p><p>For Regression Models please read the below article</p><p><a href="https://blog.jovian.com/part-1-performance-metrics-in-machine-learning-27cd9264e398">Part-1 Performance Metrics in Machine Learning</a></p><p>There are many ways for measuring classification performance. we’ll discuss these metrics in detail:</p><ul><li>Accuracy</li><li>Confusion Matrix (not a metric but fundamental to others)</li><li>Classification report(Precision and Recall,F1-score)</li><li>AUC-ROC</li></ul><p>Precision-recall is a widely used metrics for classification problems.</p><h4>What is confusion matrix</h4><p>Before diving into the topic, let’s clarify some fundamental terms that are important to understand:</p><p><em>Confusion matrices</em>, are a set of metrics used to evaluate the performance of a classification model. They provide information about how well the model is able to predict the different classes in the dataset. The metrics include true positives, true negatives, false positives, and false negatives, which help in understanding the accuracy, precision, recall, and F1-score of the model’s predictions.</p><p>In simple words, confusion metrics provide a way to measure how well a classification model is performing and identify any potential errors or misclassifications.</p><p><strong>Confusion Matrix is</strong> i<strong>s a table with 4 different combinations of predicted and actual values.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*IyduZffQhW7draow" /></figure><p>It is very helpful for determining Recall, Precision, Specificity, Accuracy, and, most significantly, AUC-ROC curves.</p><h4><strong>Elements of Confusion metrics:</strong></h4><p><strong>True Positive:</strong></p><p>Interpretation: You predicted positive and it’s true(Actually its positive).</p><p>You predicted that a woman is pregnant and she actually is.</p><p><strong>True Negative:</strong></p><p>Interpretation: predicted negative and it’s true(Actually its positive).</p><p>A fat man is not predicted pregnant and he actually is not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*sQHsBYtSWJ5GsBwOOEbHzA.png" /></figure><p><strong>False Positive: (Type 1 Error)</strong></p><p>Interpretation: You predicted positive and it’s false(Actually its negative) .</p><p>A Fat man is predicted pregnant but he actually is not.</p><p><strong>False Negative: (Type 2 Error)</strong></p><p>Interpretation: You predicted negative and it’s false(Actually its negative) .</p><p>A woman is predicted as not pregnant but she actually is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*apQ-e98fyDL3ZVjROKuwuw.png" /></figure><h4>Accuracy</h4><p>The total number of correct predictions/all the predictions.</p><p>The accuracy value<strong> ranges from 0 to 1,</strong> with<strong> 1 indicating perfect accuracy</strong> and 0 indicating no correct predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*XAGfP8yNlTwtNzKM8ovj0A.png" /></figure><h4>Precision</h4><p>actually positive predicted<strong>/</strong>total<strong> positively predicted</strong> outcomes.</p><p>The precision value <strong>ranges from 0 to 1,</strong> with <strong>1 indicating perfect precision</strong> (all positive predictions are correct) and 0 indicating no correct positive predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/1*-3qu0hiWac-xdDn8I5vCMQ.png" /></figure><h4>Recall/Senstivity/Hit rate</h4><p>correctly positive predicted <strong>/</strong>total number o<strong>f Actual positive</strong> outcomes.</p><p>The recall value<strong> ranges from 0 to 1,</strong> with<strong> 1 indicating perfect recall (the</strong> model correctly identifies all positive instances) and 0 indicating no correctly identified positive instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*4UA0_SmXV7O6YN1Vk67BXA.png" /></figure><h4><strong>F1 Score</strong></h4><p>The F1 score is defined as <strong>the harmonic mean of precision and recall. </strong>It combines the precision and recall of a model into a single score. It is maximum when Precision is equal to Recall.</p><p>The F1 score ranges from 0 to 1, where a score of 1 represents perfect precision and recall, while a score of 0 indicates the worst performance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*s-g3Nv2O6qvIjOnS9HVgww.png" /></figure><p>🎯 Key Points to Remember:</p><p>1️⃣ <em>The F1 score is useful when you want to consider both precision and recall simultaneously, especially when the classes are imbalanced, and you want to find a balance between correctly predicting positive instances (precision) and capturing all positive instances (recall).</em></p><h4>AUC- ROC (Area Under the Receiver Operating Characteristic Curve)</h4><p>ROC (Receiver Operating Characteristic) is a graphical representation of the performance of a binary classification model. <strong>It plots the true positive rate (TPR) against the false positive rate (FPR) at different classification thresholds.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*SHAcKlImRZSDK8_lV7zvhw.png" /></figure><p><em>A high AUC score indicates that the model has good discrimination ability, i.e., it can effectively differentiate between positive and negative instances at different classification thresholds. Conversely, a lower AUC-ROC score suggests that the model struggles to differentiate between the two classes.</em></p><p><strong>AUC ranges from 0 to 1, with 0.5 indicating random guessing and 1 indicating a perfect classifier.</strong></p><p>🎯 Key Points to Remember:</p><p>1️⃣<em>AUC is especially useful in</em><strong><em> imbalanced</em></strong><em> datasets where accuracy can be misleading.</em></p><p>Happy Readings!!!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86217c08ded" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part-1 Evaluation metrics for Regression problems in Machine Learning]]></title>
            <link>https://medium.com/@tavishi.1402/part-1-performance-metrics-in-machine-learning-27cd9264e398?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/27cd9264e398</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[math]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 17:08:11 GMT</pubDate>
            <atom:updated>2023-06-11T18:36:57.909Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h4>A Comprehensive Guide to Evaluating Model Accuracy and Effectiveness of Machine Learning REGRESSION Model</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiXlYbe9Ace7d2VPdbn_xg.jpeg" /></figure><h4>What is performance Metrics? why do we need Performance Metrics</h4><p><em>Performance metrics play a crucial role in model evaluation, model selection, and comparing different algorithms or approaches</em><strong>.</strong> After we have trained our model and have predicted the outcomes, we need to evaluate the model’s performance.</p><p>These metrics provide a way to assess how well a model is performing on a given task, such as classification or regression. They help to understand the strengths and weaknesses of a model and guide improvements in its performance.</p><p>Every machine learning task can be broken down to either <strong><em>Regression</em> or <em>Classification </em></strong>Different performance metrics are used based on the specific task at hand. There are dozens of metrics for both problems, but we’re gonna discuss popular ones.</p><h3>Regression metrics</h3><p>Regression models have continuous output. So, we need a metric based on calculating some sort of distance between <em>predicted</em> and <strong><em>actual(truth) </em></strong>value</p><p>In order to evaluate Regression models, we’ll discuss these metrics in detail:</p><ul><li>Mean Absolute Error (MAE),</li><li>Mean Squared Error (MSE),</li><li>Root Mean Squared Error (RMSE),</li><li>R² (R-Squared).</li><li>Adjusted R²</li></ul><p>Before dive into the Detail explanation lets understand what is actual value and predicted value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*l_itxAQUsSebMvBB8PFRzA.jpeg" /></figure><p><strong>The actual value</strong> : refers to the true or known value of the target variable</p><p><strong>The predicted value : </strong>is the value estimated or generated by a machine learning model.</p><h4><strong>Mean Squared Error (MSE)</strong></h4><ul><li>Mean Squared Error (MSE) is a popular performance metric in machine learning that measures the average <strong>squared</strong> difference between predicted and actual values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XAwyCsSnr2E1Ysot.png" /></figure><p><strong>Few Important points Related to MSE</strong></p><ul><li>It’s differentiable, so it can be optimized better.</li><li>Calculates the average squared difference between predicted and actual values.</li><li>Emphasizes larger errors due to the squaring operation.</li><li>Useful when larger errors need to be penalized more heavily.</li><li>Sensitive to outliers and can be influenced by extreme values.</li></ul><h4>Mean Absolute Error</h4><p>MAE (Mean Absolute Error) is a performance metric in machine learning that calculates the average<strong> absolute</strong> difference between predicted and actual values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*FZ7g5m1DCnFjSwVx.png" /></figure><p><strong>Few Important points Related to MAE</strong></p><ul><li>Gives equal weight to all errors regardless of their magnitude.</li><li>Less sensitive to outliers compared to MSE.</li><li>Provides a more robust measure of prediction accuracy.</li><li>Easier to interpret since it is in the same unit as the target variable.</li><li>It is useful if the training data has outliers as MAE does not penalize high errors caused by outliers.</li><li>MAE is non-differentiable as opposed to MSE, which is differentiable.</li><li>It can be challenging to compute gradients in MAE.</li></ul><h4>Root Mean Squared Error (RMSE):</h4><p>Root Mean Squared Error is the<strong> square root</strong> of the average of the squared difference between predicted and actual values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/0*9qMD6h_0j4lhicm7.png" /></figure><p><strong>Few Important points Related to RMSE</strong></p><ul><li>It retains the differentiable property of MSE.</li><li><em>Similar to MSE but with the added advantage of being in the same unit as the target variable.</em></li><li>It <em>handles the larger errors</em> due to the square root operation done by MSE by square rooting it.</li><li>RMSE <em>does not penalize the errors</em> as much as MSE does due to the square root.</li><li>Provides a <em>more intuitive</em> and interpretable measure of prediction accuracy <em>compared to MSE.</em></li><li>Preserves the same unit as the target variable, making it easier to compare and understand the magnitude of the errors.</li><li>MSE values are expressed in quadratic equations. Hence when we plot it, we get a gradient descent with only one global minima.</li></ul><p><strong>NOTE-</strong> The choice between MSE, MAE, and RMSE depends on the specific problem, the nature of the data, and the desired trade-off between sensitivity to outliers, interpretability, and the magnitude of errors. Each metric has its own advantages and can be useful in different scenarios.</p><h3>R² -Coefficient of determination)</h3><p>The R² score, also known as the coefficient of determination or<em> goodness of fit</em>, is a metric in machine learning that measures how well a regression model fits the data</p><p><strong>A higher R² score indicates a better fit</strong>, and it <strong>allows us to compare the model’s performance against a baseline model that uses the mean value of the target variable</strong>.</p><ul><li><em>If the </em>R²<em> score is zero</em>, it means that the regression line is equivalent to the mean line. In this case, both lines overlap, indicating that the model’s performance is poor and it fails to capture any meaningful relationship in the data.</li><li>If the R² score is one, it implies that the regression line perfectly fits the data without any errors. However, achieving a perfect R² score is highly unlikely in real-world scenarios.</li><li>In general cases, the R² score falls between zero and one, such as 0.8. This indicates that the model can explain 80 percent of the variance in the data. As the R² score approaches one, the regression line gets closer to perfection, indicating an improvement in model performance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*Zji4-c16BwspKmTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*62-pc-eMOwCfYqP-.png" /></figure><p><strong>Few Important points Related to </strong>R²</p><ul><li>R²is a measure of how well a regression model fits the data and explains the variability in the dependent variable.</li><li><strong>It ranges between 0 and 1</strong>, with 0 indicating no variability explained and <strong><em>1 indicating a perfect fit.</em></strong></li><li>R² can be used to compare different models, with higher values indicating better performance.</li><li>However, R²should be interpreted with caution as it doesn’t provide information on statistical significance or causality.</li></ul><h4>Adjusted R²</h4><p>One <strong>disadvantage of the R2 <em>score</em></strong> is that <strong>when adding new features to the dataset, the score may either increase or remain constant</strong>, but it never decreases. This is because the R² score assumes that adding more data will always increase the variance of the data.</p><p>However, a problem arises when an irrelevant feature is added to the dataset, as the R² score may mistakenly increase, indicating an improvement in the model’s performance, even though it is incorrect.</p><p>Hence, To control this situation Adjusted R Squared came into existence. Adjusted R² is always lower than R², as it adjusts for the increasing predictors and only shows improvement if there is a real improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*f4Uw5uq0gw4MbHeM.png" /></figure><p>Now as <strong>P</strong> increases by adding some features so the denominator will decrease, n-1 will remain constant. R2 score will remain constant or will increase slightly so the complete answer will increase and when we subtract this from one then the resultant score will decrease. so this is the case when we add an irrelevant feature in the dataset.</p><p>And if we add a relevant feature then the R2 score will increase and 1-R2 will decrease heavily and the denominator will also decrease so the complete term decreases, and on subtracting from one the score increases.</p><p><strong>Few Important points Related to </strong>R²</p><ul><li>Adjusted R² is a modified version of the R² (R-squared) score that adjusts for the number of features in a regression model.</li><li>Unlike R², which tends to increase as more features are added, Adjusted R² penalizes the inclusion of unnecessary features that do not contribute significantly to the model’s predictive power.</li><li>Adjusted R² provides a more reliable measure of model performance by accounting for the trade-off between model complexity and goodness of fit.</li><li>It is particularly useful when comparing regression models with different numbers of features, as it helps identify the model that strikes the right balance between simplicity and predictive power.</li><li><strong>The Adjusted R² score ranges from negative infinity to 1</strong>, with a higher score indicating a better fit and a greater proportion of variance explained by the independent variables.</li><li><strong>Negative values of Adjusted R² may occur when the model performs worse than a simple average o</strong>r when the number of features is excessively large compared to the sample size.</li></ul><p><a href="https://medium.com/@tavishi.1402">Click here for more Data Science Content</a></p><p>Happy Learnings!!!</p><p><strong>References</strong></p><p><a href="https://www.analyticsvidhya.com/blog/2021/05/know-the-best-evaluation-metrics-for-your-regression-model/">https://www.analyticsvidhya.com/blog/2021/05/know-the-best-evaluation-metrics-for-your-regression-model/</a></p><p><a href="https://www.youtube.com/watch?v=vsooKEWCb4g">https://www.youtube.com/watch?v=vsooKEWCb4g</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27cd9264e398" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regularization Techniques: Ridge, Lasso and Elastic Net]]></title>
            <link>https://medium.com/@tavishi.1402/regularization-techniques-lasso-and-ridge-90d3cc73ca4c?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/90d3cc73ca4c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 08:43:45 GMT</pubDate>
            <atom:updated>2023-06-03T15:43:55.397Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h4>Overfitting Saviors in ML</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SMxvHYCOfS5jonLI.png" /></figure><h4>Overview of Overfitting:</h4><p>Regularization is a technique used in machine learning to prevent overfitting and improve the generalization ability of models. <strong>It involves adding a penalty term to the loss function during the training process, which helps control the complexity of the model.</strong> By adding this penalty, regularization discourages the model from fitting noise and random fluctuations in the training data.</p><p>The goal of regularization is to find the right balance between fitting the training data well and avoiding overfitting. It encourages the model to capture the underlying patterns in the data while avoiding excessive complexity.</p><h4>Regularization Techniques:</h4><p>1- L1 regularization (Lasso)</p><p>2- L2 regularization (Ridge).</p><p>3- Elatic Net</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g0XdF6-9PLJWhxGK.png" /></figure><p>Ridge, Lasso, and Elastic Net are three popular regularization techniques used in machine learning to address overfitting and improve the performance of models. Here’s a brief explanation of each technique:</p><h4><strong>1- Ridge Regularization:</strong></h4><ul><li>Ridge regularization, also known as L2 regularization, <strong>adds the sum of squared coefficients to the loss function as penalty.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*LmfCdC-ZVAj3YhjM.png" /></figure><ul><li>This penalty term <strong>encourages the model to have smaller and more balanced weights.</strong></li><li>Ridge regularization is<strong> effective when dealing with multicollinearity<em>(</em></strong>statistical concept where several independent variables in a model are correlated<em>)</em>, where features are highly correlated.</li></ul><h4><strong>2- Lasso Regularization:</strong></h4><ul><li>Lasso regularization, also known as L1 regularization, <strong>adds the sum of absolute values of coefficients to the loss function.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/0*VJYsitaygqLPPn-3.png" /></figure><ul><li><strong>Lasso encourages sparsity</strong> by bringing some coefficients to exactly zero.</li><li><strong>It also performs feature selection</strong>, effectively <strong>selecting the most important features and disregarding irrelevant ones.</strong></li><li>Lasso is particularly useful when dealing with <strong>high-dimensional</strong> datasets.</li></ul><h4><strong>3- Elastic Net Regularization (L1+L2):</strong></h4><ul><li>Elastic Net regularization combines the properties of both Ridge and Lasso regularization</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*x7yyrzBgNgpU_Iw0Z-yDoA.jpeg" /></figure><ul><li><strong>It adds a combination of the L1 and L2 penalties to the loss function.</strong></li><li><strong>Elastic Net is beneficial when dealing with datasets that have a large number of features and multicollinearity issues.<em> </em></strong>It provides a balance between feature selection (Lasso) and handling correlated features (Ridge).</li></ul><h4>Conclusion :</h4><p>These regularization techniques help control the complexity of models, prevent overfitting, and improve generalization performance.<strong> The choice between Ridge, Lasso, or Elastic Net depends on the specific characteristics of the dataset and the goals of the model.</strong></p><p>By applying regularization techniques, models become more robust, better generalize to new data, and can provide more reliable predictions.</p><p>Happy Learning!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90d3cc73ca4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Overfitting in Machine Learning]]></title>
            <link>https://medium.com/@tavishi.1402/overfitting-in-machine-learning-f5aa8530ae39?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5aa8530ae39</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Thu, 01 Jun 2023 19:40:10 GMT</pubDate>
            <atom:updated>2023-06-02T08:49:00.357Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h4>Strategies for Accurate and Reliable Models</h4><p>In the exciting world of machine learning, building accurate and robust models is a primary objective, However, there’s a hurdle that often arises — overfitting which is a common problem that can lead to inaccurate predictions, But what exactly is overfitting, and why is it a concern???</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oAAu0HpPduTYEaMe" /></figure><h3>What is Overfitting ???</h3><p>Overfitting is a common problem in machine learning that occurs when a model learns the training data too well, to the point where it becomes overly specialized and fails to generalize to new, unseen data accurately. In simple terms, overfitting can be thought of as “memorizing” the training data rather than “learning” from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/0*nu3PP0283rNgtHqg.png" /></figure><p>Imagine you’re studying for a math test, and you have a set of practice questions with answers. If you memorize those specific questions and answers without understanding the principles and concepts, you may struggle to solve new, unfamiliar problems on the actual test. That’s similar to what happens with overfitting in machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jjddcZBPT5ROvtwN.jpg" /></figure><p>In machine learning, the goal is to build a model that can make accurate predictions based on patterns it learns from the training data. However, if the model becomes too complex or tries too hard to fit the training data perfectly, it may end up “memorizing” the noise and randomness present in the data instead of learning the underlying patterns.</p><p>As a result, when the model encounters new data that it hasn’t seen before, it may struggle to make accurate predictions because it’s too focused on the specific examples it memorized during training. It fails to generalize well and perform effectively on unseen data.</p><p><strong>Understanding the function of variance and bias in overfitting is crucial for gaining additional insights into the phenomenon:</strong></p><h4><strong>Variance:</strong></h4><p>Variance represents the variability or sensitivity of a model’s predictions to different training data. <strong>High variance models are overly complex and tend to overfit the training data,</strong> leading to poor generalization.</p><h4>Bias:</h4><p>Bias refers to the difference between the average prediction and the target value(<strong>error</strong> ), introduced by making simplifying assumptions in a model. <strong>High bias models are too simplistic and tend to underfit the data</strong>, failing to capture the true underlying patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*wHRlyj0tmgWWlKhFZZJeAQ.jpeg" /></figure><p><strong>The goal is to strike a balance that minimizes both bias and variance is crucial to build a model </strong>, <strong>that accurately</strong> captures the patterns in the data while generalizing well to new examples.</p><p><strong>Low bias and low variance will give a balanced model, whereas high bias leads to underfitting, and high variance lead to overfitting.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*jGhQzM0n2s2O5kTesI-Gcw.jpeg" /></figure><p><strong>Low Bias:</strong> The average prediction is very close to the target value</p><p><strong>High Bias:</strong> The predictions differ too much from the actual value</p><p><strong>Low Variance:</strong> The data points are compact and do not vary much from their mean value</p><p><strong>High Variance:</strong> Scattered data points with huge variations from the mean value and other data points.</p><h4>Overfitting can be caused by several factors:</h4><ol><li><strong>Model Complexity: </strong>If a model is too complex, it can fit the training data too closely, capturing noise and random fluctuations rather than the true underlying patterns.</li><li><strong>Insufficient Training Data:</strong> When the amount of training data is limited, the model may not have enough examples to learn from, leading to overfitting as it tries to make sense of the available data.</li><li><strong>Feature Overload: </strong>If the model is trained on a large number of features, including irrelevant or redundant ones, it can lead to overfitting as the model tries to find patterns in noise or unrelated features.</li><li><strong>Lack of Regularization:</strong> Without regularization techniques like ridge or lasso, which help control the model’s complexity, there is a higher chance of overfitting.</li></ol><p>The key to combating overfitting lies in finding the right balance between model complexity and generalization.</p><h4><strong>Effective Strategies to Tackle Overfitting in Machine Learning:</strong></h4><ol><li><strong>Increase Training Data</strong>: Collecting more data helps the model generalize better by capturing a wider range of patterns and reducing the impact of noise.</li><li><strong>Simplify the Model:</strong> Using a less complex model with fewer parameters can prevent it from becoming too specialized in fitting the training data. Simplicity often leads to better generalization.</li><li><strong>Split Data for Validation: </strong>Dividing the available data into training and validation sets helps assess the model’s performance on unseen examples. This validation process can indicate if the model is overfitting and guide adjustments.</li><li><strong>Cross-Validation:</strong> Splitting the available data into multiple subsets for training and validation can help assess the model’s performance on unseen data and detect overfitting.</li><li><strong>Regularization:</strong> Techniques like ridge and lasso regularization add a penalty term to the model’s objective function, discouraging overly complex models and reducing the chances of overfitting.</li><li><strong>Feature Selection: </strong>Choosing relevant features and removing redundant or noisy ones can help simplify the model and reduce overfitting.</li><li><strong>Early Stopping:</strong> Monitoring the model’s performance during training and stopping the training process when the performance on the validation set starts to deteriorate can prevent overfitting.</li></ol><h4>Conclusion</h4><p>Overfitting is a significant concern in machine learning, as it compromises the model’s ability to generalize and make accurate predictions on new data. By understanding the causes and employing appropriate strategies, machine learning practitioners can mitigate overfitting and build more robust and reliable models.</p><p>To Know about the Regularization Techniques please read <a href="https://medium.com/@tavishi.1402/regularization-techniques-lasso-and-ridge-90d3cc73ca4c">this blog</a></p><p><a href="https://medium.com/@tavishi.1402/regularization-techniques-lasso-and-ridge-90d3cc73ca4c">Regularization Techniques: Ridge, Lasso and Elastic Net</a></p><p><strong>Happy Learnings !!!!!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5aa8530ae39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polynomial Linear Regression in Simple Words]]></title>
            <link>https://medium.com/@tavishi.1402/polynomial-linear-regression-in-machine-learning-in-simple-words-b39ea30aadbc?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b39ea30aadbc</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[math]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Sun, 28 May 2023 19:06:10 GMT</pubDate>
            <atom:updated>2023-05-30T02:37:13.876Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h4>Unveiling the curved path in machine learning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*a8_NOkn3d7bI1flR.png" /></figure><p><strong>In linear regression, the relationship between </strong>the independent variable(s) and the dependent variable <strong>is considered to be linear</strong>. However, in some cases, the data may not follow a linear pattern, and a straight line may not adequately represent the relationship. <strong>This restriction is overcome by polynomial regression, which accepts curved or nonlinear relationships.</strong></p><h3>What is Polynomial Regression?</h3><p>Polynomial regression is a form of regression analysis that models the relationship between the independent variable(s) and the dependent variable as an nth degree polynomial function. In other words, it extends the concept of linear regression to capture nonlinear relationships between variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DJFUG5EZmO8KldGR.png" /></figure><h3>Math behind polynomial regression</h3><p>The general form of a polynomial regression equation is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*-owKKnt97C9pYqXMCp4tyQ.png" /></figure><p>x -the independent variable, β₀, β₁, β₂, …, βₙ are the coefficients of the polynomial equation.</p><p>By including higher-order terms (x², x³, etc.) in the equation, polynomial regression can capture more complex patterns in the data<strong>. The degree of the polynomial determines the flexibility of the model in fitting the data.</strong> <strong>For example, a quadratic (degree 2) polynomial regression can capture a parabolic relationship, while a cubic (degree 3) polynomial regression can capture an S-shaped curve as shown in the picture below.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/0*9ZM1H4Dje6IpMfoQ.png" /></figure><h3>Types of Polynomial Regression</h3><p>1. Linear — if degree as 1</p><p>2. Quadratic — if degree as 2</p><p>3. Cubic — if degree as 3 and goes on, on the basis of degree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*vla-cye06UtPtmXF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AEJZWvMS5gWgtDTc.png" /></figure><h4>Linear Regression Vs Polynomial Regression</h4><p>When dealing with non-linear relationships in a dataset, Polynomial Regression is often preferred over Linear Regression. Linear Regression assumes a linear relationship between the independent and dependent variables, which may not accurately capture the underlying pattern in the data. Polynomial Regression, on the other hand, allows for more flexibility by fitting a curve to the data.</p><p>To understand this concept, let’s consider an example using programming and visualization.</p><p>Suppose we have a dataset that exhibits a non-linear relationship between two variables, let’s say x and y. We can start by fitting a Linear Regression model to the data and observing the results. The Linear Regression model will attempt to fit a straight line to the data points, which may not capture the curvature present in the relationship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*DJFUG5EZmO8KldGR.png" /></figure><p>However, if we apply Polynomial Regression to the same dataset, we can fit a curve to better represent the underlying pattern. By including higher-order terms (e.g., x², x³) in the regression equation, the Polynomial Regression model can capture the non-linear behavior more effectively.</p><p>By programming and visualizing the results of both Linear Regression and Polynomial Regression, we can compare how well each model fits the data. This comparison will highlight the limitations of Linear Regression in capturing non-linear relationships and demonstrate the advantage of Polynomial Regression in such cases.</p><p>Ultimately, the decision to use Polynomial Regression over Linear Regression depends on the nature of the data and the relationship between the variables. When there are indications of non-linear patterns, and a curve is better suited to represent the data, Polynomial Regression can provide more accurate predictions and insights.</p><h4>I<strong>mplementing Polynomial Regression in Python:</strong></h4><p>To demonstrate polynomial regression, we will utilize the scikit-learn library in Python. Let’s dive into the code:</p><p>Step 1: Import the required libraries</p><pre>import numpy as np<br>from sklearn.linear_model import LinearRegression<br>from sklearn.preprocessing import PolynomialFeatures<br>import matplotlib.pyplot as plt </pre><p>Step 2: Creating the dataset</p><pre># Input features<br>X = np.array([1, 5, 2, 8, 4, 5]).reshape(-1, 1)<br># Output variable<br>y = np.array([2, 4, 5, 4, 5,6,9]</pre><p>Step 3: Transforming features into polynomial features</p><pre># Create a PolynomialFeatures object of desired degree<br>degree = 3<br>poly_features = PolynomialFeatures(degree=degree)<br># Polynomial features transformation<br>X_poly = poly_features.fit_transform(X)</pre><p>Note that you can adjust the degree of the polynomial by modifying the degree parameter in the PolynomialFeatures class. Higher degrees allow for more complex polynomial relationships, but may also lead to overfitting if the degree is too high for the available data.</p><p>Step 4: Creating and training the model</p><pre># Create a linear regression object<br>model = LinearRegression()<br># Train the model using the polynomial features<br>model.fit(X_poly, y)</pre><p>Step 5: Making predictions and visualizing the resultsde</p><pre># Generate polynomial features for prediction<br>X_test = np.linspace(1, 5, 100).reshape(-1, 1) #numpy.linspace(start,stop,num= 50)<br><br>X_test_poly = poly_features.transform(X_test)</pre><pre># Predict the output for new data points<br>y_pred = model.predict(X_test_poly)</pre><pre># Plot the original data points<br>plt.scatter(X, y, color=&#39;b&#39;, label=&#39;Actual&#39;)</pre><pre># Plot the predicted values<br>plt.plot(X_test, y_pred, color=&#39;r&#39;, label=&#39;Predicted&#39;)</pre><pre># Add labels and title to the plot<br>plt.xlabel(&#39;X&#39;)<br>plt.ylabel(&#39;y&#39;)<br>plt.title(&#39;Polynomial Regression (Degree {})&#39;.format(degree))<br>plt.legend()</pre><pre># Display the plot<br>plt.show()</pre><p><strong>Disadvantages of polynomial regression</strong></p><p>Polynomial regression, like linear regression, has limitations.</p><ol><li>Outliers can significantly affect the results</li><li>and overfitting is a common issue. The quote by John von Neumann highlights the risk of fitting complex models to the data.</li></ol><h4><strong>Conclusion:</strong></h4><p>Polynomial regression provides a powerful framework for modeling nonlinear relationships between variables. By introducing polynomial features, the model can capture complex curves and better fit the data. olynomial Regression is preferred over Linear Regression when dealing with non-linear relationships in the data. It allows for more flexibility by fitting a curve to the data points, capturing the non-linear patterns more accurately. By programming and visualizing the results, we can observe the limitations of Linear Regression and appreciate the advantages of Polynomial Regression in capturing non-linear relationships.Happy modeling!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b39ea30aadbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linear Regression in ML]]></title>
            <link>https://medium.com/@tavishi.1402/linear-regression-in-ml-56107a59be03?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/56107a59be03</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Sun, 28 May 2023 17:09:02 GMT</pubDate>
            <atom:updated>2023-06-02T17:34:35.730Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h3>Linear Regression in Machine Learning</h3><h4>Unleashing the predictive power of machine learning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ur2Rl8nSxpIKQsPO.jpg" /></figure><h4><strong>What is Regression ??</strong></h4><p>Regression is a statistical technique used in machine learning and statistical modeling to analyze the <strong>relationship between a dependent variable and one or more independent variables</strong>, <strong>It aims to find a mathematical equation or model that best represents the relationship between the variables</strong></p><h4>Types of Regression models</h4><ol><li>Simple Linear Regression</li><li>Multiple Linear Regression</li><li>Polynomial Regression</li><li>Logistics Regression</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*z34vg1BomgkHpGUF.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*dcOKrvKk8Z3V6Gy_VfBrPw.jpeg" /></figure><p>In simple words in Linear Regression we have only one input and one output , but in Multiple Linear Regression we have multiple inputs and one output.</p><h4>What is Linear Regression ??</h4><p>In the field of machine learning, Linear Regression is one of the fundamental algorithms used for predictive modeling. It is a supervised learning technique that establish a <strong>Linear relationship</strong> between a dependent variable and one or more independent variables. In this blog post, we will delve into the concept of Linear Regression, its underlying principles, and provide a step-by-step guide to implementing it with code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*eRqtnWb6MRPnA22BIekSEw.png" /></figure><p><strong>Understanding Linear Regression</strong>: Linear Regression is a statistical approach that assumes a linear relationship between the input variables (independent variables) and the output variable (dependent variable). It predicts the value of the dependent variable based on the given set of independent variables. The goal is to find the best-fit line that minimizes the sum of squared errors between the predicted and actual values.</p><p>The equation of a simple linear regression model can be represented as: y = mx + c</p><p>Where:</p><ul><li>y is the dependent variable (target variable)</li><li>x is the independent variable (input variable)</li><li>m is the slope of the line (coefficient)</li><li>c is the y-intercept (constant term)</li></ul><p><em>A regression line can be a Positive Linear Relationship or a Negative Linear Relationship.</em></p><h4>Positive Linear Relationship:</h4><p>A positive linear relationship, also known as a direct or direct proportionality relationship, In a positive linear relationship, the relationship between the variables can be represented by a straight line when plotted on a scatter plot. The line has a positive slope, indicating that for every unit increase in one variable, there is a corresponding increase in the other variable.</p><p>For example, consider the relationship between hours of study and exam scores. If there is a positive linear relationship between these two variables, it means that as the number of study hours increases, the exam scores also increase. Similarly, if the study hours decrease, the exam scores decrease accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qBWeYePvalab65CL.png" /></figure><h4>Negative Linear Relationship:</h4><p>In a negative linear relationship, the relationship between the variables can be represented by a straight line with a negative slope when plotted on a scatter plot. The line slopes downward from left to right, indicating that for every unit increase in one variable, there is a corresponding decrease in the other variable.</p><p>For example, consider the relationship between the price of a product and the quantity demanded. If there is a negative linear relationship between these variables, it means that as the price of the product increases, the quantity demanded decreases. Similarly, if the price decreases, the quantity demanded increases.</p><h4><strong>Implementing Linear Regression:</strong></h4><p>Let’s dive into the implementation of Linear Regression using Python and the popular machine learning library, scikit-learn. We will use a sample dataset to illustrate the process. Before this lets understand some Basic and important terms:</p><h3>Cost function:</h3><p>In linear regression, the cost function, <strong>also known as the loss function</strong> is <strong>used to measure the error or </strong>the mismatch between the predicted values and the actual values of the dependent variable. <strong>The goal of linear regression is to minimize this cost function to find the best-fitting line that represents the relationship between the independent variables and the dependent variable.</strong></p><p>In Linear Regression, <strong>Mean Squared Error (MSE), Root Mean Square Error(RMSE ), Mean Absolute Error(MAE) </strong>cost function is used</p><p><strong>Mean Squared Error (MSE)</strong> :is a widely used metric in regression problems to measure the average squared difference between the predicted values and the actual values. It provides a measure of how well a regression model fits the data points.</p><p>Mathematically, MSE is calculated by taking the average of the squared differences between the predicted values (ŷ) and the actual values (y):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/0*Gh4yu7NjEP7V3Fub.jpg" /></figure><p>Where:</p><ul><li>n is the total number of data points</li><li><strong>y </strong>represents the <strong>actual values</strong> of the dependent variable</li><li><strong>ŷ </strong>represents the <strong>predicted values</strong> of the dependent variable</li></ul><p>Key points to understand about MSE:</p><ol><li>Squaring the differences: <strong>Squaring the differences between predicted and actual values has two primary purposes: it removes the negative signs and emphasizes larger errors by magnifying them. </strong>This is important because we want to penalize larger errors more significantly.</li><li>Average of squared differences: To obtain the MSE, the sum of squared differences is divided by the total number of data points (n). This normalization ensures that the MSE is comparable across datasets of different sizes.</li></ol><p>Here are some scenarios where MSE is often used:</p><ol><li><strong>Optimization</strong>: MSE is commonly used as the cost function in optimization algorithms, such as gradient descent, to train regression models. The goal is to minimize the MSE by adjusting the model parameters or coefficients, ultimately finding the best-fitting line that minimizes the overall prediction errors.</li><li><strong>Differentiability</strong>: MSE is a differentiable function, which is desirable for many optimization algorithms. Its differentiability allows for efficient computation of gradients and facilitates the optimization process.</li><li><strong>Emphasizing Larger Errors</strong>: If you want to put more weight on larger errors or outliers, MSE is suitable. Squaring the errors in MSE amplifies their impact on the overall metric, making it more sensitive to extreme values.</li></ol><p>However, it’s important to note that MSE has a drawback in terms of interpretability. <strong>Since it involves squaring the errors, the units of MSE are not in the same scale as the dependent variable. This makes it less interpretable and harder to communicate the average prediction error in practical terms.</strong></p><p>In Short, MSE is a widely used metric in regression problems that measures the average squared difference between the predicted and actual values of the dependent variable. It is often used as a cost function for optimization and is sensitive to larger errors or outliers. However, it lacks interpretability in the original units of the dependent variab</p><h4>Root Means Square</h4><p>RMSE (Root Mean Squared Error) is commonly used as a performance metric in regression problems, especially when the scale of the dependent variable is significant.</p><p>The RMSE is calculated by taking the square root of the average of the squared differences between the predicted values (ŷ) and the actual values (y) of the dependent variable. The formula for RMSE is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/0*dpw0M_FPSeebPHXI.png" /></figure><ul><li>n is the total number of data points</li><li><strong>y </strong>represents the <strong>actual values</strong> of the dependent variable</li><li><strong>ŷ </strong>represents the <strong>predicted values</strong> of the dependent variable</li></ul><p>Here are some scenarios where RMSE is often used:</p><ol><li><strong>Prediction Accuracy</strong>: RMSE is a widely used metric to assess the accuracy of regression models in predicting the values of the dependent variable. It provides a measure of the average prediction error in the same units as the dependent variable. Higher RMSE values indicate larger prediction errors and lower model accuracy.</li><li><strong>Comparing Models: </strong>RMSE is useful for comparing the performance of different regression models. By calculating the RMSE for each model on the same dataset, you can determine which model produces predictions that are closer to the actual values. The model with the lower RMSE is generally considered to be a better fit to the data.</li><li><strong>Outlier Sensitivity:</strong> RMSE is sensitive to outliers or extreme values. As it involves squaring the differences between predicted and actual values, outliers can have a significant impact on the RMSE. If your data contains outliers that you want to account for in your evaluation, using RMSE can provide a more robust measure of model performance compared to other metrics like Mean Absolute Error (MAE).</li><li><strong>Interpretability:</strong> RMSE provides a measure of the average prediction error in the same units as the dependent variable. This makes it more interpretable and easier to communicate in practical terms. For example, if the dependent variable represents sales in dollars, the RMSE will be expressed in dollars, allowing you to understand the average prediction error in terms of currency.</li></ol><p>It’s important to note that the choice of evaluation metric, whether it’s RMSE or another metric, depends on the specific problem, the characteristics of the data, and the goals of the analysis. Different metrics may be more appropriate in certain scenarios, and it’s often recommended to consider multiple evaluation metrics to gain a comprehensive understanding of model performance.</p><p>In short, RMSE is commonly used in regression problems to evaluate the accuracy and performance of models, compare different models, account for outliers, and provide a measure of prediction error in the same units as the dependent variable.</p><h4>Mean Absolute Error</h4><p>MAE (Mean Absolute Error) is another commonly used metric for evaluating the performance of regression models. It measures the average absolute difference between the predicted values and the actual values of the dependent variable. Unlike RMSE, MAE does not involve squaring the differences, making it less sensitive to outliers.</p><p>The MAE is calculated by taking the average of the absolute differences between the predicted values (ŷ) and the actual values (y) of the dependent variable. The formula for MAE is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/0*pekgUwh_vurG6whk.png" /></figure><p>Similar to RMSE, in the formula, n represents the total number of data points, y represents the actual values of the dependent variable, and ŷ represents the predicted values of the dependent variable.</p><p>MAE provides a measure of the average magnitude of the prediction errors in the same units as the dependent variable. It represents the average absolute deviation of the predicted values from the actual values. Lower MAE values indicate better model performance, as they reflect smaller average prediction errors.</p><p>When to use MAE:</p><ol><li><strong>Robustness to Outliers</strong>: MAE is less sensitive to outliers compared to RMSE because it does not involve squaring the differences. If your data contains outliers or extreme values that you want the model evaluation to be less affected by, using MAE as a metric is beneficial.</li><li><strong>Interpretability</strong>: Similar to RMSE, MAE is interpretable in the same units as the dependent variable. It provides a measure of the average absolute prediction error, which can be easily understood and communicated in practical terms.</li><li><strong>Equally Weighted Errors</strong>: MAE treats all errors equally. Each prediction error contributes proportionally to the overall average error. This characteristic can be advantageous in certain cases where all errors are considered equally important.</li></ol><p>However, MAE does not penalize larger errors as heavily as RMSE does. It does not account for the squared differences, which can make it less sensitive to extreme errors. Depending on the problem and the nature of the data, this may or may not be desirable.</p><p>In Short, MAE is a commonly used metric in regression problems that measures the average absolute difference between the predicted and actual values of the dependent variable. It is robust to outliers and provides an interpretable measure of prediction error. Choosing between MAE and RMSE depends on the specific requirements of the problem and the desired treatment of outliers.</p><h4>Implementation of Linear Regression</h4><p>Step 1: Import the required libraries</p><pre>import numpy as np<br>import pandas as pd<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LinearRegression<br>from sklearn.metrics import mean_squared_error, r2_score</pre><p>Step 2: Load and explore the dataset</p><pre># Load the dataset<br>data = pd.read_csv(&#39;dataset.csv&#39;) <br># Explore the dataset<br>print(data.head())</pre><pre># Explore the dataset<br>print(data.head())</pre><p>Step 3: Split the dataset into training and testing sets</p><pre># Split the dataset into features (X) and target variable (y)<br>X = data[[&#39;independent_variable&#39;]]<br>y = data[&#39;dependent_variable&#39;]</pre><pre># Split the data into training and testing sets<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)</pre><p>Step 4: Create and train the Linear Regression model# Create a Linear Regression model</p><pre># Create a Linear Regression model<br>model = LinearRegression()<br><br># Train the model using the training sets<br>model.fit(X_train, y_train)</pre><p>Step 5: Make predictions and evaluate the model</p><pre># Make predictions on the testing set<br>y_pred = model.predict(X_test)<br># Evaluate the model<br>mse = mean_squared_error(y_test, y_pred)<br>r2 = r2_score(y_test, y_pred)<br>print(&#39;Mean Squared Error:&#39;, mse)<br>print(&#39;R-squared:&#39;, r2)</pre><p><strong>Conclusion</strong>: Linear Regression is a powerful technique that allows us to model and predict relationships between variables. By minimizing the sum of squared errors, it finds the best-fit line that approximates the relationship between the independent and dependent variables. In this blog post, we discussed the underlying principles of Linear Regression and provided a step-by-step guide to implementing it using Python and scikit-learn. By following these steps, you can start exploring and applying Linear Regression to your own datasets for various prediction tasks.</p><p>To assess the accuracy of a model’s predictions, various performance metrics can be used to evaluate its performance and effectiveness in capturing the correct outcomes, to read more <a href="https://medium.com/@tavishi.1402/part-1-performance-metrics-in-machine-learning-27cd9264e398">Click on this article</a></p><p><a href="https://medium.com/@tavishi.1402/part-1-performance-metrics-in-machine-learning-27cd9264e398">Part-1 Performance Metrics in Machine Learning</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56107a59be03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Machine Learning ????]]></title>
            <link>https://medium.com/@tavishi.1402/what-is-machine-learning-ca99bcd06095?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca99bcd06095</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Fri, 26 May 2023 18:26:20 GMT</pubDate>
            <atom:updated>2023-05-28T16:43:06.160Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h3>What is Machine Learning ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*ur51ukhdw0jfDSokPZ52iQ.jpeg" /></figure><p><strong>Introduction</strong>: Machine learning, a subset of artificial intelligence, has emerged as a groundbreaking technology with the potential to transform numerous industries and shape the future of innovation. Machine learning is an exciting technology that allows computers to learn from data and make predictions without being explicitly programmed. It’s like teaching a computer to think and make decisions on its own. By analyzing large amounts of data, machine learning algorithms can discover patterns and make accurate predictions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7HOnDzguDbk6C-tzSXusLw.jpeg" /></figure><p><strong>Understanding Machine Learning</strong>: <br>Machine learning is all about teaching computers to learn and make decisions on their own without us telling them exactly what to do. We do this by giving them lots of examples or data to learn from. Just like how we learn from experience, computers learn by analyzing the data and finding patterns in it.</p><p>We use mathematical techniques and powerful computers to help computers make sense of the data. They look for similarities, differences, and trends in the data, which helps them understand what it means and make predictions or decisions based on that understanding.</p><p>The more data we give them, the better they become at making accurate predictions or decisions. It’s like training a dog. The more times you show a dog a new trick, the better they get at doing it correctly.</p><h3><strong>The Three Types of Machine Learning</strong>:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DDlB5Ik8RYZ2hDaHSJxN6A.png" /></figure><p><strong>a. Supervised Learning</strong>: Supervised learning is a type of machine learning where we teach a machine using labeled data. Labeled data means we know the desired output or answer for each example in the training data. The machine learns from this labeled data to make predictions or classify new, unseen data.</p><p>Think of it like teaching a computer to recognize different things. We show it lots of examples and tell it what each example represents. For example, we can show the computer many emails and tell it which ones are spam and which ones are not. By learning from these labeled examples, the machine can then predict if new emails are spam or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZEozb3RI7tNyZu75b86eBQ.png" /></figure><p>Supervised learning has many practical applications. It can help us detect spam emails, where the machine learns to recognize patterns in the content of emails to determine if they are spam or not. It can also be used for image recognition, where the machine learns to identify objects or people in images based on labeled examples. Another application is sentiment analysis, where the machine learns to analyze text and determine the sentiment or emotion expressed, such as whether a review is positive or negative.</p><p>In summary, supervised learning is a powerful tool that allows machines to learn from labeled data and make predictions or classifications on new, unseen data. It has a wide range of applications, from spam detection to image recognition and sentiment analysis.</p><p><strong>b. Unsupervised Learning: </strong>Unsupervised learning is a type of machine learning where machines learn from unlabeled data. Unlabeled data means that we don’t have specific guidance or answers for the examples in the training data. Instead, the machines try to find patterns or structures within the data on their own.</p><p>Imagine you have a big collection of pictures, but you don’t know what each picture represents. With unsupervised learning, you can teach a machine to look for similarities or common features among the pictures. It might group similar pictures together, even if you don’t know what those pictures actually show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*BnQdoGECOZekYIbkw2Ju7w.png" /></figure><p>There are different tasks in unsupervised learning. One of them is called clustering, where the machine tries to group similar examples together based on their characteristics. It’s like organizing a messy closet by putting similar clothes in the same pile.</p><p>Another task is dimensionality reduction. Sometimes, data has many different features or attributes, which can make it difficult to understand or analyze. With dimensionality reduction, the machine tries to simplify the data by finding the most important or relevant features. It’s like summarizing a long story into a few key points.</p><p>Anomaly detection is another example of unsupervised learning. In this task, the machine learns what is normal or expected in a dataset, and then it can identify unusual or unexpected patterns. It’s like a security system that alerts you when something out of the ordinary happens.</p><p>Unsupervised learning is particularly useful for exploring and discovering hidden insights in data. It can help us uncover patterns, group similar examples, and identify anomalies without needing specific guidance or labeled examples.</p><p>In simple terms, unsupervised learning is when machines learn from unlabeled data to find patterns or structures on their own. Tasks like clustering, dimensionality reduction, and anomaly detection fall under unsupervised learning. It’s like organizing pictures based on similarities, summarizing complex data, or spotting something unusual in a dataset.</p><p><strong>c. Reinforcement Learning</strong>: Reinforcement learning is a type of machine learning where an “agent” learns to make decisions by interacting with its environment and receiving feedback. This feedback comes in the form of rewards or penalties, which tell the agent whether its actions were good or bad.</p><p>Think of it like teaching a pet. When the pet does something good, we give it a treat as a reward. When it does something bad, we might give it a little punishment. Over time, the pet learns to make better decisions to get more rewards and avoid punishments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*mVmqPSO6Yr8Z4TV_AFtB4g.jpeg" /></figure><p>In reinforcement learning, the agent starts with little or no knowledge about the environment. It takes actions, and based on those actions, it receives rewards or penalties. By repeatedly trying different actions and observing the consequences, the agent learns which actions lead to the most rewards. It gradually improves its decision-making abilities through trial and error.</p><p>Reinforcement learning has many applications. For example, in robotics, we can use reinforcement learning to train robots to perform specific tasks. The robot tries different actions, and based on the feedback it receives, it learns how to perform the task more efficiently.</p><p>In game playing, reinforcement learning can be used to train computer programs to play games. The program learns by playing the game many times, receiving rewards when it makes good moves and penalties when it makes bad ones. Over time, it becomes better and can even surpass human players.</p><p>Autonomous systems, like self-driving cars, also benefit from reinforcement learning. The car learns to make driving decisions based on rewards and penalties, improving its ability to navigate safely and efficiently.</p><p>To summarize, reinforcement learning is a type of machine learning where an agent learns from feedback in the form of rewards or penalties. Through trial and error, the agent improves its decision-making abilities to maximize cumulative rewards. It has applications in robotics, game playing, and autonomous systems, among others. It’s like teaching a pet to make good decisions by rewarding good behavior and punishing bad behavior.</p><h4>Summary of type of Machine Learning :</h4><p><strong>1. Supervised Machine Learning — Task-Oriented (Classification — Regression)</strong></p><p><strong>2. Unsupervised Machine Learning — Fact or Data-Oriented (Cluster — Anomaly detection)</strong></p><p><strong>3. Reinforcement Machine Learning — Either learning from mistakes or learning from them correctly</strong></p><h3><strong>Applications of Machine Learning:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*oh9abrN3SYWqGkgnN2GqsA.png" /></figure><p><strong>a. Healthcare</strong>: Machine learning revolutionizes healthcare by enabling early disease detection, personalized medicine, and data-driven decision-making. It assists in medical imaging analysis, patient monitoring, and drug discovery, leading to improved diagnostics and treatments.</p><p><strong>b. Finance and Banking</strong>: Machine learning plays a crucial role in fraud detection, credit risk assessment, and algorithmic trading. By analyzing vast financial datasets, it can identify patterns indicative of fraudulent activities, make accurate risk predictions, and optimize investment strategies.</p><p><strong>c. Transportation and Autonomous Systems: </strong>Machine learning powers self-driving cars, enabling them to perceive their surroundings, make real-time decisions, and navigate safely. It also improves traffic management, logistics optimization, and predictive maintenance in transportation systems.</p><p><strong>d. Natural Language Processing</strong>: Machine learning algorithms enable machines to understand and process human language. It facilitates applications such as machine translation, sentiment analysis, chatbots, and voice assistants.</p><h4><strong>Ethical Considerations and Challenges:</strong></h4><p>Even though machine learning is really helpful, there are some things we need to be careful about. One important thing is making sure that the results it gives us are fair and unbiased. Sometimes, the algorithms can unintentionally favor certain groups of people or make unfair decisions. We need to be aware of this and try to fix it.</p><p>Another thing to think about is privacy. Machine learning uses a lot of data, and we need to make sure that people’s personal information is kept safe and not misused.</p><p>There’s also concern about how machine learning might affect jobs. Some tasks that used to be done by people might now be done by machines. This means that some jobs could change or even disappear. We need to think about how to support people and make sure that everyone has opportunities for new jobs and skills.</p><p>To make sure that machine learning is used in the right way, we need to be open and transparent about how it works. We should have clear rules and be accountable for the decisions that are made using machine learning.</p><p>By being aware of these challenges and working together, we can make sure that machine learning is used responsibly and benefits everyone. It’s important to think about fairness, privacy, and the impact on jobs as we continue to use this powerful technology.</p><p><strong>The Future of Machine Learning:</strong> Machine learning keeps getting better and better because computers are becoming more powerful, we have access to more data than ever before, and researchers are discovering new and improved algorithms. These advancements are leading to some really exciting developments, like deep learning, neural networks, and generative models. And these new techniques have the potential to bring about even more innovation in various industries and fields.</p><p><strong>Conclusion: </strong>Machine learning is an exciting field that is helping us solve complex problems and make our lives better. By working together with machines and using machine learning in the right way, we can make amazing progress and create a future where technology helps us do things we never thought possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca99bcd06095" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is Perception in Neural Networks?]]></title>
            <link>https://medium.com/@tavishi.1402/what-is-perception-in-neural-network-fd22a84c08ea?source=rss-639c4ec34ac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd22a84c08ea</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Tavishi]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 01:58:26 GMT</pubDate>
            <atom:updated>2022-11-28T03:57:35.758Z</atom:updated>
            <content:encoded><![CDATA[<h4>Data Science</h4><h4>An overview of the perceptron and how they work</h4><p>Perceptron&#39;s are the building blocks of neural networks. A single layer perceptron is called neural network and a multi-layer perceptron is called Neural Networks. Perceptron is a linear classifier (binary). It is typically used for supervised learning.</p><p>Neural networks, also known as artificial neural networks (ANNs) or simulated neural networks (SNNs), are a subset of machine learning that provide the foundation of deep learning techniques. Neural networks are computational algorithms or models that understand the data and process information. Their name and structure are inspired by the human brain, mimicking the way that biological neurons signal to one another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iyY4lS84IsmNhwGh_UCjbA.gif" /></figure><p>This is an excellent illustration of the human brain. Our brains were empty at birth, but when we encountered the real world, we learned about things by seeing them or hearing about them. In a same way our system learns from the data and past experience to identify the patterns and makes predictions.</p><p>The role of neurons in the brain is played by the perceptron in a neural network. A perceptron can learn to detect input data computations in business intelligence. Perceptron algorithms help in the linear separation of classes and patterns based on the numerical or visual input data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ui3IvoiVYBFtaU0auj63ew.gif" /></figure><h3>Components of a Perceptron</h3><p>A perceptron consists of</p><ol><li>Input values</li><li>Weights and Bias</li><li>Net sum (weighted sum)</li><li>Activation Function- It explains the non-linearity in the perceptron model.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NgHej1wvi7yiNX0lMIOdaQ.png" /></figure><h4>Why do we Need Weight and Bias?</h4><p>Weight and bias are two essential components of the perceptron model. These are learnable parameters, and as the network is trained, both parameters are adjusted to reach the desired values and output.</p><p>Weights are used to determine how important each feature is in forecasting output value. Features with near-zero values are deemed to have less weight or relevance. These are less important in the prediction process than features with values greater than zero, known as weights with a higher value. If a feature’s weight is positive, it has a direct link with the target value; if it is negative, it has an inverse relationship with the target value.</p><h4>Why do we need Activation Function?</h4><p>The activation function is an important part of an artificial neural network. They basically decide whether a neuron should be activated or not</p><h3>How does Perceptron work?</h3><p><a href="https://www.youtube.com/watch?v=JkeiEYkLEvM">Tutorial 2- How does Neural Network Work — YouTube</a></p><ol><li>All the inputs <strong><em>x1,x2,x3…xn</em></strong> are given to the input layer and weights are assigned once an input layer has been defined.</li><li>All inputs are then multiplied by respective weights and added together.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*kdV2irAimDiHcc-rYYVSig.png" /></figure><p>3. <strong>Apply</strong> that weighted sum to the correct <a href="https://medium.com/towards-data-science/activation-functions-neural-networks-1cbd9f8d91d6"><strong><em>Activation Function</em></strong>.</a> The output is processed by an activation function, which decides the output.</p><ul><li>For Binary classification we the Sigmoid Activation function</li><li>For multiclassification we generally use SoftMax Activation function at the output layer and variation of ReLU Activation function at Hidden layers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZafDv3VUm60Eh10OeJu1vw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HY0tZ8HpMNK7CXxcQmIg1g.png" /></figure><p>4. Use cost function to get the output, when the perceptron’s input values are similar to those desired for its anticipated output, we can claim that it performed satisfactorily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*5mkQMk2YubPfaG2LHNTwXA.png" /></figure><p>5. If there is a difference between what was expected and what was obtained, the weights must be adjusted to restrict the extent to which these errors effect future forecasts based on unchanged parameters.</p><h3>Perceptron Model</h3><p>The perceptron model was deployed for machine-driven picture recognition for the first time in 1957 at Cornell Aeronautical Laboratory in the United States. It was claimed to be the most notable AI-based innovation because it was the first artificial neural network.<br>The perceptron algorithm, on the other hand, has certain technological limitations. Because it was single-layered, the perceptron model could only be applied to linearly separable classes. The invention of multi-layered perceptron algorithms later resolved the problem. Here is a more in-depth look at the various sorts of perceptron models:</p><h3>Single Layer Perceptron Model</h3><p>SLP is the most basic type of artificial neural network, and it can only classify situations that are linearly separable with a binary target (1, 0). Activation functions are neural network decision-making components. They calculate net output of a neural node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8R0hWWkWY8vGdtg_bVR1g.jpeg" /></figure><p>A single layer perceptron (SLP) is a feed-forward network (To generate some output, the input data should only be fed forward. The input should not flow backwards during output generation; otherwise, a cycle would occur and the output would never be formed. This type of network arrangement is known as a feed-forward network. Forward propagation is aided by the feed-forward network.) based on a threshold transfer function.</p><h3>Multilayer Perceptron Model</h3><p>The multi-layer perceptron model, often known as the Backpropagation algorithm, works in two stages: Forward Stage: In the forward stage, activation functions begin on the input layer and end on the output layer. Backward Stage: In the backward stage, weight and bias values are adjusted to meet the needs of the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*KrhdlmEQSu_AnBXZkDMdZQ.png" /></figure><h3>Forward propagation</h3><p>As the name suggests, the input data is fed in the forward direction through the network. Forward propagation is the way data moves from left (input layer) to right (output layer) in the neural network. Each hidden layer accepts input data, processes it according to the activation function, and then sends it on to the next layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*ENnf5rk_VNeiY9ujMHCYsg.jpeg" /></figure><h3>Backward propagation</h3><p>The process of moving from the right to left that is backward from the Output to the Input layer is called the<strong> Backward Propagation. </strong>Backpropagation in neural networks is an abbreviation for “backward error propagation.” The core of neural network training is backpropagation. It is a common technique for training artificial neural networks. It is a preferable method of fine-tuning neural network weights based on the error rate achieved in the previous epoch (i.e., iteration (Forword propagation + backward propagation). By fine-tuning (adjusting or correcting) the weights, we can minimize error rates and make the model more Accurate.</p><h4>Limitations of the Perceptron Model</h4><p>A perceptron model has the following limitations:</p><ul><li>The perceptron generates only a binary number (0 or 1) as an output due to the hard limit transfer function.</li><li>A single layer perceptron can only learn linearly separable problems. Boolean AND function is linearly separable, whereas Boolean X OR function (and the parity problem in general) is not. Hence non-linear input vectors cannot be classified properly.</li></ul><p>Any comments or if you have any questions, <strong>write them in the comment.</strong></p><p><strong>Clap it! Share it! Follow Me!</strong></p><p>Happy to be helpful. …..</p><p><strong>References</strong></p><ul><li><a href="https://www.analytixlabs.co.in/">https://www.analytixlabs.co.in</a></li><li><a href="https://www.youtube.com/watch?v=JkeiEYkLEvM">Krish Naik</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd22a84c08ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>