<?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 Pranjal Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Pranjal Srivastava on Medium]]></description>
        <link>https://medium.com/@pranjalsrivastava88?source=rss-78487b46c68e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bw7izf79x0VSSuZb.jpg</url>
            <title>Stories by Pranjal Srivastava on Medium</title>
            <link>https://medium.com/@pranjalsrivastava88?source=rss-78487b46c68e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:24:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pranjalsrivastava88/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[Practicum: Stairway to analytics professional!]]></title>
            <link>https://pranjalsrivastava88.medium.com/practicum-stairway-to-analytics-professional-1bbbfe4a8172?source=rss-78487b46c68e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bbbfe4a8172</guid>
            <dc:creator><![CDATA[Pranjal Srivastava]]></dc:creator>
            <pubDate>Wed, 04 May 2022 01:17:41 GMT</pubDate>
            <atom:updated>2022-05-04T01:17:41.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tpg1IBwHAbUhqOwOyckK7g.jpeg" /><figcaption>My practicum team at the practicum partner’s office for a presentation</figcaption></figure><p>The practicum project has been one of the most engaging and educational experiences of my academic career so far. It has many dimensions and the best part is that even though some of them were essential to follow, I chose to follow some that expanded my horizon. The practicum project is generally about learning analytical aspects of any project, client management, timely deliverables, being a team player, and managing your work. Along with all these, I chose to explore a new dimension: leadership. I started the project as a member of the team. Within a few weeks, I emerged as the team leader. I have driven all the meetings with our practicum partner, motivated my team to keep working even when things were challenging, instill collaboration among team members, work with the MIP (MSBA Industry Partner) to outline the project deliverables, gave presentations to the leadership team and served as the customer success manager as my last role.</p><blockquote>Practicum project? What is that?</blockquote><p>It is a course divided into all three quarters where a student gets to work on an analytics project with an organization. The course kickstarts in September and runs all the way till May or June, depending upon your project. The course prepares you for what lies beyond your MSBA. It teaches you how to present yourself as a professional in the analytics industry. A good Data professional needs to be proficient technically but should also be able to effectively communicate their thoughts, lead meetings, and conversations in front of both technical and non-technical audiences. I have learned from so many workshops and huddles with Professor Sanjay Saigal, who seems to be more enthusiastic about the project than any student. This inspired me the most and I’ve always tried to match that energy level throughout my journey.</p><p>The practicum project for me has been about coming out of my comfort zone, rising to the occasion, and delivering excellence. It’s not only just a project, it’s a journey full of challenges and learnings. It’s about accepting whatever comes your way and making something useful out of it! I still remember all my one-on-one calls and conversations with Professor every time I faced challenges. Each time I learned something new and chose to move forward with my best effort.</p><blockquote>Tales of practicum learnings!</blockquote><p>I learned a wide spectrum of things from the practicum. Listing them down would be a foolish attempt. So, let me walk you through some of the highlights of my journey!</p><h4>Silent meetings!</h4><p>I remember the first time I read about this as part of pre-class readings for one of our practicum sessions. I was fascinated by the concept and then I learned more about it in the class. I got a chance to practice that in one of the in-class sessions and I was amazed at the increase in the productivity of my team. We started to have most of our discussions and brainstorming sessions this way after this class. I realized that the members who were not very vocal before started to add some really insightful thoughts in such meetings! This helped my cause of increasing participation in discussions. This changed a lot of dynamics in the team and helped us to have more collaborative meetings!</p><h4>Expectation management!</h4><p>As a person, it is very hard for me to say no to people! This is one of my flaws and it is not a good quality while working as a professional! I learned to set the expectations and put my foot down if the situation demands it. I remember many conversations with Professor who told me that I can’t take things personally and need to be firm with managing expectations within a team and project.</p><p>As a result, I learned how to get people to take responsibility and delegate some work instead of doing everything personally. I believe that there are many people like me who find it difficult to be outspoken about asking other people to lead some tasks. I assure you that it’s okay to do so and it’s totally professional!</p><p>As the customer success manager of my team, I had several meetings with the MIP to clearly define a definite list of deliverables for our project. It was a hard conversation for someone like me but I’m glad that I did it! I learned a lot about client management and I believe that it prepared me for my upcoming career!</p><h4>Self-branding!</h4><p>I have always been the one for public speaking and client presentations! I love doing that and I have been doing that since high school. This practicum project gave me the opportunity to not only do so but also improve upon my communication and presentation skills.</p><p>I gave several presentations throughout this course. Some of them were just in the form of weekly updates, sometimes quarterly progress ones and one time I got the opportunity to present our project to the leadership team of our practicum partner at their office.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Iti6DGHK6XOTi0a_" /><figcaption><em>Winter quarter-end presentation (I’m the guy in the beautiful red shirt!)</em></figcaption></figure><p>These presentations and client interactions helped me to better brand myself. More importantly, how to brand me in front of not only the MIP and his team but also in front of my own team and batchmates! I believe that one’s social image is important for their career progress, especially in today’s world where everyone has views about everyone!</p><p>In the end, I just want to conclude my thoughts by emphasizing the importance of practicum. It truly played a pivotal role in my MSBA journey. Of course, there were ups and downs but I can confidently say that I learned most from the challenges that I faced as a team member and as a team lead! I wouldn’t trade those experiences for anything now because each ordeal taught me something and inspired me to do better as an upcoming analytics professional!</p><p>I hope that my journey gave you some insights about the practicum in this program and I look forward to utilizing all these learnings in my future career!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bbbfe4a8172" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to communicate better in meetings?]]></title>
            <link>https://pranjalsrivastava88.medium.com/how-to-communicate-better-in-meetings-a22604b0ba51?source=rss-78487b46c68e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a22604b0ba51</guid>
            <dc:creator><![CDATA[Pranjal Srivastava]]></dc:creator>
            <pubDate>Sat, 26 Feb 2022 05:27:56 GMT</pubDate>
            <atom:updated>2022-02-26T05:27:56.263Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tR5OMFNJ0gB6Rj4R.jpg" /><figcaption>Source: <a href="https://g.foolcdn.com/editorial/images/446553/meeting_gettyimages-603992138.jpg">https://g.foolcdn.com/editorial/images/446553/meeting_gettyimages-603992138.jpg</a></figcaption></figure><p>How many times have you walked into a meeting and regretted being there just after 20 minutes? I can vouch for many such times! It is a well-known fact in the corporate world that meetings are nothing but a waste of time, most of the time!</p><p>There is always this one person presenting with several people zoning out within a few minutes of the presentation! The problem with most of the meetings is that there is no clear agenda defined beforehand. It is highly likely that one person asks a question, and the entire discussion goes around taking most of the designated time. Other people with something more to add either end up extending the meeting or never really gets the chance to talk about it!</p><blockquote><strong>Enter Silent Meetings!</strong></blockquote><p>The CEO of Amazon, Jeff Bezos, came with this novel and brilliant idea of silent meetings! There will always be designated presented, but in this case, that person would prepare a document with agenda, ideas, and all the relative content. The room will just sit in silence and read that document and add any comment they would have spoken about, to the document now. Everyone else shall do the same. This way each participant will get to weigh in their opinion and time would be used effectively!</p><p>After having this document digitally, every person has a chance to review other people’s comments and add to them without wasting time! This idea quickly spread across not just Amazon but to other companies too.</p><blockquote><strong>Why is communication important in teams?</strong></blockquote><p>Most of the companies have global teams and there are interdependencies within a team. Communication becomes the key to the successful delivery of any project, especially in such cases. One needs to communicate effectively to get ideas across to develop a better solution. Most of the time, there is always a hesitation due to language constraints across global teams. There are always introverted people every time and even though they might have good points, they tend not to contribute due to their nature. Silent meetings can bridge this gap as no one has to really speak but write down their comments and thoughts! This gives equal opportunity to everyone to participate.</p><p>Also, in any global team, there are mostly members logging in from different time zones. The process of silent meetings helps you create a document in the end with narration and everyone’s comments in it. This helps in passing on the conclusion of the meeting to different teams globally who probably start in different time zones!</p><p>Fortunately, I have been a part of such a situation in my previous company, IBM, where we had people from Budapest, Texas, LA, and Bangalore (four different time zones!). We actually used to follow this convention for all of our discussions and after comparing the productivity of this new meeting technique with the traditional way, all of us were amazed at the difference! We saw much more clarity in thoughts and participation from almost everyone!</p><blockquote><strong>Pandemic era = Zoom meetings!</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*S0VnDM4BUfCvGQi8.jpg" /><figcaption>Source: <a href="https://helpdeskgeek.com/wp-content/pictures/2020/04/gallery-view.jpg">https://helpdeskgeek.com/wp-content/pictures/2020/04/gallery-view.jpg</a></figcaption></figure><p>The pandemic changed a lot of things in the corporate world- one of the biggest being remote work culture! A lot of organizations have fully moved to the remote culture as nearly most of them ended up making more profits by cutting the infrastructure costs!</p><p>Online meetings do have their advantages, but it also causes a lot of fatigue. Communication within teams becomes even more important in this scenario. People must be on one or another call for almost half of their days and participate in all of them effectively. With the use of silent meetings, any discussion can be done in a more organized and timely manner. It has been proven that online meetings cause more fatigue than regular meetings because of continuous staring into the screens. Most of the time, people tend to just stay quiet because they’re too tired to express their opinion.</p><p><strong>Example</strong>: In our practicum project, we had almost all our meetings online due to rising Covid cases during the month of January. The meetings usually used to get monotonous soon due to lack of participation and interest! After our practicum session about effective communication using silent meetings, my team decided to implement that in our daily meetings. Within 3 weeks, we realized that everyone was more interested and the team, was much more productive. Communication improved without even uttering a word!</p><blockquote><strong>Conclusion</strong></blockquote><p>Communication is one of the pillars of a successful project. One of the ways for effective communication and saving time is silent meetings! It maximizes participation, saves the meeting from digressing from the agenda, provides equal opportunity for everyone to participate and express their views, removes the authoritarianism of the presenter, and always provides a conclusion! My practicum team has used this technique to improve our work by collaborating in a smoother and much more efficient way!</p><p>References:</p><p><a href="https://medium.com/swlh/the-silent-meeting-manifesto-v1-189e9e3487eb">The Silent Meeting Manifesto v1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a22604b0ba51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tale of leadership and teamwork!]]></title>
            <link>https://pranjalsrivastava88.medium.com/tale-of-leadership-and-teamwork-7ab9b378bb20?source=rss-78487b46c68e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ab9b378bb20</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[leadership]]></category>
            <dc:creator><![CDATA[Pranjal Srivastava]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 23:44:57 GMT</pubDate>
            <atom:updated>2022-01-25T23:46:12.864Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/770/0*_61nrEzgXo94zwgL" /><figcaption>Image by <a href="https://www.michaelpage.at/sites/michaelpage.at/files/styles/advice_node_desktop/public/legacy/5141-MP_DE_BLOG_IMAGES_RESIZE_440x284_0019_shutterstock_500593225.png?itok=6VghdA9-">https://www.michaelpage.at/sites/michaelpage.at/files/styles/advice_node_desktop/public/legacy/5141-MP_DE_BLOG_IMAGES_RESIZE_440x284_0019_shutterstock_500593225.png?itok=6VghdA9-</a></figcaption></figure><p>“How do I become the team lead?” — In my very first call with my Professor, I asked him this question as I decided on my practicum project. “A good leader is not self-proclaimed; you need to emerge as one by proving your worth!”</p><p>The professor may have forgotten about this, but I haven’t, clearly! As I was about to embark upon my practicum journey last October, I decided that I want to lead my team from a technical perspective and establish myself as a successful leader. I decided to prepare myself for the career switch after this graduation. I used to work as a Data Scientist for four years at IBM and now I wanted to move to a leadership role after graduation. So, I pushed myself and prepared to do this. As with almost everything else in life, it is easier said than done! I had no idea how to lead people or even how to establish myself as a leader!</p><p>Rewind to October 2021!</p><p>My team met with our practicum partner team for the first time in late October. We learned about the company, its services, and our project for the next nine months. It was overwhelming at first but that’s just how every beginning feels to me! After that, we had our first call with the MIP (MSBA Industry Partner), where we introduced ourselves and talked about the project. We assigned our tasks, but I chose to not only do my part but also check on other people to see if they needed any help. I talked to my team and asked them if they would be okay with me leading the call with our MIP. Fortunately, they were quite happy and gave me a green signal.</p><p>I believe that effective communication is the most important skill to become a good leader. Fortunately, my oratory skills have always been my strength. I have a lot of experience in public speaking, and I believe that helped me in gaining the trust of my fellow team members.</p><blockquote>A good leader needs to be a good follower!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*97jB-lzP779EeIqn.jpg" /><figcaption>Image by <a href="https://futurist.gr/why-being-a-good-follower-makes-a-better-leader-by-gwen-moran/">https://futurist.gr/why-being-a-good-follower-makes-a-better-leader-by-gwen-moran/</a></figcaption></figure><p>I believe that this is where most people fail as they don’t listen enough. I made sure to create an environment where my team members could speak freely and without any hesitation.</p><p>In any discussion, I would make sure that everyone feels accepted and validated for each of their points. I’m always eager to learn something if I don’t know it. As a result, I learned something or other from each of my team members and I gave them the credit for it.</p><p>Fortunately, my team members always spoke their minds and we all decided to learn from each other and be honest about our work. We started this culture of assessing each other works to improve and drop our comments anonymously so that no one would feel any negativity towards the other person.</p><blockquote>A team is as good as its leader!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*4Ph-BpDAAwuypiQN.jpeg" /><figcaption>Image by <a href="https://www.teambonding.com/wp-content/uploads/2013/09/boss-vs-leader_264722-624x.jpeg">https://www.teambonding.com/wp-content/uploads/2013/09/boss-vs-leader_264722-624x.jpeg</a></figcaption></figure><p>Over the period, I emerged as the team lead, and everyone started to look up to me for any help, discussion, or guidance. I accepted this role wholeheartedly and decided to work even harder to be the leader my team deserved. I believe that a good leader must be the hardest worker in the room! I tried my best to always stay on top of things, be it our weekly huddles, research work for the project, leading a technical discussion with the MIPs, or helping my teammates with any work.</p><p>Our project started a bit late than others due to some unavoidable issue. So, we had lesser time than all the other groups. I’ll agree that we all were quite worried initially but I’m glad that my team helped each other to catch up on tasks and decided to make the best with what we had rather than sulking about what went wrong. This was one of our biggest hurdles as a team and I couldn’t be happier to look back and see how great we did!</p><blockquote>All’s well that ends well!</blockquote><p>As we reached the end of the quarter, we needed to give two presentations, one in class and the other to all the MIPs. Since I saw that my team members were a little bit nervous about that, I decided to volunteer for the first presentation. I was quite happy to see that one of my team members got inspired and decided to join me. We did well as a few students called our presentation quite interesting in the later Q/A session.</p><p>This little token of appreciation gave confidence to us, and I saw that other team members volunteered to give the second presentation to the MIPs. I stepped down happily and pushed them forward as there is no I in the team. The judgment day came, and our presentation went better than we expected. All the partners were quite happy and excited about the work we had done and all the plans for the rest of the practicum.</p><p>In conclusion, I can say that it has been an eventful journey with lots of learning so far! Obviously, there is a lot of scope for improvements, but I am sure that my team will only go upwards and onwards from here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ab9b378bb20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sparse matrices — Part 2]]></title>
            <link>https://pranjalsrivastava88.medium.com/sparse-matrices-part-2-e27b69d337a?source=rss-78487b46c68e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e27b69d337a</guid>
            <category><![CDATA[scikit-learn]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[statsmodels]]></category>
            <category><![CDATA[sparse-matrix]]></category>
            <dc:creator><![CDATA[Pranjal Srivastava]]></dc:creator>
            <pubDate>Sat, 22 Jan 2022 23:56:45 GMT</pubDate>
            <atom:updated>2022-01-22T23:56:45.177Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Sparse matrices — Part 2</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*4JPKVl7W-mWKsTHD.png" /><figcaption>Photo by: <a href="https://scikit-learn.org/stable/modules/linear_model.html">https://scikit-learn.org/stable/modules/linear_model.html</a></figcaption></figure><p>We learned about sparse matrices and why do we need them in the first part of the article. In this one, we’re going to cover different packages available for implementing multiple linear regression in Python, their limitations and support for sparse matrices.</p><p><strong>Statsmodel OLS package</strong></p><p>This package gives us the statistics about our model like the p-values, R-squared values, AIC, BIC, etc. This model is analogous to the lm() function in R which provides a detailed analysis of all the estimates and parameters involved in the regression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPoxi8kvm7zwcbSmmjLe7w.png" /><figcaption>Statsmodel OLS result summary</figcaption></figure><p>Though we can use this package to predict and calculate other goodness of the fit measures, it’s not ideal to use it, especially for large datasets.</p><p>In my research project, I had a dataset of 1.4M rows and around 6600 dummy variables and I was trying to run fixed effects regression (part 3 of this series will cover this). I tried running regression using this package and I kept getting errors of memory limit exceeded. As a solution, my research advisors asked me to convert the input matrix to a sparse dataset as 90% of the data is zero anyway (recall that it’s a matrix of dummy variables), I tried that and now I could process the dataset in seconds rather than waiting for hours.</p><p><em>Sparse matrix and Statsmodel are not friends!</em></p><p>One of the biggest disadvantages of using the Statsmodel package is that it doesn’t take a scipy sparse matrix or Sparse [uint8] format as input. I discovered this while running the regression using the newly converted matrix into sparse as we discussed above.</p><p>Here comes the Scikit learn package into the picture.</p><p><strong>Scikit learn package</strong></p><p>This package was designed to run multiple linear regression using large datasets and make predictions using the out-of-sample approach or cross-validation. It is one of the most widely used packages by programmers. It offers many different pre-build functions to get the value of the intercept, coefficients, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWZFXj33thW9X3rnb1kKTw.png" /><figcaption>Scikit learn regression result displaying coefficients and intercept value</figcaption></figure><p>We can see that there are different ways to get different attributes of a linear regression but there is nothing like a summary() we used in the Statsmodel package.</p><p>Coming back to the sparse matrix, this package also supports sparse matrix as an input and gives the results in a few seconds. The issue with this package is that it doesn’t give a detailed summary of statistical parameters like the Statsmodel does.</p><p>For calculating p-values, we’ll have to write our function using the model run by Scikit learn.</p><p>Please refer to the following link to see the code for the same: <a href="https://stackoverflow.com/questions/27928275/find-p-value-significance-in-scikit-learn-linearregression">https://stackoverflow.com/questions/27928275/find-p-value-significance-in-scikit-learn-linearregression</a></p><p>This is why a lot of programmers and statisticians believe that R has better support for statistics-related problems than Python. In R, we can just use “lm()” function or “lme4” package to replicate the task we discussed above for the same size of the dataset.</p><p>In this article, we talked about two different packages used for performing multiple linear regression, their advantages, disadvantages, and which one to use when dealing with sparse matrices.</p><p>In the next article, we’ll deep dive into fixed-effects and random-effects regression and learn how to interpret them.</p><p><strong>References:</strong></p><p><a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html">LinearRegression</a></p><p><a href="https://scikit-learn.org/stable/modules/linear_model.html">https://scikit-learn.org/stable/modules/linear_model.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e27b69d337a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to sparse matrices — Part 1]]></title>
            <link>https://pranjalsrivastava88.medium.com/introduction-to-sparse-matrices-part-1-b8bdcf19a32c?source=rss-78487b46c68e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8bdcf19a32c</guid>
            <category><![CDATA[sparse]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sparse-matrix]]></category>
            <category><![CDATA[scipy]]></category>
            <dc:creator><![CDATA[Pranjal Srivastava]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 03:58:24 GMT</pubDate>
            <atom:updated>2022-01-22T23:44:12.460Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction to sparse matrices — Part 1</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*Iih-D_M5RaqDKouMvwWNWw.png" /><figcaption>Photo by <a href="https://cmdlinetips.com/2018/03/sparse-matrices-in-python-with-scipy/">https://cmdlinetips.com/2018/03/sparse-matrices-in-python-with-scipy/</a></figcaption></figure><p>Any matrix which comprises mostly zero values can be termed as a sparse matrix. Roughly, if more than two-thirds of the data points are zero, it is safe to assume that it can be stored as a sparse matrix though there is no strict definite proportion. A dense matrix is the opposite with mostly non-zero values. A sparse matrix can always be stored as a dense matrix too.</p><p><em>A matrix is sparse if many of its coefficients are zero. The interest in sparsity arises because its exploitation can lead to enormous computational savings and because many large matrix problems that occur in practice are sparse.</em></p><p><em>~ Page 1 </em><a href="https://amzn.to/2DcsQVU">Direct Methods for Sparse Matrices</a>, Second Edition 2017</p><p>Sparsity: This is the ratio of the total number of zero elements divided by the total number of elements in a matrix.</p><p>Sparsity (s) = no of zeros / total number of elements in the matrix</p><h3><strong>Why sparse matrices?</strong></h3><p>Dense matrices can be very computationally heavy and exhaustive, both in terms of space and time complexity.</p><p><strong>Space complexity</strong></p><p>Any matrix which has a lot of features but the data is mostly not present for most of the features, that is, zero.</p><p>For example, the matrix for user ratings for the products on an e-commerce website or ratings of movies by different users on IMDB or Netflix. Most of the users do not provide a rating and that’s why most of the elements are zero in such data.</p><p>We know that very few people actually provide ratings and thousands of people might have bought it in the past making them the users. So, most of the elements will be zero. If we store this matrix as dense, we’ll be using 32 or 64-bit zero values making it really big in memory size.</p><p><strong>Time complexity</strong></p><p>Let’s say we want to run a basic collaborative filtering algorithm on the matrix that we created above. Imagine running it on 100,000 users by 10000 product matrix where most of the values are zero. For something as simple as subtracting the avg rating of the user from each product to remove bias (one of the steps performed in collaborative filtering), the compiler will have to go through the entire matrix making the entire process slow. This problem increases as the size of the matrix increases.</p><h3>Applications of Sparse matrices</h3><p>In Machine learning, there are a bulk of operations that are performed in a series. In a case where we have a big matrix, converting it into a sparse matrix always helps. A sparse matrix is stored in a different format than a dense matrix. When we store a dense matrix as a sparse matrix, the program only stores the location of non-zero values, making it smaller in memory size and much faster for any computations.</p><p>-Recommender systems use sparse matrices for storing its matrices (user-user, user-item, and item-item)</p><p>-NLP user sparse matrices for tf-idf matrix, storing frequency of a word in a document and its comparison with different lexicons</p><p>-Dummy variables for a class with, let’s say 5000 levels, can be stored as a sparse matrix making it more usable to run with regression and other models</p><h3>Using sparse matrices in Python</h3><p>Python offers wide support for sparse matrices. One of the most widely used libraries is Scipy.sparse as it offers many default functions for data exploration.</p><p>Creating a sparse matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3vaGo6xnyBxh7LB7-VtPA.png" /></figure><p>Converting a dense matrix to sparse</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*42EhwBlXWSKUXnKrB6FpvQ.png" /></figure><p>Using sparse matrix with Pandas</p><p>Most of the time we have data in a data frame and when we have to perform some operations over it, there might be a lot of dummy variables. In my research work, I had a matrix of almost 6600 dummy variables and 1.4 Million rows with almost 90% of the cells being zeros due to dummy variables. I could not perform regression as I was running into the memory overload issue. As the article suggested above, in all such cases, it is advisable to convert the dense matrix to sparse. So, best way is to convert your data frame to a sparse format while creating dummies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LLwss2MsfHEUZ_fzDI5pmA.png" /></figure><p>We can see in the above piece of code how we created dummy variables for one column and stored it as a sparse matrix at the same time.</p><p>Using sparse matrices in multiple linear regression is one of the most important things and we will learn about that in the second part of this series.</p><h3>References</h3><ul><li><a href="https://en.wikipedia.org/wiki/Sparse_matrix">Sparse matrix - Wikipedia</a></li><li><a href="https://machinelearningmastery.com/sparse-matrices-for-machine-learning/">A Gentle Introduction to Sparse Matrices for Machine Learning - Machine Learning Mastery</a></li><li><a href="https://docs.scipy.org/doc/scipy/reference/sparse.html">Sparse matrices (scipy.sparse) - SciPy v1.7.1 Manual</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8bdcf19a32c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>