<?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 JYOTI PRAKASH DEY on Medium]]></title>
        <description><![CDATA[Stories by JYOTI PRAKASH DEY on Medium]]></description>
        <link>https://medium.com/@deyprakash753?source=rss-72f694abfa1e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BMRJyWVa0JZio--waGVN5g@2x.jpeg</url>
            <title>Stories by JYOTI PRAKASH DEY on Medium</title>
            <link>https://medium.com/@deyprakash753?source=rss-72f694abfa1e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:13:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deyprakash753/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[Ways to Learn Data Science When Money’s Tight]]></title>
            <link>https://medium.com/@deyprakash753/ways-to-learn-data-science-when-moneys-tight-126bdd250bcc?source=rss-72f694abfa1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/126bdd250bcc</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[JYOTI PRAKASH DEY]]></dc:creator>
            <pubDate>Mon, 02 Sep 2024 20:22:36 GMT</pubDate>
            <atom:updated>2024-09-03T07:19:12.206Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ways To Learn Data Science When Money’s Tight</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RA7jQ2QhVeE5BOout2nHwA.jpeg" /><figcaption>Image from Pixabay</figcaption></figure><p>So, you’ve got big dreams , but your wallet is lighter than air. No worries! Just because your budget is tighter than a superhero suit doesn’t mean you can’t achieve your goals. I’m here to show you how to master data science without spending a fortune. Grab your favorite cornetos (mine is Jalapeno), and let’s embark on this cost-effective journey.</p><h3>1. Python: The Gateway Drug to Data Science (1–2 Weeks)</h3><p>Before you go swinging around fancy algorithms, you need to get cozy with Python. Think of Python as the chimichanga of programming languages — easy to love and hard to put down. You’ll be using it for everything, so let’s start here.</p><p><strong>Resource:</strong> Hop over to Codecademy’s free Python course or get your hands dirty with freeCodeCamp’s Python tutorials. Both are like that perfect nacho platter — crispy, cheesy, and oh-so-satisfying.</p><p><strong>Time Commitment:</strong> Spend about 1–2 weeks here, diving in for at least an hour a day. It’s like doing push-ups: painful at first, but you’ll thank yourself later when you’re flexing your Python muscles.</p><h3>2. Statistics: The Art of Making Numbers Sexy (2–4 Weeks)</h3><p>Next up, statistics! No, it’s not as boring as it sounds. This is where you learn how to make numbers dance to your tune. Trust me, knowing your way around a mean, median, and mode will make you the life of the data science party.</p><p><strong>Resource:</strong> Join <a href="https://www.khanacademy.org/math/statistics-probability">Khan Academy’s Statistics and Probability course</a> for a free ride into the world of stats. Then level up with DataCamp’s free Introduction to Data Science course.</p><p><strong>Time Commitment:</strong> Spend 2–4 weeks here, one hour a day. Think of it as prepping your gadgets before you go into battle — you don’t want to skip this.</p><h3>3. Pandas: Data Manipulation for the Lazy Genius (2–3 Weeks)</h3><p>Now that you’ve got some basic knowledge, it’s time to wrangle some data. Enter Pandas, the library that’ll make you feel like you’ve got superpowers. It’s like having a butler who organizes your data and brings you your slippers — if your slippers were CSV files.</p><p><strong>Resource:</strong> <a href="https://www.youtube.com/playlist?list=PL5-da3qGB5IA6E6ZNXu_kUsjnYeoP6sAe">Data School’s YouTube playlist on Pandas</a> is where you want to be. It’s free, and the lessons are bite-sized, just like my attention span.</p><p><strong>Time Commitment:</strong> Give it 2–3 weeks of daily practice, about an hour a day. Play with datasets from Kaggle like a cat with a laser pointer.</p><h3>4. Data Visualization: Because a Picture Is Worth a Thousand Cells (2–3 Weeks)</h3><p>Time to make your data look pretty. You’ll need Matplotlib and Seaborn to turn those rows and columns into visual masterpieces. Think of this as your chance to add some pizzazz to your PowerPoints.</p><p><strong>Resource:</strong> Corey Schafer’s YouTube channel is your new best friend. Check out his tutorials on <a href="https://www.youtube.com/watch?v=8Ar5Q9bKmXY">Matplotlib</a> and <a href="https://www.youtube.com/watch?v=GcXcSZ0gQps">Seaborn</a>. He breaks it down so well you’ll feel like you’re getting a pep talk from a seasoned mentor.</p><p><strong>Time Commitment:</strong> 2–3 weeks should do it. Spend an hour a day creating visualizations that make your data pop. Trust me, your future self will thank you.</p><h3>5. Machine Learning: Your First Step Toward World Domination (4–6 Weeks)</h3><p>Alright, you’ve reached the big leagues. Machine learning is where the real fun begins. You’ll be teaching your computer to recognize patterns and make predictions, just like a fortune-teller with a crystal ball — except, you know, it actually works.</p><p><strong>Resource:</strong> <a href="https://www.coursera.org/learn/machine-learning">Andrew Ng’s Machine Learning course on Coursera</a> is a classic. It’s free if you audit it, and it’s packed with enough knowledge to make you feel like Tony Stark in his lab.</p><p><strong>Time Commitment:</strong> Spend 4–6 weeks on this, dedicating an hour (or more, if you’re feeling ambitious) every day. This is your training montage — Rocky had his stairs, you’ve got your algorithms.</p><h3>6. Research Papers on arXiv: Where the Cool Kids Hang Out (Ongoing)</h3><p>Once you’re comfortable with the basics, it’s time to explore the cutting-edge stuff. Head over to <a href="https://arxiv.org/">arXiv</a> and dive into some research papers. These are where the big brains share their latest discoveries. Challenge yourself by trying to replicate their findings — it’s like solving a mystery, but with code instead of a magnifying glass.</p><p><strong>Resource:</strong> Start with machine learning papers that align with what you’ve learned so far. Try to reproduce their results, and maybe, just maybe, you’ll come up with something even cooler.</p><p><strong>Time Commitment:</strong> This is an ongoing adventure. Set aside a few hours a week to explore these papers. It’s like adding extra spice to your chimichangas — optional, but oh-so-rewarding.</p><h3>7. Projects: Where Your Skills Become Superpowers (Ongoing)</h3><p>With all that knowledge, it’s time to get your hands dirty. Real projects are where you’ll transform from a mere mortal into a data science superhero. Plus, they make for excellent portfolio pieces when you’re ready to impress the big shots.</p><p><strong>Resource:</strong> Kaggle is your playground. Whether it’s joining a competition or tackling a project from scratch, this is where you put all that theory into practice. Also, don’t forget to check out <a href="https://github.com/">GitHub</a> for open-source projects that need a hero (that’s you).</p><p><strong>Time Commitment:</strong> Projects are an ongoing thing. Aim to knock out at least one project a month. It’ll take some time, but remember — you’re crafting your origin story here.</p><h3>8. Networking: Because Even Superheroes Need a Team (Ongoing)</h3><p>Last but not least, get out there and network. Even Deadpool needs friends (well, sort of). Join online communities, attend virtual meetups, and keep learning from others in the field. It’s like assembling your own Avengers, except with data scientists instead of demigods.</p><p><strong>Resource:</strong> Hit up <a href="https://www.linkedin.com/">LinkedIn</a>, <a href="https://twitter.com/">Twitter</a>, and <a href="https://www.reddit.com/r/datascience/">Reddit</a> to connect with other data nerds. Also, subscribe to newsletters like <a href="https://dataelixir.com/">Data Elixir</a> to keep your inbox filled with the latest and greatest.</p><p><strong>Time Commitment:</strong> Networking isn’t a one-time thing; it’s part of the journey. Spend some time each week making connections, sharing your work, and learning from others. Who knows — you might just find your next mentor or job opportunity.</p><h3>Conclusion: No Money? No Problem!</h3><p>There you have it — a crash course in learning data science without breaking the bank. Sure, your wallet might be empty, but your brain will be bursting with knowledge. So go out there, start learning, and remember: it’s not about how much cash you have, but how much you’re willing to grind. Now, go make some data magic happen!</p><p>Wow, you really made it all the way to the end? That’s some serious dedication! Whether you’re now a data master or just couldn’t get enough of my charm (I’m blushing), how about dropping a comment below to let me know? It’s quick, painless, and might just give you that extra boost of data karma. Plus, who doesn’t love a little feedback? Go on, make this moment epic!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=126bdd250bcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[14 Seaborn Tricks You Must Know]]></title>
            <link>https://medium.com/@deyprakash753/14-seaborn-tricks-you-must-know-66efb2611ce9?source=rss-72f694abfa1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/66efb2611ce9</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[seaborn]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[JYOTI PRAKASH DEY]]></dc:creator>
            <pubDate>Wed, 28 Aug 2024 10:48:06 GMT</pubDate>
            <atom:updated>2024-08-28T10:48:06.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*Am6psfP8YmJkeL9oZZdHyQ.png" /></figure><p>Alright, buckle up, because I’m about to spill the beans on some Seaborn tricks that’ll make your data visualizations so sharp, they could slice through a chimichanga. Whether you’re wrangling with monstrous datasets, crafting visual stories that’d make even the Mona Lisa crack a smile, or just trying to make your plots pop like a comic book panel, Seaborn’s got your back.</p><p>Born from the loins of Matplotlib (it’s not as weird as it sounds), Seaborn lets you whip up stunning visualizations with the ease of a superhero doing a victory lap. It’s like having a superpower in your coding arsenal — just a few lines, and boom, you’ve got a masterpiece that’s ready to blow minds in both your analysis and presentations. From distributions to relationships to the nitty-gritty of categorical data, Seaborn’s got all the tricks up its spandex sleeves to help you unlock patterns and insights like a data-driven detective.</p><p>But here’s where Seaborn really shines — it doesn’t just help you plot data; it turns you into a storyteller. The kind who weaves data into tales so compelling, even your toughest critic might shed a tear. With its emphasis on style and its smooth-as-butter integration with Pandas, your visualizations won’t just be informative — they’ll be downright mesmerizing.</p><p>So, as we dive into these 14 Seaborn tricks, think of it as gearing up for a mission. How can you make your plots clearer, your code tighter, and your insights deeper? With Seaborn, these superpowers are not just within reach — they’re practically begging to be unleashed. Let’s do this!</p><p><strong>1. Customizing Figure Aesthetics</strong><br>Seaborn makes it easy to customize the look of your plots with themes and palettes using set_theme() and color_palette(). You can choose from a variety of themes or create your own.</p><p><strong>Use Case:</strong> Suppose you want to give your plots a professional look with a dark theme and a specific color palette.</p><pre>import seaborn as sns<br>import matplotlib.pyplot as plt<br><br># Set the dark theme and a custom color palette<br>sns.set_theme(style=&quot;dark&quot;, palette=&quot;muted&quot;)<br><br># Example plot<br>data = sns.load_dataset(&quot;penguins&quot;)<br>sns.histplot(data=data, x=&quot;flipper_length_mm&quot;, hue=&quot;species&quot;)<br>plt.show()</pre><p><strong>2. Pairwise Relationships with </strong><strong>pairplot</strong><br>Seaborn’s pairplot lets you visualize pairwise relationships in a dataset with scatterplots and histograms, making it ideal for understanding correlations and distributions.</p><p><strong>Use Case:</strong> Analyzing relationships between different features of the Iris dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>iris = sns.load_dataset(&quot;iris&quot;)<br><br># Plot pairwise relationships<br>sns.pairplot(iris, hue=&quot;species&quot;)<br>plt.show()</pre><p><strong>3. Heatmaps with </strong><strong>heatmap</strong><br>The heatmap function is perfect for visualizing matrices, correlations, and other grid-like data structures with color encoding.</p><p><strong>Use Case:</strong> Visualizing the correlation matrix of the Titanic dataset.</p><pre>import seaborn as sns<br>import matplotlib.pyplot as plt<br><br># Load the dataset<br>titanic = sns.load_dataset(&quot;titanic&quot;)<br><br># Compute the correlation matrix<br>corr = titanic.corr()<br><br># Create a heatmap<br>sns.heatmap(corr, annot=True, cmap=&quot;coolwarm&quot;)<br>plt.show()</pre><p><strong>4. Adding Regression Lines with </strong><strong>lmplot</strong><br>lmplot allows you to fit and visualize a linear regression model, making it easy to analyze relationships between variables.</p><p><strong>Use Case:</strong> Investigating the relationship between total_bill and tip amounts in the tips dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>tips = sns.load_dataset(&quot;tips&quot;)<br><br># Create a linear model plot<br>sns.lmplot(x=&quot;total_bill&quot;, y=&quot;tip&quot;, data=tips)<br>plt.show()</pre><p><strong>5. Visualizing Categorical Data with </strong><strong>catplot</strong><br>Seaborn’s catplot is versatile for visualizing categorical data, supporting various kinds of plots such as box plots, bar plots, and strip plots.</p><p><strong>Use Case:</strong> Comparing the distribution of total bills by day of the week in the tips dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>tips = sns.load_dataset(&quot;tips&quot;)<br><br># Create a categorical plot<br>sns.catplot(x=&quot;day&quot;, y=&quot;total_bill&quot;, kind=&quot;box&quot;, data=tips)<br>plt.show()</pre><p><strong>6. Highlighting Specific Data with </strong><strong>FacetGrid</strong><br>FacetGrid allows you to create multi-plot grids based on subsets of your data, making it ideal for segmenting data by categories.</p><p><strong>Use Case:</strong> Creating a grid of plots to compare the distribution of flipper lengths across different species of penguins.</p><pre>import seaborn as sns<br><br># Load the dataset<br>penguins = sns.load_dataset(&quot;penguins&quot;)<br><br># Create a grid of plots<br>g = sns.FacetGrid(penguins, col=&quot;species&quot;)<br>g.map(sns.histplot, &quot;flipper_length_mm&quot;)<br>plt.show()</pre><p><strong>7. Visualizing Distributions with </strong><strong>distplot and </strong><strong>histplot</strong><br>distplot (deprecated, use histplot and kdeplot) combines a histogram with a kernel density estimate, giving a clear picture of the data distribution.</p><p><strong>Use Case:</strong> Visualizing the distribution of petal lengths in the Iris dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>iris = sns.load_dataset(&quot;iris&quot;)<br><br># Create a distribution plot<br>sns.histplot(iris[&#39;petal_length&#39;], kde=True)<br>plt.show()</pre><p><strong>8. Working with Time Series Data using </strong><strong>lineplot</strong><br>The lineplot function is perfect for visualizing time series data, capturing trends and patterns over time.</p><p><strong>Use Case:</strong> Plotting the average monthly temperature over time.</p><pre>import seaborn as sns<br>import pandas as pd<br><br># Create a time series data<br>data = pd.DataFrame({<br>    &#39;month&#39;: pd.date_range(start=&#39;2021-01&#39;, periods=12, freq=&#39;M&#39;),<br>    &#39;temperature&#39;: [5, 7, 9, 13, 16, 20, 23, 22, 19, 14, 10, 6]<br>})<br><br># Create a line plot<br>sns.lineplot(x=&quot;month&quot;, y=&quot;temperature&quot;, data=data)<br>plt.show()</pre><p><strong>9. Combining Plots with </strong><strong>jointplot</strong><br>jointplot lets you visualize the relationship between two variables along with their marginal distributions.</p><p><strong>Use Case:</strong> Exploring the relationship between petal length and petal width in the Iris dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>iris = sns.load_dataset(&quot;iris&quot;)<br><br># Create a joint plot<br>sns.jointplot(x=&quot;petal_length&quot;, y=&quot;petal_width&quot;, data=iris, kind=&quot;scatter&quot;)<br>plt.show()</pre><p><strong>10. Enhancing Box Plots with </strong><strong>violinplot</strong><br>The violinplot function combines box plots with KDE plots, giving a more detailed view of the distribution.</p><p><strong>Use Case:</strong> Comparing the distribution of total bills across different days in the tips dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>tips = sns.load_dataset(&quot;tips&quot;)<br><br># Create a violin plot<br>sns.violinplot(x=&quot;day&quot;, y=&quot;total_bill&quot;, data=tips)<br>plt.show()</pre><p><strong>11. Customizing Legends with </strong><strong>legend</strong><br>Seaborn allows you to easily customize legends to make your plots more informative and aesthetically pleasing.</p><p><strong>Use Case:</strong> Customizing the legend in a scatter plot of petal lengths and widths.</p><pre>import seaborn as sns<br><br># Load the dataset<br>iris = sns.load_dataset(&quot;iris&quot;)<br><br># Create a scatter plot with a customized legend<br>sns.scatterplot(x=&quot;petal_length&quot;, y=&quot;petal_width&quot;, hue=&quot;species&quot;, data=iris)<br>plt.legend(title=&quot;Iris Species&quot;, loc=&quot;upper left&quot;)<br>plt.show()</pre><p><strong>12. Data Wrangling with </strong><strong>barplot</strong><br>The barplot function can handle grouped data and calculate summary statistics on the fly, making it great for quick comparisons.</p><p><strong>Use Case:</strong> Comparing the average total bills by day of the week.</p><pre>import seaborn as sns<br><br># Load the dataset<br>tips = sns.load_dataset(&quot;tips&quot;)<br><br># Create a bar plot<br>sns.barplot(x=&quot;day&quot;, y=&quot;total_bill&quot;, data=tips, estimator=sum)<br>plt.show()</pre><p><strong>13. Visualizing the Entire DataFrame with </strong><strong>pairplot</strong><br>pairplot makes it easy to explore the relationships between all the numerical variables in your dataset, giving a comprehensive view of pairwise correlations.</p><p><strong>Use Case:</strong> Exploring relationships in the Titanic dataset.</p><pre>import seaborn as sns<br><br># Load the dataset<br>titanic = sns.load_dataset(&quot;titanic&quot;)<br><br># Create a pair plot<br>sns.pairplot(titanic.dropna())<br>plt.show()</pre><p><strong>14. Adjusting Subplots with </strong><strong>subplots_adjust</strong><br>Sometimes, default subplot settings can lead to overlapping plots. You can use subplots_adjust to fine-tune spacing.</p><p><strong>Use Case:</strong> Adjusting subplot spacing in a grid of plots to avoid overlaps.</p><pre>import seaborn as sns<br>import matplotlib.pyplot as plt<br><br># Load the dataset<br>iris = sns.load_dataset(&quot;iris&quot;)<br><br># Create a grid of plots<br>sns.pairplot(iris, hue=&quot;species&quot;)<br><br># Adjust subplot spacing<br>plt.subplots_adjust(top=0.9)<br>plt.show()</pre><p>So, you made it to the end, huh? Scrolled all the way through? Impressive! You must be a data ninja or just really like me (I’m flattered). Either way, now that your Seaborn game is stronger than a superhero’s abs, how about dropping a tiny comment below to show some love? I promise it won’t hurt — well, unless you’re fighting crime while typing, in which case, maybe just use your good hand. Go on, make my day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66efb2611ce9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[14 NumPy Tricks You Must Know]]></title>
            <link>https://medium.com/@deyprakash753/14-numpy-tricks-you-must-know-925921f1b868?source=rss-72f694abfa1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/925921f1b868</guid>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[numpy-array]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[JYOTI PRAKASH DEY]]></dc:creator>
            <pubDate>Sat, 24 Aug 2024 19:32:22 GMT</pubDate>
            <atom:updated>2024-08-24T19:32:22.146Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*RY96IbeNH41iTggMlfjI4A.jpeg" /></figure><p>In this blog, I’ll share some NumPy techniques that have become essential in my daily work, dramatically improving my efficiency.</p><p>Consider the challenge of working with massive datasets — whether it’s simulating physical systems, analyzing high-dimensional data, or processing images. How would you approach these tasks? Traditional tools may falter, but when you need something more powerful, flexible, and intuitive, NumPy is the answer.</p><p>NumPy, short for Numerical Python, is an open-source library that’s a cornerstone of scientific computing in Python. It enables you to work with large arrays and matrices, perform vectorized operations, and apply advanced mathematical functions — all with remarkable speed and ease. Whether you’re performing element-wise operations, linear algebra, or statistical analysis, NumPy offers a robust toolkit that transforms how you approach numerical problems.</p><p>But what truly sets NumPy apart is its ability to simplify and accelerate complex computations. With NumPy, you’re not just crunching numbers — you’re rethinking how data is processed and analyzed. The library’s design encourages a more intuitive understanding of numerical data, turning abstract concepts like broadcasting and vectorization into powerful tools that can reshape your workflows.</p><p>With NumPy, you’re not merely handling data — you’re unlocking new ways to interpret and manipulate it, uncovering insights that might otherwise remain hidden. What efficiencies can be gained by optimizing operations? How can you harness the power of arrays to solve real-world problems? With NumPy, these possibilities are not just theoretical but practical and within reach.</p><p>Here are the 14 NumPy tricks and their use cases:</p><h3>1. Efficient Array Creation</h3><p>This feature allows you to quickly generate arrays with specified ranges, shapes, and intervals using functions like np.arange, np.linspace, and np.zeros.</p><p><strong>Use Case:</strong> Suppose you want to plan your daily schedule with time slots every hour. You can generate an array of hours from 8 AM to 5 PM.</p><pre>import numpy as np<br><br># Generate an array of time slots from 8 AM to 5 PM<br>time_slots = np.arange(8, 18)  # [8, 9, 10, ..., 17]</pre><h3>2. Broadcasting</h3><p>Broadcasting allows you to perform operations on arrays of different shapes by automatically expanding the smaller array to match the shape of the larger one.</p><p><strong>Use Case:</strong> Imagine you’re preparing a shopping list and need to calculate the total cost for multiple items with different quantities. Broadcasting lets you apply a single price to multiple quantities without looping.</p><pre>prices = np.array([10, 15, 20])<br>quantities = np.array([2, 3, 5])<br><br># Calculate the total cost for each item<br>total_cost = prices * quantities  # [20, 45, 100]</pre><h3>3. Fancy Indexing</h3><p>Fancy indexing enables you to select specific elements from an array based on indices or conditions.</p><p><strong>Use Case:</strong> If you’re organizing a family gathering, and you have a list of ages, you can easily pick out who qualifies as an adult (age 18 or older).</p><pre>ages = np.array([12, 19, 25, 17, 30])<br>adults = ages[ages &gt;= 18]  # [19, 25, 30]</pre><h3>4. Vectorization</h3><p>Vectorization allows you to apply operations on entire arrays without needing explicit loops.</p><p><strong>Use Case:</strong> If you’re adjusting the volume of several music tracks by increasing each by 10%, vectorization lets you apply this change to all tracks simultaneously.</p><pre>volumes = np.array([0.5, 0.7, 0.9])<br><br># Increase each volume by 10%<br>adjusted_volumes = volumes * 1.1  # [0.55, 0.77, 0.99]</pre><h3>5. Reshaping Arrays</h3><p>Reshaping changes the shape of an array without altering its data.</p><p><strong>Use Case:</strong> When organizing photos in a grid layout, you can reshape a list of photo IDs into a 2D array representing the grid.</p><pre>photos = np.arange(1, 10)<br><br># Reshape the list into a 3x3 grid<br>photo_grid = photos.reshape(3, 3)</pre><h3>6. Aggregating Data</h3><p>Aggregation functions like np.sum, np.mean, and np.median allow you to summarize and derive statistics from your data.</p><p><strong>Use Case:</strong> If you’re tracking your daily steps for a week, you can easily calculate the total steps taken.</p><pre>steps = np.array([4000, 5000, 7000, 8000, 4500, 6000, 7500])<br><br># Calculate total steps<br>total_steps = np.sum(steps)  # 42000</pre><h3>7. Concatenating and Splitting Arrays</h3><p>Concatenation and splitting allow you to combine multiple arrays into one or divide one array into multiple parts.</p><p><strong>Use Case:</strong> If you have two playlists and want to combine them into one, you can concatenate the arrays of song IDs.</p><pre>playlist1 = np.array([1, 2, 3])<br>playlist2 = np.array([4, 5, 6])<br><br># Combine the two playlists<br>combined_playlist = np.concatenate((playlist1, playlist2))</pre><h3>8. Sorting and Searching</h3><p>Sorting and searching functions allow you to organize your arrays and find elements quickly.</p><p><strong>Use Case:</strong> If you want to sort your favorite movie ratings from highest to lowest, you can easily sort the array of ratings.</p><pre>ratings = np.array([4.5, 3.0, 5.0, 4.0])<br><br># Sort ratings in descending order<br>sorted_ratings = np.sort(ratings)[::-1]  # [5.0, 4.5, 4.0, 3.0]</pre><h3>9. Handling Missing Data</h3><p>Handling missing data involves identifying and managing NaN (Not a Number) values in your datasets.</p><p><strong>Use Case:</strong> If you’re keeping track of your expenses, and you missed recording a few days, you can fill those missing entries with a placeholder like 0.</p><pre>expenses = np.array([150.0, np.nan, 200.0, np.nan, 250.0])<br><br># Replace NaN values with zero<br>cleaned_expenses = np.nan_to_num(expenses, nan=0.0)</pre><h3>10. Saving and Loading Data</h3><p>This feature allows you to save NumPy arrays to disk and load them later.</p><p><strong>Use Case:</strong> If you’re working on a large recipe list and want to save your work, you can save the array of ingredients to a file and load it later to continue.</p><pre>ingredients = np.array([&#39;flour&#39;, &#39;sugar&#39;, &#39;eggs&#39;])<br><br># Save the array to a file<br>np.save(&#39;ingredients.npy&#39;, ingredients)<br><br># Load the array from the file<br>loaded_ingredients = np.load(&#39;ingredients.npy&#39;)</pre><h3>11. Random Number Generation</h3><p>NumPy provides various functions to generate random numbers, which are useful for simulations or initializing random states.</p><p><strong>Use Case:</strong> If you’re planning a game night and need to randomly assign teams, you can generate random numbers to divide the group.</p><pre># Generate random team assignments for 6 players<br>teams = np.random.randint(1, 3, size=6)  # Example: [1, 2, 1, 2, 1, 2]</pre><h3>12. Linear Algebra Operations</h3><p>NumPy’s linear algebra functions allow you to perform complex matrix operations.</p><p><strong>Use Case:</strong> If you’re calculating your home loan payments based on different interest rates, you can use linear algebra to solve for the payments.</p><pre>matrix = np.array([[1, 2], [3, 4]])<br><br># Compute the inverse of the matrix<br>inverse_matrix = np.linalg.inv(matrix)</pre><h3>13. Advanced Indexing</h3><p>Advanced indexing lets you access and modify array elements in sophisticated ways.</p><p><strong>Use Case:</strong> If you’re rearranging your grocery list based on priority, advanced indexing allows you to move items around quickly.</p><pre>grocery_list = np.array([&#39;apples&#39;, &#39;bananas&#39;, &#39;carrots&#39;])<br><br># Rearrange items in priority order<br>priority_list = grocery_list[[2, 0, 1]]  # [&#39;carrots&#39;, &#39;apples&#39;, &#39;bananas&#39;]</pre><h3>14. Element-Wise Operations</h3><p>Element-wise operations allow you to perform arithmetic or logical operations on each element of an array independently.</p><p><strong>Use Case:</strong> If you’re tracking your daily water intake and want to convert it from liters to milliliters, element-wise operations let you easily multiply each value by 1000.</p><pre># Daily water intake in liters<br>water_intake_liters = np.array([1.5, 2.0, 1.8, 2.2])<br><br># Convert liters to milliliters<br>water_intake_milliliters = water_intake_liters * 1000  # [1500, 2000, 1800, 2200]</pre><p>Scrolled all the way? Would love to know your opinion on this blog, leave a small comment to support me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=925921f1b868" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What do Generative Adversarial Networks learn?]]></title>
            <link>https://medium.com/@deyprakash753/what-do-generative-adversarial-networks-learn-a450a0373020?source=rss-72f694abfa1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a450a0373020</guid>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[JYOTI PRAKASH DEY]]></dc:creator>
            <pubDate>Sat, 24 Aug 2024 16:24:21 GMT</pubDate>
            <atom:updated>2024-08-24T16:24:21.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4N05Pn0Zg3TAgbFPfo1ow.jpeg" /><figcaption>from Unsplash</figcaption></figure><p>Generative Adversarial Networks (GANs) have captured the imagination of researchers and developers alike, but what exactly do these networks learn as they churn through data?</p><p>At their core, GANs are about generating data that looks real — convincingly real — but the path they take to get there is anything but straightforward.</p><p>GANs consist of two neural networks locked in a continuous battle: the generator and the discriminator. The generator’s goal is to create data so close to the real thing that the discriminator, whose job is to tell real from fake, is fooled. Over time, this push and pull refine both networks. The generator learns to produce data that closely mimics the original dataset, while the discriminator sharpens its ability to spot the fake.</p><p>But what is the generator truly learning as it transforms random noise into images, or any other type of data? And how does the discriminator improve its ability to differentiate between the generated and the real? These questions lead us to the heart of GANs, where the learning process is about much more than just creating something that looks convincing.</p><h3>Dissecting the Learning Process</h3><p>The beauty of GANs lies in their adversarial setup, which pushes both the generator and the discriminator to improve constantly. But to understand what each network learns, we need to look closely at how they operate and interact.</p><h3>The Generator’s Learning Path</h3><p>The generator begins its journey with no real knowledge of the data it’s trying to replicate. Its initial outputs are essentially random noise, far from anything useful. But through training, it starts to pick up on patterns. Each time it produces an example, the discriminator evaluates it, providing feedback on how close it was to the real data.</p><p>Over many iterations, the generator learns to tweak its outputs incrementally, moving closer to something that could pass as authentic. It’s a process of trial and error, where the generator gradually understands the structure, texture, and overall composition of the data it aims to mimic. By the end of the training, the generator has learned a complex function that maps random noise into data points that are nearly indistinguishable from those in the original dataset.</p><h3>The Discriminator’s Role</h3><p>On the other side of this dynamic, the discriminator is tasked with distinguishing between real and generated data. Initially, it’s relatively easy for the discriminator to spot the fakes, as the generator’s early attempts are often quite poor. However, as the generator improves, the discriminator’s job becomes harder.</p><p>The discriminator learns to recognize subtle details that differentiate real from generated data — details that could be as fine-grained as the texture of a surface in an image or the slight variations in a time series. Through this process, the discriminator also becomes a robust feature extractor, honing in on the most distinguishing characteristics of the real data.</p><h3>What GANs Learn: Patterns, Features, and More</h3><p>So, what do GANs ultimately learn? It turns out that both networks, through their adversarial training, develop a deep understanding of the data’s underlying structure.</p><p>GANs are particularly adept at learning and replicating patterns. Whether it’s the way colors blend in a photograph or how numbers fluctuate in financial data, GANs capture these nuances. The generator, in its quest to fool the discriminator, must learn these patterns down to the smallest details. The result is an ability to generate new data that fits seamlessly into the broader context of the original dataset.</p><h3>Feature Extraction</h3><p>Another crucial aspect of what GANs learn is feature extraction. While the discriminator is trained to identify what makes data “real,” it inadvertently learns to identify the key features that define the dataset. This knowledge is implicitly passed back to the generator, which uses it to create more convincing fakes.</p><p>For instance, if the task involves generating human faces, the discriminator might learn that certain facial features, like the shape of the eyes or the spacing between them, are critical to determining authenticity. The generator, receiving feedback from the discriminator, will adjust its outputs to better capture these features.</p><p>GANs walk a fine line between creativity and realism. The generator has to strike a balance — generate data that’s novel enough to be interesting, but close enough to the real thing to avoid detection. This balance is at the heart of what GANs learn: to create new data that is both believable and original.</p><h3>Image Generation: Unlocking Creative Potential</h3><p>Generative Adversarial Networks have revolutionized the field of image generation, enabling machines to create images that can range from photorealistic to entirely surreal. The potential applications of this technology are vast, spanning industries from entertainment to healthcare. But how exactly do GANs tackle image generation, and what are the real-world use cases?</p><h3>How GANs Generate Images</h3><p>At the heart of GAN-based image generation is the generator’s ability to learn and reproduce the patterns found in a dataset of real images. The process begins with the generator taking in random noise and transforming it into a preliminary image. This image is then evaluated by the discriminator, which compares it to real images from the dataset.</p><p>The discriminator’s feedback — essentially a score indicating how real or fake the image appears — guides the generator in refining its output. Over many iterations, the generator learns to produce images that are increasingly difficult to distinguish from the real thing.</p><p>This iterative process allows GANs to capture intricate details like textures, shadows, and the interplay of light and color, resulting in images that can closely mimic reality. However, GANs are not limited to simple replication. They can also generate novel images that, while grounded in the real world, have never existed before.</p><h3>Use Cases of GANs in Image Generation</h3><ol><li><strong>Art and Creative Design</strong></li></ol><ul><li><strong>AI-Generated Art</strong>: GANs have opened new avenues in the art world, where artists collaborate with AI to create unique pieces. For example, GAN-generated artwork has been auctioned at major art houses, blending human creativity with machine learning to produce pieces that challenge traditional notions of art.</li><li><strong>Design Prototyping</strong>: In fields like fashion and architecture, GANs can generate design prototypes that help creators visualize new concepts. A fashion designer might use a GAN to generate new fabric patterns or garment designs, while an architect could use one to explore innovative building shapes.</li></ul><p><strong>2. Entertainment and Media</strong></p><ul><li><strong>Video Game Design</strong>: In the gaming industry, GANs are used to create realistic textures, characters, and even entire landscapes. By training on vast datasets of images, GANs can generate lifelike environments or characters that add depth and immersion to video games. For example, they can create realistic facial expressions for characters or generate unique terrains for open-world games.</li><li><strong>Movie Special Effects</strong>: GANs can also be employed in the film industry to generate special effects, like realistic explosions or weather conditions, that blend seamlessly with live-action footage. This capability reduces the need for costly physical effects, making movie production more efficient.</li></ul><p><strong>3. Healthcare</strong></p><ul><li><strong>Medical Imaging</strong>: In healthcare, GANs are used to generate synthetic medical images, which are particularly valuable for training purposes. For instance, GANs can create realistic images of tumors, which can then be used to train diagnostic algorithms, improving their accuracy without the need for additional patient data.</li><li><strong>Data Augmentation</strong>: GANs can also generate variations of existing medical images, such as MRI scans or X-rays, to augment datasets. This helps in building more robust machine learning models that can generalize better to new, unseen data, ultimately improving diagnostic capabilities.</li></ul><p><strong>4. Advertising and Marketing</strong></p><ul><li><strong>Personalized Marketing</strong>: GANs can generate personalized images for marketing campaigns. For example, they can create product images that appeal to specific demographics, generating content that is tailored to individual tastes and preferences. This personalization increases engagement and conversion rates.</li><li><strong>Virtual Try-Ons</strong>: In the retail sector, GANs can be used to create virtual try-on systems where customers can see how clothes, accessories, or even makeup would look on them without physically wearing the items. The GAN generates realistic images of the products on the user’s body or face, enhancing the online shopping experience.</li></ul><p><strong>5. Restoration and Super-Resolution</strong></p><ul><li><strong>Image Restoration</strong>: GANs are also used to restore old or damaged photographs. By training on datasets of high-quality images, a GAN can learn to reconstruct missing parts of an image, remove noise, or even colorize black-and-white photos.</li><li><strong>Super-Resolution</strong>: Another application is in enhancing the resolution of images. A GAN trained on high-resolution and low-resolution image pairs can learn to upscale images, adding details that make the upscaled version appear more detailed and realistic. This is particularly useful in fields like satellite imaging, where high-resolution data may be limited.</li></ul><h4>How GANs Tackle Image Generation</h4><p>GANs approach image generation by learning a detailed model of the distribution of the training data. The generator’s goal is to capture this distribution so well that it can produce new samples that appear as if they were drawn from the original dataset. Here’s how this process plays out:</p><ol><li><strong>Training with Diverse Data</strong>: The effectiveness of a GAN in generating images depends heavily on the diversity and quality of the training data. For example, if a GAN is trained on a dataset of human faces, it learns the common features of faces — eyes, noses, mouths, and how they relate to one another spatially. The more diverse the dataset, the more varied the generated images can be.</li><li><strong>Iterative Refinement</strong>: The training process is iterative. The generator starts with a rough approximation and gradually improves its output. In the beginning, the discriminator easily identifies the generated images as fake. But as training progresses, the generator learns to produce increasingly realistic images, challenging the discriminator more and more. This back-and-forth continues until the generator’s images are nearly indistinguishable from real ones.</li><li><strong>Handling Challenges like Mode Collapse</strong>: One of the significant challenges in GAN-based image generation is mode collapse, where the generator produces a limited variety of images, focusing too much on certain features and neglecting others. Advanced techniques, such as feature matching or using multiple discriminators, can help mitigate this problem, encouraging the generator to explore a broader range of possibilities.</li><li><strong>Balancing Creativity and Realism</strong>: GANs must balance creativity and realism in image generation. If the generator becomes too focused on mimicking the training data exactly, it might produce images that are overly familiar, lacking in novelty. On the other hand, if it strays too far from the training data, the images might lose their realistic qualities. The adversarial setup ensures that GANs learn to generate new images that are not only realistic but also exhibit a degree of originality, making them valuable in creative fields.</li></ol><h3>Data Augmentation: Expanding the Horizons of Machine Learning</h3><p>Data augmentation is a technique used to artificially increase the size and diversity of a training dataset by generating new examples from the existing data. In machine learning, the more varied and extensive the dataset, the better the model’s ability to generalize to new, unseen data. This is where GANs come into play, offering a powerful tool to generate synthetic data that closely resembles real-world examples.</p><h3>How GANs Perform Data Augmentation</h3><p>At the core of GAN-based data augmentation is the generator’s ability to learn the underlying patterns of the dataset and produce new data points that fit within those patterns. Here’s how this process unfolds:</p><ol><li><strong>Learning the Data Distribution</strong>: The generator is trained on the original dataset, learning the statistical properties and feature distributions that characterize the data. For instance, if the dataset consists of images of handwritten digits, the GAN learns the various styles and shapes that digits can take, as well as the typical variations in handwriting.</li><li><strong>Generating Synthetic Examples</strong>: Once trained, the generator can create new data points that are not exact copies of the original examples but are close enough in appearance and structure to be useful. These synthetic examples can include slight variations, such as changes in orientation, scale, or even style, depending on the application.</li><li><strong>Diversity and Realism</strong>: GANs are particularly effective at producing diverse yet realistic examples. Unlike traditional data augmentation techniques, which often rely on simple transformations like rotation or flipping, GANs can generate entirely new examples that introduce variations not present in the original dataset. This capability is crucial for tasks where model performance is highly dependent on the richness of the training data.</li></ol><h3>Use Cases of GANs in Data Augmentation</h3><ol><li><strong>Medical Imaging</strong></li></ol><ul><li><strong>Enhancing Diagnostic Models</strong>: In medical imaging, collecting a large, diverse dataset is often challenging due to privacy concerns and the rarity of certain conditions. GANs can generate synthetic medical images, such as MRI scans or X-rays, that resemble real patient data. This augmented dataset can then be used to train machine learning models, improving their ability to detect and diagnose diseases from limited data.</li><li><strong>Simulating Rare Conditions</strong>: For rare medical conditions, GANs can create examples that would otherwise be difficult to obtain. By generating synthetic images of these conditions, models can be trained to recognize and diagnose them more accurately, which is especially important in early detection and treatment.</li></ul><p><strong>2. Natural Language Processing (NLP)</strong></p><ul><li><strong>Text Data Augmentation</strong>: GANs can also be applied to text data, where they generate new sentences or paragraphs that maintain the semantic structure of the original data. This is useful in tasks like sentiment analysis, where augmenting the dataset with varied examples can lead to more robust models.</li><li><strong>Language Translation</strong>: In cases where parallel corpora (aligned text in two languages) are scarce, GANs can generate synthetic translations, helping to train more effective language models for machine translation tasks.</li></ul><p><strong>3. Computer Vision</strong></p><ul><li><strong>Image Classification and Object Detection</strong>: In computer vision, GANs can augment datasets used for image classification or object detection. For example, a GAN trained on images of vehicles could generate synthetic images of cars, trucks, or bikes in various orientations and lighting conditions. These additional examples help models become more accurate and robust, particularly in recognizing objects in real-world scenarios where conditions vary.</li><li><strong>Facial Recognition</strong>: GANs can generate new facial images with varying expressions, angles, and lighting conditions. This augmented dataset allows facial recognition systems to better handle variations in appearance, improving their performance in diverse settings.</li></ul><p><strong>4. Speech Recognition</strong></p><ul><li><strong>Augmenting Audio Data</strong>: In speech recognition, collecting diverse audio samples can be difficult, especially for rare languages or accents. GANs can generate synthetic audio clips that mimic different speech patterns, accents, and pronunciations. This enriched dataset can then be used to train more accurate speech recognition models.</li><li><strong>Noise Robustness</strong>: GANs can also be used to generate noisy versions of audio data, helping models learn to recognize speech in less-than-ideal conditions, such as in crowded or noisy environments.</li></ul><p><strong>5. Financial Data</strong></p><ul><li><strong>Time Series Data Augmentation</strong>: In finance, GANs can generate synthetic time series data that mimic market behaviors. For example, a GAN trained on historical stock prices could produce new sequences that exhibit similar trends and volatility. These synthetic time series can be used to stress-test trading algorithms or to train models that predict market movements.</li><li><strong>Risk Management</strong>: By generating data that simulates extreme market conditions, GANs can help financial institutions assess and prepare for potential risks, even those that haven’t been observed in historical data.</li></ul><h4>Advantages of GAN-Based Data Augmentation</h4><ul><li><strong>Richness and Variety</strong>: GANs can introduce new, unseen variations in the data, making the augmented dataset richer and more diverse than what traditional methods could achieve. This is particularly useful in domains where the data is inherently complex and varied, such as in medical imaging or natural language processing.</li><li><strong>Reduction of Overfitting</strong>: By exposing the model to a broader range of data through GAN-generated examples, the risk of overfitting is reduced. This leads to better generalization to new data, which is crucial for real-world applications.</li><li><strong>Synthetic Data for Privacy</strong>: In sensitive fields like healthcare, using real patient data for training can raise privacy concerns. GANs provide a way to generate synthetic data that retains the essential characteristics of the original data while protecting patient privacy.</li><li><strong>Scalability</strong>: GANs offer a scalable solution to data augmentation. Once trained, a GAN can generate an almost limitless number of new examples, providing an extensive dataset without the need for additional data collection.</li></ul><p>While GANs offer significant advantages in data augmentation, there are also challenges to consider:</p><ul><li><strong>Quality of Synthetic Data</strong>: The quality of the generated data depends heavily on the training process and the quality of the original dataset. Poorly trained GANs can produce unrealistic or biased data, which can negatively impact model performance.</li><li><strong>Computational Resources</strong>: Training GANs, especially for high-quality data generation, requires substantial computational resources. This can be a limitation for smaller organizations or those with limited access to high-performance computing.</li><li><strong>Ethical Considerations</strong>: The use of synthetic data raises ethical questions, particularly in fields like healthcare, where the implications of model decisions can be significant. Ensuring that GAN-generated data is representative and unbiased is crucial to avoid reinforcing existing biases in machine learning models.</li></ul><p>In domains like picture creation and data augmentation, Generative Adversarial Networks have shown to be revolutionary, opening up new avenues and pushing the limits of machine learning. GANs reproduce the data we feed them, but they also produce fresh, insightful insights and applications in a variety of fields by perfectly balancing realism with creativity.</p><p>There is still plenty to learn, even if we have already looked at what GANs can learn and how they use it in real-world situations. The actual beauty in these networks is in the mathematical understanding that powers them; in the algorithms, in the loss functions, in the complex dance of the discriminator and generator.</p><p>We’ll go more into mathematical intuition in a future piece, revealing the inner workings of GANs and how they accomplish such amazing things. Join me as I dissect the intricate theories behind GANs by following me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a450a0373020" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[14 pandas tricks you MUST know]]></title>
            <link>https://medium.com/@deyprakash753/14-pandas-tricks-you-must-know-aee396dde875?source=rss-72f694abfa1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/aee396dde875</guid>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[pandas-tutorial]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[JYOTI PRAKASH DEY]]></dc:creator>
            <pubDate>Tue, 13 Aug 2024 03:55:13 GMT</pubDate>
            <atom:updated>2024-08-13T03:55:13.711Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7hVaYAveaMrBaaerWY0sbg.png" /></figure><p>I’ve been using Python for almost 3 years now and the one thing that attracts me is the robustness.. In this blog, I will be sharing a bunch of Pandas scripts that I use daily, which have increased my performance.</p><p>Imagine you’re tasked with understanding a massive dataset — millions of rows of financial transactions, patient records, or social media interactions. How would you approach this? Would traditional spreadsheets suffice, or do you need something more robust, flexible, and intuitive?</p><p>Pandas, an open-source Python library, is designed to make complex data analysis tasks accessible and efficient. It allows you to structure, analyze, and visualize your data in ways that would be cumbersome or impossible with basic tools. Whether you’re reshaping datasets, filling in missing values, or performing statistical analysis, Pandas offers a wide array of functions that can transform your data exploration process.</p><p>But what sets Pandas apart? It’s not just the speed or the ease of use — it’s the way it encourages you to think about data. Pandas turns abstract concepts like dataframes and series into tangible, manipulable objects, allowing you to focus on asking the right questions rather than getting bogged down in the mechanics of data handling. It’s a library that’s as much about discovery as it is about execution.</p><p>With Pandas, you won’t just be processing data — you’ll be extracting insights, making predictions, and perhaps even questioning the data itself. What patterns are hidden in the noise? How can you reshape the data to uncover new perspectives? With Pandas, these questions become not just possible to explore but enjoyable to answer.</p><p>Here are the 14 Pandas tricks and their use cases:</p><pre>#FIRST IMPORT PANDAS AND LOAD YOUR DATA <br>import pandas as pd<br>df=pd.read_csv(&quot;YOUR FILE PATH&quot;)</pre><h3>1. Selecting Columns by Data Type</h3><p>This feature allows you to filter and select columns from a DataFrame based on their data types, such as integers (int64), floating-point numbers (float64), or strings (object). This can be particularly useful when you want to apply specific operations only to numerical columns or exclude categorical data.</p><p><strong>Use Case:</strong> If you’re performing statistical analysis and need to isolate only the numerical columns, or if you’re preparing data for machine learning models that require numerical input, this method quickly narrows down the relevant columns.</p><pre>df.select_dtypes(include=[&#39;float64&#39;, &#39;int64&#39;])</pre><h3>2. Conditional Filtering with query</h3><p>The query method provides a more readable and concise way to filter rows in a DataFrame based on conditions. Unlike traditional boolean indexing, query allows you to write conditions in a string format that can include logical operators and column names, making the code more intuitive.</p><p><strong>Use Case:</strong> This is useful when you need to filter data based on multiple conditions, such as selecting rows where the age is greater than 25 and the city is &quot;Mumbai.&quot; It simplifies complex filtering operations and improves code readability.</p><pre>df.query(&#39;age &gt; 25 &amp; city == &quot;Mumbai&quot;&#39;)</pre><h3>3. Chaining Operations with pipe</h3><p>The pipe method allows you to apply a function or a sequence of functions to a DataFrame in a chained manner. This is particularly useful for maintaining a clean and readable codebase when performing multiple transformations. Instead of breaking down each step into separate lines of code, you can chain them together, enhancing readability and flow.</p><p><strong>Use Case:</strong> When you&#39;re normalizing data, cleaning up columns, or applying multiple transformations in a specific order, pipe helps keep the sequence of operations clear and maintainable.</p><pre>def normalize(df):<br>    return (df - df.mean()) / df.std()<br><br>df.pipe(normalize)</pre><h3>4. Exploding a List-Like Column</h3><p>The explode function takes a column that contains lists and expands each element of the lists into separate rows, aligning the rest of the DataFrame accordingly. This method is useful when you have nested data within a column and need to perform analysis at a more granular level.</p><p><strong>Use Case:</strong> Suppose you have a DataFrame where one column contains lists of tags or categories associated with each record. By exploding this column, you can create a row for each tag or category, making it easier to count, group, or analyze them separately.</p><pre>df.explode(&#39;column_with_lists&#39;)</pre><h3>5. Using applymap for Element-Wise Operations</h3><p>The applymap method allows you to apply a function to each element of a DataFrame. This is useful when you need to perform element-wise operations across an entire DataFrame, such as formatting, type conversion, or custom computations.</p><p><strong>Use Case:</strong> If you need to calculate the length of each string in a DataFrame or apply a specific transformation to every element, applymap lets you do this efficiently. For example, converting all elements to their string length or formatting numbers.</p><pre>df.applymap(lambda x: len(str(x)) if isinstance(x, str) else x)</pre><h3>6. Creating New Columns with assign</h3><p>The assign method is a powerful tool for creating new columns in a DataFrame based on existing ones. It allows you to add one or more columns at a time, all while maintaining the original DataFrame. The new columns can be the result of operations on existing columns, such as arithmetic or string concatenation.</p><p><strong>Use Case:</strong> If you need to calculate a new metric, such as total cost by multiplying price and quantity columns, assign provides a clean and efficient way to add this new information to your DataFrame.</p><pre>df.assign(total_cost=lambda x: x[&#39;price&#39;] * x[&#39;quantity&#39;])</pre><h3>7. Using cut to Bin Data</h3><p>The cut function is used to segment and sort data values into bins or intervals. This is particularly useful when you want to categorize a continuous variable into discrete intervals, such as age groups, income brackets, or score ranges.</p><p><strong>Use Case:</strong> Suppose you have a dataset of ages and want to categorize individuals into age groups like &#39;Teen&#39;, &#39;Young Adult&#39;, &#39;Adult&#39;, and &#39;Senior&#39;. cut allows you to define these categories and automatically assign each data point to its corresponding bin.</p><pre>df[&#39;age_group&#39;] = pd.cut(df[&#39;age&#39;], bins=[0, 18, 35, 60, 100], labels=[&#39;Teen&#39;, &#39;Young Adult&#39;, &#39;Adult&#39;, &#39;Senior&#39;])</pre><h3>8. Memory Optimization with astype</h3><p>The astype method allows you to change the data type of a column in a DataFrame. This can be used to optimize memory usage by converting columns to more efficient types, such as converting integers to int32 or categoricals to the category type.</p><p><strong>Use Case:</strong> If you&#39;re working with a large dataset and need to reduce its memory footprint, converting categorical data to the category type or converting large integers to smaller integer types can save significant amounts of memory.</p><pre>df[&#39;category_column&#39;] = df[&#39;category_column&#39;].astype(&#39;category&#39;)</pre><h3>9. Forward and Backward Filling Missing Data</h3><p>Forward fill (ffill) and backward fill (bfill) are methods used to propagate the last valid observation forward or the next valid observation backward to fill missing values. These methods are useful when dealing with time series data or datasets where missing values need to be filled based on surrounding data points.</p><p><strong>Use Case:</strong> In time series data, if you have missing values in a sequence and you want to fill them with the last known value (e.g., carrying forward the last stock price), ffill and bfill provide a simple and effective solution.</p><pre>df.ffill()  # Forward fill<br>df.bfill()  # Backward fill</pre><h3>10. Working with MultiIndexes</h3><p>MultiIndexing in Pandas allows you to use multiple levels of indexing for rows and columns, enabling more complex data structures. This is particularly useful for hierarchical data, where you need to organize and access data at different levels of granularity.</p><p><strong>Use Case:</strong> If you’re dealing with data that has multiple layers of categorization, like sales data organized by region and then by product, using a MultiIndex allows you to slice and dice the data in powerful ways.</p><pre>df.set_index([&#39;col1&#39;, &#39;col2&#39;], inplace=True)<br>df.loc[(&#39;value1&#39;, &#39;value2&#39;)]</pre><h3>11. Aggregating Data with groupby and agg</h3><p>The groupby function groups data by one or more columns and then allows you to apply aggregation functions like sum, mean, or custom functions. The agg method provides flexibility by allowing you to apply multiple aggregation functions to different columns simultaneously.</p><p><strong>Use Case:</strong> When you need to calculate summary statistics for different groups within your data, such as finding the average price and total quantity sold per product category, groupbyand agg provide a structured and efficient way to do so.</p><pre>df.groupby(&#39;category&#39;).agg({&#39;price&#39;: [&#39;mean&#39;, &#39;sum&#39;], &#39;quantity&#39;: &#39;sum&#39;})</pre><h3>12. Reshaping Data with melt</h3><p>The melt function transforms a DataFrame from a wide format to a long format. It’s particularly useful when you have multiple columns representing similar data points and want to condense them into a single column with corresponding values.</p><p><strong>Use Case:</strong> Suppose you have monthly sales data for different products spread across multiple columns. melt can be used to convert these columns into a single &#39;Month&#39; column, making the DataFrame longer and easier to work with for analysis.</p><pre>pd.melt(df, id_vars=[&#39;id&#39;], value_vars=[&#39;A&#39;, &#39;B&#39;], var_name=&#39;variable&#39;, value_name=&#39;value&#39;)</pre><h3>13. Pivoting DataFrames</h3><p>The pivot function reshapes data by converting unique values from one column into new columns, with another column&#39;s values filling the new table. This is essentially the opposite of melt and is useful for summarizing and restructuring data.</p><p><strong>Use Case:</strong> If you have data in a long format, such as sales figures for different products and dates, and you want to create a table where each product has its own column and each row represents a date, pivot is the way to go.</p><pre>df.pivot(index=&#39;date&#39;, columns=&#39;product&#39;, values=&#39;sales&#39;)</pre><h3>14. Using sample for Random Sampling</h3><p>The sample function allows you to randomly select a fraction or a specific number of rows from a DataFrame. This can be useful for creating test datasets, performing Monte Carlo simulations, or simply getting a quick overview of your data.</p><p><strong>Use Case:</strong> When you have a large dataset and want to quickly explore a subset of the data without loading the entire dataset, or when you need to create a training sample for machine learning.</p><pre># Select 10% of the data randomly to explore a subset of a large dataset<br>sampled_df = df.sample(frac=0.1, random_state=42)</pre><p>Scrolled all the way? Would love to know your opinion on this blog, leave a small comment if you can.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aee396dde875" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction To Grafana: The ML job skill you need on your CV]]></title>
            <link>https://medium.com/@deyprakash753/introduction-of-grafana-the-ml-job-skill-you-need-on-your-cv-cb83fd88a71f?source=rss-72f694abfa1e------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb83fd88a71f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ml-model-deployment]]></category>
            <category><![CDATA[grafana]]></category>
            <dc:creator><![CDATA[JYOTI PRAKASH DEY]]></dc:creator>
            <pubDate>Sat, 27 Jul 2024 05:09:02 GMT</pubDate>
            <atom:updated>2024-07-27T07:33:17.299Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction To Grafana: The ML skill you need on your CV</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4BbsL-r-n5osWgdlcDkIkg.png" /></figure><p><strong>Introduction of Grafana: The ML job skill you need on your CV</strong></p><p>When it comes to staying competitive in the evolving world of data science and machine learning, having a skill most people aren’t yet familiar with can make the difference between you not landing the job vs missing out on the opportunity.</p><p>So what exactly is grafana?</p><p>“The open-source platform for monitoring and observability”, that’s what its github page says.</p><p>In this article I will go into a bit more detail than that and guide you through the approach you should take to effectively learn this open source tool recruiters want to see on your resume.</p><p>So what EXACTLY is GRAFANA? You ask again.</p><p>Grafana, while primarily known for its monitoring and visualization capabilities in IT and DevOps, has significant potential in the realm of data science and machine learning (ML). Here’s how Grafana can be utilized in these fields:</p><h4>Key Features Relevant to Data Science and ML:</h4><ol><li><strong>Data Source Integration:</strong></li></ol><p>Grafana’s ability to connect to various data sources is particularly useful for data scientists. It can pull data from SQL databases, NoSQL databases, time-series databases, and even cloud services, making it versatile for different types of data analysis.</p><p><strong>2. Customisable Dashboards:</strong></p><p>As a data scientist you can create interactive and highly customizable dashboards to visualize data, track model performance, and monitor key metrics. This helps in making data-driven decisions and understanding complex data patterns.</p><p><strong>3. Real-Time Monitoring:</strong></p><p>For ML models deployed in production, Grafana can monitor the models’ performance in real-time. Metrics like prediction accuracy, latency, and error rates can be tracked to ensure the models are performing as expected.</p><p><strong>4. Alerting:</strong></p><p>Set up alerts to get notified when the performance of an ML model degrades or when data drifts are detected to the robustness of the models in production.</p><p><strong>5. Plugins and Extensibility:</strong></p><p>Grafana’s plugin ecosystem includes various data source plugins and visualization plugins that can be leveraged for advanced data science needs. For example, the Plotly plugin for Grafana enables the creation of more sophisticated visualizations.</p><h4>Use Cases in Data Science and ML:</h4><ol><li><strong>Model Performance Monitoring:</strong></li></ol><p>After deploying an ML model, it’s crucial to monitor its performance over time. Grafana dashboards can display metrics such as precision, recall, F1 score, and ROC curves. Real-time monitoring ensures that any degradation in model performance is quickly detected and addressed.</p><p><strong>2. Data Exploration and Visualization:</strong></p><p>Before building models, data scientists need to explore and understand the data. Grafana can be used to create exploratory data analysis (EDA) dashboards that provide insights into data distributions, correlations, and trends.</p><p><strong>3. Anomaly Detection:</strong></p><p>Grafana can be integrated with anomaly detection systems to visualize and alert on unusual patterns in data. This is useful in applications such as fraud detection, network security, and predictive maintenance.</p><p><strong>4. A/B Testing and Experimentation:</strong></p><p>When conducting A/B tests or experiments, Grafana can be used to visualize and compare the performance of different models or versions. Metrics from experiments can be monitored to determine which version performs better.</p><p><strong>5. Data Pipeline Monitoring:</strong></p><p>Data scientists often work with complex data pipelines. Grafana can be used to monitor the health and performance of these pipelines, ensuring that data is processed and delivered reliably.</p><p>Would you like a more detailed instructions on setting up specific dashboards or examples of how Grafana can be used in your data science projects?</p><p>I’ll make another post on that if I get enough comments. Just kidding, I’ll make another post on it anyway.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb83fd88a71f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>