<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Penumudi Varun</title>
    <description>The latest articles on DEV Community by Penumudi Varun (@varunpenumudi).</description>
    <link>https://dev.to/varunpenumudi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2691447%2F95775f9f-30c4-4b4e-8ea0-faa8068eabf4.jpg</url>
      <title>DEV Community: Penumudi Varun</title>
      <link>https://dev.to/varunpenumudi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/varunpenumudi"/>
    <language>en</language>
    <item>
      <title>Non-numeric data for ML (Encoding Data)</title>
      <dc:creator>Penumudi Varun</dc:creator>
      <pubDate>Fri, 24 Jan 2025 01:57:43 +0000</pubDate>
      <link>https://dev.to/varunpenumudi/non-numeric-data-for-ml-encoding-data-3h0c</link>
      <guid>https://dev.to/varunpenumudi/non-numeric-data-for-ml-encoding-data-3h0c</guid>
      <description>&lt;p&gt;When dealing with Datasets for Machine Learning, some of the data will be in the text format. For example, consider a medical dataset containing patients details or consider a dataset containing details of individuals in an organization, usually these datasets have a gender column to tell whether the person is male or female.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffaykrgg4fg7668u1d93k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffaykrgg4fg7668u1d93k.png" alt="Non-Numeric Columns" width="577" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These non-numeric columns might contain important information needed for training the model. But, the problem is the ML and Deep Learning models cannot understand the text data. To give these features as inputs to the model we have to encode this text data into numbers before giving it to the model.&lt;/p&gt;

&lt;p&gt;This process of conversion of this text data into the numbers is called &lt;strong&gt;Feature Encoding&lt;/strong&gt;. There, are different types of feature encoding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Label Encoding&lt;/li&gt;
&lt;li&gt;Ordinal Encoding&lt;/li&gt;
&lt;li&gt;One Hot Encoding&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Label Encoding
&lt;/h2&gt;

&lt;p&gt;The label encoding we label each unique value in the column with a unique number. for example, if we consider the gender column it will only have two unique values, male and female. so we can label &lt;strong&gt;male as 1 and female as 2&lt;/strong&gt; in another column as shown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9tooewxg33kgvtopjf7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9tooewxg33kgvtopjf7.png" alt="Label Encoding" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the above dataset we created another column for label encoded values of gender column. In the label encoded columns we represent the male with 1 and female with 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ordinal Encoding
&lt;/h2&gt;

&lt;p&gt;If you sense some form of ordering in the column values, then you have to go for ordinal encoding. Consider a customer reviews dataset containing the rating column.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funxw9a40c2pfnp6468bk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funxw9a40c2pfnp6468bk.png" alt="Ordinal Encoding" width="800" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The rating column here has values good, fine, and bad. Here when we encode them to numbers we usually want to give a higher number to good rating and lower number to bad rating. This is called ordinal encoding. The ordinal encoded values for the rating column is also shown above.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Hot Encoding (Categorical Encoding)
&lt;/h2&gt;

&lt;p&gt;Let's take the previous example of gender column before. Instead of converting male to 1 and female to 2. we can instead create two separate columns for these two unique values as shown.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ubuwdw308ofrehuhiha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ubuwdw308ofrehuhiha.png" alt="Categorical Encoding" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can see that the is_male, is_female columns are added and these columns acts as better indicators of gender to the ML model rather than labeling each gender with a number. This type of encoding is called Categorical Encoding or One Hot Encoding.&lt;/p&gt;

&lt;p&gt;The is_male column acts as a Boolean feature for the ML model instead of being just a labeled number in the dataset. So, overall this is a good model. But, this has a disadvantage with cardinality of column.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cardinality:&lt;/strong&gt; This is measure of number of unique values of the column. Eg: the cardinality of the gender column is just 2. &lt;/p&gt;

&lt;h3&gt;
  
  
  Problem
&lt;/h3&gt;

&lt;p&gt;Now let's consider that there is a column with 100 unique values, then by one hot encoding 100 more columns will be added to dataset, which might make our Machine Learning model slower. So, we have to consider low cardinality columns for one hot encoding.&lt;/p&gt;

&lt;p&gt;So, these are the most important encoding types you need to know in Machine learning.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>learning</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Wanna Know Big O Basics!</title>
      <dc:creator>Penumudi Varun</dc:creator>
      <pubDate>Tue, 14 Jan 2025 09:21:17 +0000</pubDate>
      <link>https://dev.to/varunpenumudi/-4lip</link>
      <guid>https://dev.to/varunpenumudi/-4lip</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/varunpenumudi" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2691447%2F95775f9f-30c4-4b4e-8ea0-faa8068eabf4.jpg" alt="varunpenumudi"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/varunpenumudi/time-complexity-big-o-for-beginners-k0a" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Time Complexity, Big-O for Beginners&lt;/h2&gt;
      &lt;h3&gt;Penumudi Varun ・ Jan 14&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#leetcode&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#dsa&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#algorithms&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#datastructures&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>algorithms</category>
      <category>datastructures</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Time Complexity, Big-O for Beginners</title>
      <dc:creator>Penumudi Varun</dc:creator>
      <pubDate>Tue, 14 Jan 2025 09:10:14 +0000</pubDate>
      <link>https://dev.to/varunpenumudi/time-complexity-big-o-for-beginners-k0a</link>
      <guid>https://dev.to/varunpenumudi/time-complexity-big-o-for-beginners-k0a</guid>
      <description>&lt;p&gt;Often times when dealing with algorithms, we want to know which algorithm takes more time and which one takes less time. To know it, first one need a way to measure the time taken by the algorithm. The thing is we cannot measure the time taken by a algorithm in seconds. This is because the code for algorithms can be written in different languages. &lt;/p&gt;

&lt;p&gt;If you code for a faster algorithm in python and a slower one in C++ both of them might take same amount of time. Even if we try to compare their times by coding both in a single language, that would still be a bad idea. Because an algorithm running on a faster computer will take fewer nano seconds than the same algorithm on a slower computer. Hence "Seconds" are not a useful unit to measure time taken by a algorithm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Better Way(Time Complexity)
&lt;/h2&gt;

&lt;p&gt;So, what could be a better way. one way to solve this problem is by instead of asking "how many seconds will this algorithm take?" we can ask a different question i.e. "How many operations does this algorithm take?".&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;p&gt;Let's consider two simple algorithms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Algorithm to pop last element of an array/list.&lt;/li&gt;
&lt;li&gt;Algorithm to pop element at index i in the list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first algorithm is simple. It You just take out the last element of the array and no need to do anything other than that. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9tdyj5cqg3y7b2hys76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm9tdyj5cqg3y7b2hys76.png" alt="Constant time" width="724" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This takes Just a single operation. Hence time complexity in Big-O notation is given by: &lt;strong&gt;O(1)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whereas the second algorithm is different. To remove an element at a specific index you have to shift all the elements after this index left. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fusf6ifnulm847vvpv590.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fusf6ifnulm847vvpv590.png" alt="Linear time" width="724" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the worst case if the index i=0 then we have to shift the whole array to left. So in worst case if there are n elements in the array, All the n elements are shifted left. &lt;br&gt;
We have to perform n shifts in worst case, i.e. 'n' operations need to be performed. This makes the time complexity of this algorithm in Big O is given as &lt;strong&gt;O(n)&lt;/strong&gt;, where n is no. of elements in the array.&lt;/p&gt;

&lt;p&gt;These Big O notations are standard ways to represent time complexity of an algorithm. The Big O notation is a way to tell the amount of operations the algorithm will take given n number of inputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Time Complexities
&lt;/h2&gt;

&lt;p&gt;Some Important time complexities that you will see while solving DSA questions are:&lt;br&gt;
&lt;strong&gt;O(1)&lt;/strong&gt;:      Takes Constant amount of time&lt;br&gt;
&lt;strong&gt;O(log(n))&lt;/strong&gt;: Time increases logarithmically with no. of inputs&lt;br&gt;
&lt;strong&gt;O(n)&lt;/strong&gt; :     Time increases linearly with inputs&lt;br&gt;
&lt;strong&gt;O(n^2)&lt;/strong&gt;:    Quadratic amount of time taken&lt;br&gt;
&lt;strong&gt;O(2^n)&lt;/strong&gt;:    Time increases exponentially with inputs&lt;br&gt;
&lt;strong&gt;O(n!)&lt;/strong&gt;:     Algorithm performs factorial number of operations.&lt;/p&gt;

&lt;p&gt;The rate at which the time increases for algorithms for each of these types of algorithms is visually shown in the graph below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8eij1wh50lkcmnkl9qb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8eij1wh50lkcmnkl9qb.png" alt="Big O chart" width="745" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see the no. of operations for O(n!) algorithm increases rapidly and stays constant for O(1) as the amount of inputs increases. Hence, The O(n!) is the worst time complexity and O(1) is the best.&lt;/p&gt;

&lt;h2&gt;
  
  
  Note
&lt;/h2&gt;

&lt;p&gt;When we say time complexity we don't actually mean the exact amount of operations that an algorithm will take, instead it means how the no. of operations increase with increase in no. of inputs. &lt;/p&gt;

&lt;p&gt;let's say we consider popping two numbers at specific index and you might think now the time complexity would be O(2n), But that's not the case the time complexity would still be O(n). This is because don't care whether it takes n, 2n, 3n or some constant n operations, we see that the no. of operations algorithm takes is in the order of n's Hence time complexity is O(n) or linear.&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>dsa</category>
      <category>algorithms</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>What is the Architecture of Django?</title>
      <dc:creator>Penumudi Varun</dc:creator>
      <pubDate>Sun, 12 Jan 2025 07:30:15 +0000</pubDate>
      <link>https://dev.to/varunpenumudi/what-is-the-architecture-of-django-29dj</link>
      <guid>https://dev.to/varunpenumudi/what-is-the-architecture-of-django-29dj</guid>
      <description>&lt;p&gt;The first time I was asked this question was not when i was learning Django, but after I had learned it and applied for an internship. During the internship, I was asked this question. Unfortunately, I didn't know the answer at that time, but now I do.&lt;/p&gt;

&lt;p&gt;Every Django project you create follows an architecture called &lt;strong&gt;MVT&lt;/strong&gt;. The MVT here stands for &lt;strong&gt;Mode Template View&lt;/strong&gt;. These three things are main parts of any Django project. Let's see about them in detail. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpj85nfcm6j9h9ea76mv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpj85nfcm6j9h9ea76mv.png" alt="Django Architecture Diagram" width="800" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Model
&lt;/h2&gt;

&lt;p&gt;A model is a class based representation of a table in a database. Django applications use python classes to represent a table in the website database, these classes are called models in django. All the model classes you create in django should inherit from "django.db.models.Model" class. Each model class will have attributes that represents the fields of the database table. &lt;/p&gt;

&lt;h2&gt;
  
  
  View
&lt;/h2&gt;

&lt;p&gt;The view is the function or class that contains necessary logic to take in a HTTP request coming from the client and send the appropriate HTML, json or some other response back to the user. In Django these views can be class based or function based in Django. &lt;/p&gt;

&lt;p&gt;The view takes in the url path, query parameters along with request body sent by the user/client then uses this data to perform CRUD operations if needed, and sends back the responses. &lt;/p&gt;

&lt;h2&gt;
  
  
  Template
&lt;/h2&gt;

&lt;p&gt;The template in Django is nothing but a HTML file that defines the layout and contains body of webpage along with some other script written in special templating syntax supported by Django. &lt;/p&gt;

&lt;p&gt;Using this special templating syntax we can show the dynamic data on the website. This dynamic data is actually given by a Django view to the template and it usually contains the information about models of the Django project.&lt;/p&gt;

&lt;h2&gt;
  
  
  MVT and MVC?
&lt;/h2&gt;

&lt;p&gt;The MVT architecture used by Django is a slightly different version of another popular architecture called &lt;strong&gt;MVC&lt;/strong&gt;. Here &lt;strong&gt;MVC&lt;/strong&gt; stands for &lt;strong&gt;Model View Controller&lt;/strong&gt;. Here Model, View and Controller stands for&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model&lt;/strong&gt;: The model here represents the data and business logic. The model handles the data and business logic of the application similar to the model in Django's MVT.&lt;br&gt;
&lt;strong&gt;View&lt;/strong&gt;: The view here is different. It doesn't contain the logic for handling http requests, instead it represents UI elements. So, the view in MVC is more similar to template in MVT&lt;br&gt;
&lt;strong&gt;Controller&lt;/strong&gt;: The Controller in this architecture is responsible for the logic for controlling the requests and user inputs. So controller here is more like view in the MVC&lt;/p&gt;

&lt;p&gt;So, this is all you should know about the Django's architecture. If you have any questions feel free to ask them in comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>django</category>
      <category>architecture</category>
      <category>python</category>
    </item>
  </channel>
</rss>
