<?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 Vishal jain on Medium]]></title>
        <description><![CDATA[Stories by Vishal jain on Medium]]></description>
        <link>https://medium.com/@vj_jainy?source=rss-4634cd4d2e45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Vishal jain on Medium</title>
            <link>https://medium.com/@vj_jainy?source=rss-4634cd4d2e45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 05:58:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vj_jainy/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[Everything You Need To know About “lsof” Command In Linux]]></title>
            <link>https://medium.com/@vj_jainy/everything-you-need-to-know-about-lsof-command-in-linux-3943def96a12?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/3943def96a12</guid>
            <category><![CDATA[file-descriptor]]></category>
            <category><![CDATA[lsof]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Sun, 22 Dec 2024 14:34:16 GMT</pubDate>
            <atom:updated>2024-12-22T14:34:16.149Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In this article we will try to understand why <strong><em>lsof </em></strong>stands for list open files and its use cases in real world.</blockquote><p>Before starting let’s remember the founding stone of linux that “<em>everything in linux is a file</em>”.</p><p>It essentially <strong>Displays information about files opened by processes.</strong> This includes not only files on the local disk but also network sockets, pipes, and other file system objects.</p><p>For every file that a process access linux assigns a positive integer to it. The reason is it decouples it from filepath thus preventing the overhead. It will also come in handy once we understand process and system-wide open file description table that linux maintains.</p><p>Consider <strong><em>process table</em></strong> as a data structure that linux maintains for each process which stores information about a process like process id, parent process id, cpu usage, file descriptors etc. It helps <strong><em>lsof </em></strong>to gather information about open files. Similarly there is a <strong><em>system-wide open file description table</em></strong> which as name suggests maintains information about all open files across the entire system.</p><p>To check file descriptor used by a file you can go to <strong>/proc/process_id</strong> and can find all file descriptor under “<strong><em>fd</em></strong>” used by a process.</p><p>Lets try to understand the output of <strong><em>lsof</em></strong>:</p><p>For example I have first run <strong>top </strong>command in one terminal and <strong>lsof </strong>in another:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*5iWLQdsNAhdko4M-8QfNUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7Y9PvkKq3a3qZ_DlnfYJA.png" /></figure><p>In above example <strong>command </strong>is the name of the process in some cases it also includes kernel threads. <strong>PID </strong>is the process ID. <strong>USER </strong>is the owner of the process. <strong>FD </strong>is our file descriptor. Consider FD “<strong>5r</strong>” for example it means <strong>5 </strong>is the file descriptor, open for read. Similarly “<strong>w</strong>” stands for write and “<strong>u</strong>” stands for open for both reading and writing.</p><p>You can also verify same thing under <strong>/proc</strong>, where <strong>3756 </strong>is our PID from above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*pW6-5gVwHOIelG94STMO4g.png" /></figure><p>Now let’s see some of the use cases of <strong><em>lsof</em></strong>:</p><ul><li><strong>Finding open files:</strong></li><li>lsof filename - Displays information about processes that have the specified file open.</li><li>lsof -p &lt;PID&gt; - Displays all files opened by a specific process.</li><li><strong>Identifying network connections:</strong></li><li>lsof -i - Displays information about all network connections.</li><li>lsof -i :&lt;port&gt; - Displays information about processes listening on a specific port.</li><li><strong>Checking for resource leaks:</strong></li><li>lsof | grep deleted - Finds files that have been deleted but are still open.</li><li><strong>Troubleshooting network problems:</strong></li><li>lsof -i :&lt;port&gt; - Can help determine if a port is in use and by which process.</li></ul><p>That’s it for now, feel free to comment in case you feel something is missing out, I will try to add in it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3943def96a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What was 1929 Great Depression ?]]></title>
            <link>https://medium.com/@vj_jainy/what-was-1929-great-depression-c9adb717fab7?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9adb717fab7</guid>
            <category><![CDATA[stock-market-crash]]></category>
            <category><![CDATA[economic-crisis]]></category>
            <category><![CDATA[great-depression]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 05:05:19 GMT</pubDate>
            <atom:updated>2023-08-02T05:05:19.601Z</atom:updated>
            <content:encoded><![CDATA[<h3>What was 1929 Great Depression ?</h3><p>The Great Depression was a severe and prolonged economic downturn that took place during the 1930s. It is considered one of the most devastating economic crises in history. While the depression lasted throughout the 1930s, it is often associated with the year 1929 due to the significant events that occurred during that time.</p><p>The causes of the Great Depression were complex and multifaceted, but some key factors include:</p><ol><li><strong>Stock Market Crash of 1929:</strong> On October 29, 1929, also known as <strong><em>“Black Tuesday,”</em></strong> the U.S. stock market experienced a massive crash. The values of many stocks plummeted, leading to a massive loss of wealth for investors.</li><li><strong>Speculative Bubble:</strong> In the years leading up to the crash, there was a speculative bubble in the stock market, driven by excessive borrowing and speculation. As stock prices soared, investors engaged in risky buying and selling practices, creating an unsustainable market.</li><li><strong>Banking Crisis:</strong> The stock market crash severely impacted the banking system. Banks had invested heavily in the stock market, and when the market collapsed, many banks lost significant amounts of money. Panicked depositors rushed to withdraw their savings, leading to numerous bank failures.</li><li><strong>Overproduction and Underconsumption:</strong> Industries were producing more goods than consumers could afford to buy. As a result, inventories piled up, and businesses had to cut back production, leading to layoffs and a further decline in consumer spending.</li><li><strong>Decline in International Trade:</strong> The Smoot-Hawley Tariff Act of 1930, which raised tariffs on imported goods, resulted in retaliatory tariffs from other countries, reducing international trade and worsening the global economic situation.</li><li><strong>Tight Monetary Policy: </strong>The Federal Reserve’s response to the initial economic downturn was to raise interest rates and restrict the money supply, further exacerbating the crisis.</li></ol><p>The effects of the Great Depression were far-reaching and devastating. Unemployment soared, reaching levels as high as 25% in the United States. Families lost their homes, businesses collapsed, and people struggled to survive. The economic downturn had profound social and psychological impacts, leading to increased poverty, homelessness, and widespread hardship.</p><p>To address the Great Depression, governments around the world implemented various policies, such as the New Deal in the United States. The New Deal, introduced by President Franklin D. Roosevelt, included a range of social and economic programs aimed at providing relief, recovery, and reform. While the Great Depression eventually ended with the onset of World War II, its impact on the global economy and society left a lasting legacy. Governments and economists have since learned valuable lessons from the Great Depression to help prevent and manage future economic crises.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9adb717fab7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What caused 2008 Financial Crisis and its impact on Economy ?]]></title>
            <link>https://medium.com/@vj_jainy/what-caused-2008-financial-crisis-and-its-impact-on-economy-1262ebed6e59?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/1262ebed6e59</guid>
            <category><![CDATA[financial-crisis]]></category>
            <category><![CDATA[2008-financial-crisis]]></category>
            <category><![CDATA[economy]]></category>
            <category><![CDATA[housing-bubble]]></category>
            <category><![CDATA[recession]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Sat, 29 Jul 2023 05:23:18 GMT</pubDate>
            <atom:updated>2023-07-29T05:23:18.306Z</atom:updated>
            <content:encoded><![CDATA[<h3>What caused 2008 Financial Crisis and its impact on Economy ?</h3><p>The 2008 financial crisis, also known as the <strong>global financial crisis</strong> or the Great Recession, was one of the most severe economic downturns since the Great Depression of the 1930s. It had far-reaching consequences that affected economies worldwide and resulted in significant changes to financial regulations and policies.</p><h4>Causes: The crisis had complex and interconnected causes, but some key factors were:</h4><ol><li><strong>Housing Bubble:</strong> One of the primary triggers was the housing market bubble in the United States. For several years leading up to the crisis, housing prices had been rising rapidly, fueled by lax lending practices and the availability of subprime mortgages (high-risk loans to borrowers with poor credit histories).</li><li><strong>Subprime Mortgage Crisis:</strong> Financial institutions, driven by the desire for profit, offered subprime mortgages to borrowers who were high-risk and often unable to afford the loans. These mortgages were then bundled together and sold as complex financial products known as mortgage-backed securities (MBS) and collateralized debt obligations (CDOs).</li><li><strong>Securitization and Derivatives:</strong> The financial industry’s increasing reliance on complex financial instruments made it difficult to assess the actual risks associated with these assets. As MBS and CDOs were sold and resold, their true value and the exposure of different financial institutions to them became uncertain.</li><li><strong>Excessive Leverage:</strong> Many financial institutions, including major banks, operated with high levels of leverage, meaning they held a large amount of debt compared to their actual capital reserves. This made them vulnerable to even minor losses, which, when combined with the toxic assets, triggered a cascading effect.</li><li><strong>Global Interconnectedness:</strong> The global financial system had become highly interconnected, meaning that problems in one part of the world could quickly spread to others through financial markets and institutions.</li></ol><h3>Key Events and Impact:</h3><p>The crisis began to escalate in 2007 when rising numbers of subprime mortgage borrowers started defaulting on their loans. This led to significant losses for financial institutions holding these assets, resulting in a loss of confidence and liquidity issues in the financial markets.</p><p>Notable events during the crisis include the bankruptcy of Lehman Brothers in September 2008, which sent shockwaves through the global financial system and intensified the crisis. Several other major financial institutions also faced serious difficulties, and governments and central banks had to step in with massive bailout packages to prevent further collapses.</p><h4>The crisis had severe consequences, including:</h4><ol><li><strong>Global Recession:</strong> The crisis triggered a worldwide economic downturn, leading to reduced economic activity, rising unemployment, and falling GDP in many countries.</li><li><strong>Bank Failures: </strong>Numerous banks and financial institutions collapsed or faced near-collapse, requiring government intervention to prevent a complete collapse of the financial system.</li><li><strong>Housing Market Crash:</strong> The housing market plummeted, leaving many homeowners with negative equity and facing foreclosure.</li><li><strong>Government Interventions:</strong> Governments and central banks implemented various measures to stabilize the financial system, including bailouts, stimulus packages, and monetary easing.</li><li><strong>Regulatory Reforms:</strong> The crisis highlighted the need for better financial regulation and oversight. Many countries introduced significant regulatory reforms to prevent a similar crisis in the future.</li></ol><p>Overall, the 2008 financial crisis was a stark reminder of the risks posed by irresponsible lending practices, excessive leverage, and the complexities of modern financial markets. It served as a turning point in financial regulations and policies, shaping the global economic landscape for years to come.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1262ebed6e59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Balance Sheet, Income Statement and Cash Flow Statement]]></title>
            <link>https://medium.com/@vj_jainy/what-is-balance-sheet-income-statement-and-cash-flow-statement-9c677985237e?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c677985237e</guid>
            <category><![CDATA[financial-statements]]></category>
            <category><![CDATA[balance-sheet]]></category>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[cash-flow]]></category>
            <category><![CDATA[income-statement]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Tue, 25 Jul 2023 12:35:16 GMT</pubDate>
            <atom:updated>2023-07-25T12:35:16.166Z</atom:updated>
            <content:encoded><![CDATA[<h3>Balance Sheet in Financial</h3><p>A balance sheet is one of the three primary financial statements used by businesses to provide a snapshot of their financial position at a specific point in time. The other two financial statements are the income statement and cash flow statement. The balance sheet is also known as the statement of financial position.</p><p>The purpose of a balance sheet is to show what a company owns (its assets), what it owes (its liabilities), and the residual interest of the owners (shareholders’ equity) at a particular date. The balance sheet follows the accounting equation:</p><p><strong>Assets = Liabilities + Shareholders’ Equity</strong></p><p>Here’s a breakdown of the key components of a balance sheet:</p><ol><li><strong>Assets</strong>: Assets represent everything a company owns or controls that have a measurable value and can be used to generate future economic benefits. Assets are typically categorized into two main types:</li></ol><p>a. <strong>Current Assets:</strong> These are assets that are expected to be converted into cash or used up within one year or one operating cycle of the business, whichever is longer. Common examples include cash, accounts receivable (money owed to the company by customers), inventory, and short-term investments.</p><p>b. <strong>Non-Current Assets (or Fixed Assets):</strong> These are assets that are expected to provide benefits for more than one year and are not easily converted into cash. Examples include property, plant, equipment, long-term investments, and intangible assets like patents and trademarks.</p><p>2. <strong>Liabilities:</strong> Liabilities represent the company’s debts or obligations to external parties. Like assets, liabilities are also categorized into two main types:</p><p>a. <strong>Current Liabilities:</strong> These are obligations that the company is expected to settle within one year or one operating cycle, whichever is longer. Common examples include accounts payable (money owed to suppliers), short-term loans, and accrued expenses.</p><p>b. <strong>Non-Current Liabilities:</strong> These are obligations that the company will settle over a period longer than one year. Examples include long-term loans, bonds payable, and deferred tax liabilities.</p><p>3. <strong>Shareholders’ Equity (or Owner’s Equity):</strong> Shareholders’ equity represents the residual interest in the assets of the company after deducting liabilities. It reflects the amount of money that would be left for the shareholders if all the company’s assets were sold and all its debts were paid off. It includes items such as common stock, additional paid-in capital, retained earnings, and other comprehensive income.</p><p>The balance sheet is prepared in a “vertical” format, with assets listed on the left side and liabilities and shareholders’ equity listed on the right side. The assets’ total must always equal the sum of liabilities and shareholders’ equity to maintain the accounting equation balance.</p><p>The balance sheet is an essential tool for investors, creditors, and other stakeholders to assess the financial health and stability of a company. By analyzing the balance sheet, they can understand the company’s liquidity, solvency, and overall financial position.</p><h3>Income Statement or Profit/Loss Statement</h3><p>A profit and loss statement, also known as an income statement or statement of earnings, is one of the three primary financial statements used by businesses to report their financial performance over a specific period of time, usually a quarter or a year. The other two financial statements are the balance sheet and cash flow statement.</p><p>The purpose of a profit and loss statement is to show the revenues (sales or income) generated by a company and the expenses incurred to generate those revenues during the specified period. The resulting figure is the company’s net income or net loss, which indicates its profitability over the given time frame.</p><p>Here’s a breakdown of the key components of a profit and loss statement:</p><ol><li><strong>Revenues (Sales or Income):</strong> This section includes all the income earned by the company from its primary business activities. Revenue can come from selling products, providing services, or other operating activities. It represents the “top line” of the income statement.</li><li><strong>Cost of Goods Sold (COGS) or Cost of Services:</strong> This category comprises the direct costs associated with producing or providing the goods or services sold by the company. It includes expenses such as raw materials, labor, and manufacturing overhead for manufacturing companies, or direct labor and direct expenses for service-based companies.</li><li><strong>Gross Profit:</strong> Gross profit is calculated by subtracting the cost of goods sold from the total revenue. It represents the amount of money left after covering the direct costs of production or service delivery.</li><li><strong>Operating Expenses:</strong> Operating expenses include all the indirect costs associated with running the day-to-day operations of the business. These expenses are not directly tied to the production of goods or services. Common examples include salaries, rent, utilities, marketing expenses, and administrative costs.</li><li><strong>Operating Income (or Operating Profit):</strong> Operating income is obtained by subtracting the total operating expenses from the gross profit. It represents the company’s profitability from its core operations, excluding interest and taxes.</li><li><strong>Other Income and Expenses:</strong> This category includes any income or expenses that are not directly related to the primary business activities. It may include gains or losses from the sale of assets, interest income, or interest expenses.</li><li><strong>Profit Before Tax:</strong> Profit before tax is the result of adding or subtracting other income and expenses from the operating income. It represents the company’s income before paying income taxes.</li><li><strong>Net Income (or Net Profit/Loss):</strong> Net income is the final figure on the income statement and is calculated by deducting income taxes from the profit before tax. If the result is positive, it represents the net profit earned during the period. If the result is negative, it indicates a net loss.</li></ol><p>The profit and loss statement is crucial for assessing a company’s financial performance, profitability, and ability to generate earnings over a specific period. It helps investors, creditors, and management evaluate the company’s operating efficiency and overall financial health.</p><h3>Cash Flow Statement</h3><p>A cash flow statement is one of the three primary financial statements used by businesses to report their cash inflows and outflows over a specific period of time. The other two financial statements are the balance sheet and income statement (profit and loss statement).</p><p>The purpose of a cash flow statement is to provide a detailed account of how cash has been generated and used during the specified period, which is usually a quarter or a year. It helps stakeholders understand the company’s ability to generate cash and its capacity to meet its financial obligations.</p><p>The cash flow statement is divided into three main sections, each providing valuable insights into the company’s cash flows:</p><ol><li><strong>Operating Activities:</strong> This section shows the cash flows generated or used by the company’s core operating activities, which involve the production and delivery of goods and services. Cash flows from operating activities include receipts from customers and payments to suppliers, employees, and other operating expenses. It also includes interest and dividends received and interest paid.</li><li><strong>Investing Activities:</strong> This section reports cash flows related to the acquisition and disposal of long-term assets and other investments. Cash flows from investing activities include the purchase and sale of property, plant, equipment, and other assets. It also includes investments in other companies (such as acquiring stocks or bonds) and proceeds from the sale of those investments.</li><li><strong>Financing Activities:</strong> This section shows the cash flows resulting from transactions with the company’s owners and creditors. Cash flows from financing activities include proceeds from issuing stocks or taking on long-term debt (e.g., issuing bonds or obtaining loans) and cash payments for dividends, stock buybacks, or debt repayments.</li></ol><p>At the end of the cash flow statement, the net change in cash and cash equivalents during the period is calculated. This figure indicates the overall increase or decrease in cash for the specified period. If there is a net increase, it adds to the cash balance; if there is a net decrease, it subtracts from the cash balance.</p><p>It’s important to note that while the cash flow statement is separate from the income statement, there is a connection between the two. The income statement records revenues and expenses on an accrual basis, whereas the cash flow statement focuses on actual cash transactions. Therefore, the net income from the income statement is adjusted for non-cash items, such as depreciation and changes in working capital, to arrive at the cash flow from operating activities in the cash flow statement.</p><p>The cash flow statement is a critical tool for assessing a company’s liquidity, its ability to generate cash, and its financial flexibility. Investors, creditors, and analysts use the cash flow statement to gain insights into a company’s cash flow patterns and evaluate its financial health.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c677985237e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Price to Earning and Price to Book value ratio for beginner]]></title>
            <link>https://medium.com/@vj_jainy/price-to-earning-and-price-to-book-value-ratio-for-beginner-d599ea0fc8d9?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/d599ea0fc8d9</guid>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[equity]]></category>
            <category><![CDATA[key-financial-ratios]]></category>
            <category><![CDATA[market-share]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 09:49:32 GMT</pubDate>
            <atom:updated>2023-07-24T09:49:32.910Z</atom:updated>
            <content:encoded><![CDATA[<h3>PE or Price to Earning Ratio</h3><p>The Price-to-Earnings (P/E) ratio is a financial metric used to assess the relative value of a company’s stock. It is calculated by dividing the current market price of a company’s share by its earnings per share (EPS).</p><p>The formula for calculating the P/E ratio is:</p><p><strong>P/E Ratio = Market Price per Share / Earnings per Share (EPS)</strong></p><p><strong>Interpretation:</strong> The P/E ratio indicates how much investors are willing to pay for each dollar of a company’s earnings. It provides insight into the market’s expectations for a company’s future growth prospects.</p><ol><li><strong>High P/E Ratio:</strong> A high P/E ratio suggests that investors are willing to pay more for each dollar of the company’s earnings, which may indicate high expectations for future growth. It could mean the stock is relatively expensive or overvalued.</li><li><strong>Low P/E Ratio:</strong> A low P/E ratio suggests that investors are paying less for each dollar of the company’s earnings, which may indicate lower growth expectations or undervaluation. It could mean the stock is relatively cheap.</li></ol><p>The P/E ratio is commonly used to compare companies within the same industry or sector. A higher P/E ratio doesn’t necessarily mean a better investment, as it depends on various factors such as the company’s growth prospects, risk, and profitability.</p><p>It’s important to note that the P/E ratio has its limitations, and investors should consider other financial metrics and factors before making investment decisions. The P/E ratio is just one tool among many that investors use to evaluate a company’s potential and value its stock.</p><h3>PB or Price to Book Value Ratio</h3><p>The Price-to-Book (P/B) ratio is a financial metric used to evaluate the relative value of a company’s stock in relation to its book value. It compares the market price per share to the company’s book value per share.</p><p>Formula for P/B Ratio:</p><p><strong>P/B Ratio = Market Price per Share / Book Value per Share</strong></p><p><strong>Interpretation:</strong> The P/B ratio reflects how much investors are willing to pay for each dollar of the company’s net assets (book value). It provides insights into whether a stock is overvalued or undervalued based on its balance sheet.</p><ol><li><strong>High P/B Ratio:</strong> A high P/B ratio suggests that investors are paying more for each dollar of the company’s net assets, which may indicate high growth expectations or an overvalued stock.</li><li><strong>Low P/B Ratio:</strong> A low P/B ratio suggests that investors are paying less for each dollar of the company’s net assets, which may indicate lower growth expectations or an undervalued stock.</li></ol><p>The book value represents the company’s assets minus its liabilities, as shown in its balance sheet. It provides an accounting-based view of the company’s net worth.</p><p>Just like any financial metric, the P/B ratio should not be used in isolation. It is essential to consider other factors, such as the company’s profitability, growth prospects, and industry conditions, when making investment decisions.</p><p>A low P/B ratio might be attractive to value investors looking for potentially undervalued stocks, while a high P/B ratio might appeal to growth investors who believe in the company’s future prospects. As with any investment tool, context and careful analysis are necessary for a comprehensive understanding of a company’s valuation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d599ea0fc8d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stock Market For Beginner]]></title>
            <link>https://medium.com/@vj_jainy/stock-market-for-beginner-f21d5b323e10?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/f21d5b323e10</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[market-share]]></category>
            <category><![CDATA[investment]]></category>
            <category><![CDATA[equity]]></category>
            <category><![CDATA[stock-market]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 07:25:34 GMT</pubDate>
            <atom:updated>2023-07-24T07:25:34.152Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>What is the Stock Market?</strong></h3><p>The stock market is a place where you can buy and sell shares of ownership in publicly traded companies. When a company goes public, it divides its ownership into many equal parts called shares. These shares are then bought and sold on stock exchanges like the New York Stock Exchange (NYSE) or NASDAQ.</p><h3>How Does It Work?</h3><p>Imagine a stock exchange as a marketplace where buyers and sellers meet to trade shares. When you want to buy shares of a company, you place an order through a broker (online or traditional). The broker acts as a middleman, executing the trade on your behalf.</p><p>The stock’s price is determined by supply and demand. If many people want to buy a particular stock (high demand), its price will go up. Conversely, if more people want to sell the stock (high supply), its price will go down.</p><h3>Why Do Companies Sell Stocks?</h3><p>Companies sell stocks to raise capital for various purposes, such as expanding their business, funding research and development, or paying off debts. By buying shares, investors become partial owners of the company and have a stake in its success.</p><h3>How Do I Make Money from Stocks?</h3><p>There are two main ways to make money from stocks:</p><ol><li><strong>Capital Appreciation</strong>: If you buy shares at a certain price and the stock price increases over time, you can sell your shares at a higher price than what you paid, making a profit.</li><li><strong>Dividends:</strong> Some companies distribute a portion of their profits to shareholders in the form of dividends. If you own shares of a dividend-paying company, you’ll receive regular payments based on the number of shares you own.</li></ol><h3>Risks Involved:</h3><p>While the stock market offers opportunities for growth, it also comes with risks:</p><ol><li><strong>Volatility</strong>: Stock prices can fluctuate significantly over short periods, which may lead to gains or losses.</li><li><strong>Market </strong>Risk: Overall market conditions can impact stock prices. Economic factors, political events, or global events can influence the market.</li><li><strong>Company-Specific Risk</strong>: The performance of an individual company can affect its stock price. Factors like management changes or competitive pressures can influence the company’s value.</li></ol><h3>Diversification:</h3><p>One way to manage risk is through diversification. Instead of investing all your money in a single stock, you can spread it across multiple stocks and even different asset classes (like bonds or real estate).</p><h3>Long-Term Perspective:</h3><p>Investing in the stock market is typically more suitable for long-term goals. Short-term fluctuations are common, but historically, the market tends to grow over extended periods.</p><h3>Important Tips:</h3><ol><li><strong>Do Your Research:</strong> Before investing in a company, research its financial health, performance, and future prospects.</li><li><strong>Start Small: </strong>Begin with a small amount you can afford to invest. Avoid investing money you might need in the short term.</li><li><strong>Stay Informed</strong>: Keep track of financial news and market trends, but avoid making impulsive decisions based on emotions.</li><li><strong>Consider Professional Advice</strong>: If you’re unsure or have significant amounts to invest, consult a financial advisor.</li></ol><p>Remember, investing in the stock market involves risks, and there are no guarantees of profits. But with careful research and a long-term approach, it can be a powerful tool for building wealth and achieving financial goals.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f21d5b323e10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An investigation on credit card fraud detection using machine learning]]></title>
            <link>https://medium.com/analytics-vidhya/an-investigation-on-credit-card-fraud-detection-using-machine-learning-eacdd2d5cb?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/eacdd2d5cb</guid>
            <category><![CDATA[unbalanced-data]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[credit-card-fraud]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[imblearn]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Mon, 11 Jan 2021 17:02:16 GMT</pubDate>
            <atom:updated>2021-01-11T17:02:16.418Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we will analyze how various machine learning algorithms perform on balance and unbalance dataset by taking example of credit card fraud detection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YbA2bcbcMNmUzifIA4-nKw.jpeg" /><figcaption>Credit card fraud detection using machine learning</figcaption></figure><h3>INTRODUCTION</h3><p>In the past few years machine learning has played a crucial role in resolving various problems of the businesses like spam detection, recommendation, object detection etc. Fraud detection has been a painful task for the banking, medical, and commerce industry. Hackers and criminals are continuously working on new ways to find loopholes in the system as a result it is becoming more and more difficult for the companies to authenticate their transaction. According to the Fraud Benchmark Report by cyber source 83% American businesses are conducting manual reviews, and on an average basis, they review 29 % of orders manually. India is witnessing a drastic change to online transactions. It was ranked in top 5 countries with respect to credit card fraud and cases related to debit/credit card fraud have surged to 42% in 2017 according to the Hindustan Times. According to RBI data, the number of credit cards rose by a quarter upto 38 million in the last 12 months ending in May, while the number of debit cards jumped 17% to over 925 million in the same period.</p><h3>MOTIVATION</h3><p>There are many problems with manual review in credit card fraud detection like it is costly, time-consuming and lead to high false positives which means denying a normal user for the transaction completely. By analyzing machine learning algorithms in this area, my main job is to reduce human time, computation and effort. Artificial Intelligence helps machines to identify and extend the importance of patterns in place of humans by visualizing and analyzing the data on the basis of dataset provided and taking appropriate action on the basis of feature set in a short duration of time. Traditional approaches like rule based and traditional approaches have failed due to increase in data and more variation in types of transaction. Also one of the drawback is that due to high false positive rate it leads to loss of legitimate customers and high unbalance dataset is still a matter of concern and also a wide area of research in machine learning.</p><h3>OBJECTIVE</h3><p>The aim of this work is to study and analyze how machine learning algorithms like boosting and ensembling along with data balancing algorithms like smote, adasyn and allknn perform on fraud detection problems on unbalance and balance datasets.</p><h3>DATASET DESCRIPTION</h3><p>The dataset contains 284,807 transactions among which there are 492 i.e., 0.172% transactions are fraudulent transactions. It also contains transactions made by a cardholder in 2 days in month of september 2013 This dataset is highly unbalanced. Due to security reasons, most of the features in the dataset are transformed using principal component analysis (PCA). V1, V2, V3,…, V28 are PCA applied features and rest features include ‘time’, ‘amount’ and ‘class’ are non-PCA applied features.</p><h3>METRICS USED</h3><ul><li>Accuracy = TP + TN / TP + TN + FP + FN</li><li>Precision = TP / TP + FP</li><li>Recall = TP / TP + FN</li><li>F1score = 2 * precision * recall / precision + recall</li><li>Mcc = TP * TN — FP * FN / sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN))</li><li>Roc = Area under curve between false positive rate and true positive rate</li></ul><h3>RESULTS</h3><p>The results of the investigation can be viewed here:</p><p><a href="https://github.com/jainyk/An-investigation-on-credit-card-fraud-detection#results">jainyk/An-investigation-on-credit-card-fraud-detection</a></p><h3>CONCLUSION</h3><p>The overall project discusses the problem of credit card fraud detection and how machine learning can be used to deal with it. As stated in methodology various machine learning algorithms are compared on the basis on accuracy, precision, recall, f1score, roc and mcc. During the study while comparing various metrics for various machine learning it was found that highest accuracy was observed for xgboost using allknn, highest recall was observed for logistic regression with minmaxscaler [23] using allknn, highest precision and f1-score was observed for xgboost using allknn, highest roc and mcc score was observed for logistic regression using smote. Some results were quite an anomaly when compared to others like overall minmaxscaler doesn’t improve the model performance instead it showed down tread when used with logistic regression in terms of smote and adasyn it shown negative mcc score, value of zero for precision, recall, f1score when used with smote. On further observation true positive was found to be zero for logistic regression with smote and adasyn, true negative and false negative for logistic regression with minmaxscaler and logistic regression with minmaxscaler along with allknn is found to be 0. During analysis ’V14’ is found to be the most dominating feature when smote and adasyn are used as data balancing algorithm, also both of them are oversampling method, ’V17’ is found to be the most dominating feature when no data balancing algorithm is used. Most variation was observed in case of allknn as data balancing algorithm.</p><p>For any query please leave a comment below. Any further suggestions are welcomed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eacdd2d5cb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/an-investigation-on-credit-card-fraud-detection-using-machine-learning-eacdd2d5cb">An investigation on credit card fraud detection using machine learning</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Email Extraction using Python with some filters]]></title>
            <link>https://medium.com/analytics-vidhya/email-extraction-using-python-with-some-filters-233ae451f011?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/233ae451f011</guid>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[email]]></category>
            <category><![CDATA[email-extraction]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 04:14:23 GMT</pubDate>
            <atom:updated>2020-09-30T00:07:09.035Z</atom:updated>
            <content:encoded><![CDATA[<p>This article introduces concept of how to extract emails from given gmail by providing username and password. Now this script extracts mail from gmail server but you can generalize this script by looking at other mail server that imap provides by visiting <a href="https://www.systoolsgroup.com/imap/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*H2Wfwn9axtIQZogB3T6RCg.png" /></figure><p>We will be using following libraries:</p><ol><li>imaplib</li><li>email</li><li>os</li><li>datetime</li></ol><p>Make sure to allow less secure apps by checking <a href="https://myaccount.google.com/lesssecureapps?pli=1">here</a>.</p><p>I have introduced 4 filters namely:</p><ol><li>getInfoAll — this will save all the information from the specified folder (‘inbox’ in our case).</li><li>getInfoDate — this will save all the information from the specified folder (‘inbox’ in our case) from the date that we specify.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k2XJGPDEPKgzMWY5ZMhObg.png" /></figure><p>3. getInfoFrom — this will save all the information from the specified folder (‘inbox’ in our case) from the sender gmail that we specify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9v4gbhVyE4gcf_38sIXEww.png" /></figure><p>4. getInfoDateSender — this will save all the information from the specified folder (‘inbox’ in our case) from the sender gmail and date we specify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWtYFO_P371N7EDR-3Vl-Q.png" /></figure><p>Feel free to add more of them. Here we have used imap to retrieve information from mail server. Content_disposition helps us to decide whether mail has any attachment attached with it. Content_type is used to know content type of the mail like text/plain or html.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72sJNHEFIYMRmYQgr1vAwA.png" /></figure><p>In order to understand this I highly recommend to open a mail with some attachment with it in “show original option” in gmail. os.getcwd() is used to return current working directory or you can specify specific directory of your choice. I am creating “exceed+counter” as name of directory if subject length is more than 30, you can go with any other method. I have defined “textfile.txt” for all mails to download all information except the attachment about mail. In each text file i am saving following information — [to, from, date, subject, body]. You can add more info according to your requirements.</p><p>In order to visit to extract folder other than “inbox”, use mail.list() to explore other folders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6kLKG2-PPLswqEj14PLug.png" /></figure><p>#NOTE: While using subject name of the mail as directory to download the information be sure to check the length of the path since windows has some limit on the path length.</p><p>#NOTE: Be sure to check encoding type that your system support and modify that accordingly.</p><p>#UPDATE: You can also permit only some specific file formats to download by using mimetype module. Below we have allowed only pdf, jpg, png and doc file. You can modify according to your own requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*rUXOhL2t1E1fypC6-acDQg.png" /><figcaption>permitting only specific format to download</figcaption></figure><p>For code details visit <a href="https://github.com/jainyk/Email-extraction-along-with-some-filters-using-python">here</a>. And for any suggestion and improvements make a pull request or comment below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=233ae451f011" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/email-extraction-using-python-with-some-filters-233ae451f011">Email Extraction using Python with some filters</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anomaly Detection using Angle-based techniques]]></title>
            <link>https://medium.com/analytics-vidhya/anomaly-detection-using-angle-based-techniques-5d8db8500d14?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d8db8500d14</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[anomaly-detection]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Sun, 22 Mar 2020 19:27:45 GMT</pubDate>
            <atom:updated>2020-03-23T13:10:52.309Z</atom:updated>
            <content:encoded><![CDATA[<p>In our series of anomaly detection another method that we are going to discuss is angle-based techniques.</p><p>Angle based techniques are helpful in anomaly detection for multivariate data. Let’s dive into the intuition behind this technique:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*FaicATYtqJOa1wEIW9O-zw.png" /><figcaption>Orange point represent a normal point</figcaption></figure><p>In the above figure, consider a set of data points in which orange point represent a normal point. For a normal point the angle it makes with any other two data points varies a lot as you choose different data points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*asMKuCOsSDmLA-D0WH0F5A.png" /><figcaption>Green point represent a anomaly point</figcaption></figure><p>Now consider another scenario in which green point represent an anomaly, in this case the angle it makes with with other data points doesn’t vary much as you choose different data points.</p><p>The core idea is anomalies have low variance as compared to normal points which have high variance.</p><p>We will follow the following steps to implement the above algorithm:</p><ol><li>For each data point, determine the angle it makes with all pairs of other data points.</li><li>Calculate the variance of this angle.</li><li>Points for which the variance is below predetermined threshold are anomalies.</li></ol><p>Let’s dive into the coding part:</p><p>Note: Here our focus is the algorithm and not the data, we won’t carry out a test/train split. Instead, we will use simulated data where we know the anomalies and see how well the algorithm performs.</p><p>DATA: We start by creating the data, which will be a combination of normal points and anomalies. Each set of points (normal and anomaly) is generated from a 2D Gaussian distribution where we specify the mean in each dimension as well as the covariance matrix. We choose the normal data to be 100 points tightly clumped together, while the anomalies are 10 points that are further away and spread out more broadly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0PlrY5NDp1vheHbODNYnPQ.png" /></figure><p>Let’s plot the data and color code normal vs. anomaly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jnabEbx-bAzTQf4orsrzA.png" /></figure><p>Algorithm: We will implement a true angle-based algorithm. That is, we calculate the actual angles for each set of three points in the data.</p><p>We will start by constructing the two key functions for the angle-based anomaly detection algorithm. The first function, <em>angle</em>, calculates the angle between three points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kokoq_wpP3NPZvSuM-NBfg.png" /></figure><p>The second function, <em>eval_angle_point</em>, takes two inputs: a point and data (a collection of points). This function returns a list of angles that the input point makes with all pairs of points in the input data. It uses <em>angle</em> of the angle calculation.</p><p>A simple loop through all pairs of points in the data is insufficient because we must make sure the three points lead to well-determined angles without repetition. To be more specific, if we choose point A and then are considering two points in the data B (second point) and C (third point), we want to make sure that the following conditions hold:</p><ol><li>Point B is different from A</li><li>Point C is different from A and B</li><li>We don’t calculate the same angle twice. That is, if we calculate the angle between vectors AB and AC (where B is the second point and C is the third point), we don’t repeat the calculation with vectors AC and AB (where C is the second point and B is the third point)</li></ol><p>The <em>if</em> statements in <em>eval_angle_point</em> ensure the three conditions hold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4U7zb6vvnu-qYZlrm0znLQ.png" /></figure><p>Now we use <em>eval_angle_point</em> with one point from the normal data and another from the anomaly data to illustrate the claim we made above: anomalies have lower angle variance than normal points.</p><p>Choose a normal point and an anomaly at random and plot the angles made for 100 pairs of points in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qA37RSUEcakIlpk03NSWxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*92vVO2niWwYOyLLTfEZkwA.png" /></figure><p>This two point comparison looks promising, but is not statistically meaningful.</p><p>Let’s calculate the angle variance for all the anomaly data. We will label the anomalies with type ‘0’ so we can compare them with the normal data (type ‘1’) below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E50P8SwJWEH-1a459tgg0w.png" /></figure><p>Let’s have a look at the first ten entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ab0rkCakqD-KuVZR9sJDMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQjpo6K_y_6deRKsPEte1Q.png" /></figure><p>This is a little disconcerting. The angle variance for many of the anomalies is quite high — higher even than the variance of the normal point we considered above. To complete our analysis, we also need the variance for the normal data, which we calculate below (labeling normal data as type ‘1’).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZwNc2hjAYOoufgPna6aqZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5oMuImboOFfjOWF1K1RpBA.png" /></figure><p>If we notice carefully there is a significant time difference between calculation of time taken to calculate the angle variance for normal data and anomaly data.</p><p>So the question arises why is the calculation for *normal_data* relatively slow?</p><p>The answer lies in the complexity of the algorithm which turns out to be O(N^3) where N is the number of points.</p><p>EXPLANATION: To see this, think about how an angle is calculated. We need three points, and they should all be different. There are N ways to choose the first point, N−1 ways to choose the second one and N−2 to choose the third. Swapping the second and third points gives the same angle, so the overall complexity is</p><p>N∗(N−1)∗(N−2)/2=O(N^3).</p><p>Note that here we’ve split the algorithm into two parts: <em>eval_angle_point</em> calculates all angles for a given point [complexity O(N^2)] and then the final loops above (for <em>df_anomaly</em> and <em>df_normal</em>) go through all points [complexity O(N)]</p><p>Going from 10 points for the anomalies to 100 points of normal data, increases the run-time by about a factor of 10³=1000, which leads to a noticeable slowdown. Angle-based anomaly detection is slow.</p><p>Now let’s combine the two dataframes for the anomalies and the normal points and sort them in ascending order by angle variance. If our anomaly detection algorithm is perfect, then the first ten entries should all be anomalies (type 0).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VD8fFUoylz1-KtPiksNN0Q.png" /></figure><p>Oops! We find only five of the ten anomalies and the two points with the lowest variance belong to the normal data. Clearly our algorithm needs some work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*Oi_mqUe2iY2jybkT-X_66w.png" /></figure><p>This was the formula that we used earlier to calculate the angle, we found that angle is a good metric in principle but it doesn’t always work well in practice.</p><p>Hence other angle-like metrics have been devised. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*xKTWE_vbUWUlbYDAM5al3g.png" /></figure><p>While ψ is often referred to as angle, it isn’t a true angle. The square powers in the denominator, introduces a distance-dependence in this metric.</p><p>So now let’s update the formula and see the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Db04DcVYb-lVWDbuU1_SkA.png" /></figure><p>Rest of the code remains the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UexE0SYCXTJtfe8QIfDgAA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*k2mkRNyzCeUihPni4kFPRg.png" /></figure><p>As we can observe below the difference between the variance in angle of normal and anomaly point is more noticeable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-mRMW9eRW9MO-ZruKIOPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAdkyuIJS0oHyrfsSHF5fw.png" /></figure><p>As we can observe below the angle variance of anomaly points is less than before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*ZA-arKtFdx2wQRre9scCnw.png" /></figure><p>Similarly compute angle variance for normal points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z3h9a2KLCEUAZEDlkKqK7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*RTMrjuJF5Uv5h9wUgx4OfQ.png" /></figure><p>Now combining the two dataframes for the anomalies and the normal points and sort them in ascending order by angle variance. If our anomaly detection algorithm is perfect, then the first ten entries should all be anomalies (type 0).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oe6ZuPZGhjkNNxyVsRbUUQ.png" /></figure><p>And this time it works much better than before.</p><p>Codes used in this article can be found below on github:</p><p><a href="https://github.com/jainyk/Anomaly-detection/tree/master/Angle%20based%20techniques">jainyk/Anomaly-detection</a></p><p>For any query please leave a comment below. Any further suggestions are welcomed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d8db8500d14" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/anomaly-detection-using-angle-based-techniques-5d8db8500d14">Anomaly Detection using Angle-based techniques</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anomaly detection by Modified Z-Score]]></title>
            <link>https://medium.com/analytics-vidhya/anomaly-detection-by-modified-z-score-f8ad6be62bac?source=rss-4634cd4d2e45------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8ad6be62bac</guid>
            <category><![CDATA[z-score]]></category>
            <category><![CDATA[anomaly-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[modified-zscore]]></category>
            <dc:creator><![CDATA[Vishal jain]]></dc:creator>
            <pubDate>Tue, 25 Feb 2020 15:39:35 GMT</pubDate>
            <atom:updated>2024-03-15T05:23:57.251Z</atom:updated>
            <content:encoded><![CDATA[<h3>Anomaly detection by Z-Score and Modified Z-Score</h3><p><strong><em>This is an introduction on how to use Z-score and modified Z-score as an anomaly detection.</em></strong></p><p>First let us have a brief introduction to z-score and why we actually need modified z-score.</p><p>z-score is a common method for scoring anomalies in 1D data. If the mean and <a href="https://www.analyticsvidhya.com/blog/2021/04/dispersion-of-data-range-iqr-variance-standard-deviation/?utm_source=Backlink&amp;utm_medium=SEO"><strong>standard deviation</strong></a> are known, then for each data point</p><p>we calculate the z-score as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*m41t-zC6FsmQ0vse6BJ4-w.png" /></figure><p>The z-score measures how far a point is away from the mean as signed multiple of the standard deviation and large absolute values of the z-score suggest an anomaly.</p><p>Now let us have a look at a dataset that shows the limitations of z-scores and why the modified z-score can be useful.</p><p>We will look at the number of goals scored by the top goalscorer in every World Cup from 1930 through 2018 (21 competitions in total). The raw data is from here:</p><p><a href="https://en.wikipedia.org/wiki/FIFA_World_Cup_top_goalscorers">FIFA World Cup top goalscorers</a></p><p>The data was cleaned and saved as a CSV. Load it as a dataframe and take a look.</p><p><a href="https://drive.google.com/open?id=1x1yB17eNHEshqI58-t_o-hbjY1tD1nJ7">Meet Google Drive - One place for all your files</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KT0SrCmlsXLexDwwemn69g.png" /></figure><p>We will start by using the z-score to identify anomalies. As we are interested in the superstars, we will have an upper threshold. We choose 𝑧 =+2. Above this z-score, any player will be labeled as an anomaly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*l_ytI8gUktHiW4-xnhPWww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGJMZBWtuRFKqWjwmpvszw.png" /><figcaption>calculating z-score and adding to dataframe</figcaption></figure><p>Now let us define a plotting function to display the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CymBUprRVcVfYRq_eQM92w.png" /></figure><p>Only one player is picked out: Just Fontaine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*suJYjAEMHvI74E-DtlO_HQ.png" /></figure><p>Clearly our analysis is flawed. By looking at the plot, we see that in 12 out of 21 competitions, the top goalscorer(s) scored less than the mean number of goals (7.05).</p><p>So the question arises why is it so?</p><p>The answer is<strong> the mean and standard deviation are themselves susceptible to the presence of anomalies.</strong> With his 13 goals, the amazing Fontaine is raising the mean so much that most players fall below it. As a result, he becomes the only anomaly.</p><p>And because of this the z-score can sometimes be unreliable, since the mean and standard deviation are themselves sensitive to anomalies.</p><p>The <strong>modified z-score</strong> tackles this problem by using <strong>medians</strong> instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*gs5vU3KnY0K0gwayfv825Q.png" /></figure><p><strong>MAD</strong> stands for <strong>m</strong>edian <strong>a</strong>bsolute <strong>d</strong>eviation from the median.</p><p>Hence in case of modified Z-score large absolute values of the modified z-score suggest an anomaly.</p><p>Let’s repeat this analysis with the modified z-score and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lkc98d_mhArxsf0e9LyeBQ.png" /></figure><p>Note here that the median (6.0) is lower than the mean (7.05) as would be expected from the plot.</p><p>Here we are going to make a slight modification and introduce a <strong>consistency</strong> <strong>correction k</strong>, which allows us to use MAD as a consistent estimate for the standard deviation. The value of k depends on the underlying distribution of the data. For simplicity, we will use <strong>k=1.4826</strong>.</p><p>(refer: <a href="https://en.wikipedia.org/wiki/Median_absolute_deviation">https://en.wikipedia.org/wiki/Median_absolute_deviation</a>)</p><p>So the <strong>modified z-score</strong> becomes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*Cp2RDkIeDwazrdjAExyX3w.png" /></figure><p>and this is the form we will use in the function below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QV6TzwmeuuuD86SH3lex2w.png" /></figure><p>As before, compute the modified z-score for all players then plot and list the results. Note that the threshold remains the same at <strong>y=+2</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*MG-0_wvOkjXRykq0F2Df3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jiu61m4uLRQACvMpYG3Jww.png" /></figure><p>Now we find four anomalous players.</p><p>So how does the MAD compare with the standard deviation calculated previously?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nm_ia8oDz3-L_8HEbPGzjQ.png" /></figure><p><strong>k∗MAD</strong> is <strong>1.48</strong>, which is smaller than the <strong>standard deviation (2.05)</strong>. We see that the anomalies have a larger effect on the standard deviation, which depends on the square of the deviation from the mean (MAD depends linearly on the deviation).</p><p>Code used in this article can be found on github:</p><p><a href="https://github.com/jainyk/Anomaly-detection/tree/master/Zscore%20and%20modified%20zscore">jainyk/Anomaly-detection</a></p><p>For any query please leave a comment below. Any further suggestions are welcomed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8ad6be62bac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/anomaly-detection-by-modified-z-score-f8ad6be62bac">Anomaly detection by Modified Z-Score</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>