<?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 Kakarlasarathreddy on Medium]]></title>
        <description><![CDATA[Stories by Kakarlasarathreddy on Medium]]></description>
        <link>https://medium.com/@kakarlasarathreddy?source=rss-70031b8a6f36------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ph--nJ1Z0P6HjZaV</url>
            <title>Stories by Kakarlasarathreddy on Medium</title>
            <link>https://medium.com/@kakarlasarathreddy?source=rss-70031b8a6f36------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 02:40:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kakarlasarathreddy/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[Navigating the GenAI frontier-transformers , Gpt , and the path accelerated innovation]]></title>
            <link>https://medium.com/@kakarlasarathreddy/navigating-the-genai-frontier-transformers-gpt-and-the-path-accelerated-innovation-37a2ebd2033f?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/37a2ebd2033f</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Thu, 11 Apr 2024 04:32:00 GMT</pubDate>
            <atom:updated>2024-04-13T05:58:21.689Z</atom:updated>
            <content:encoded><![CDATA[<h4>Navigating the GenAI frontier-transformers , Gpt , and the path accelerated innovation</h4><ol><li>historical context:seq2seq paper and NMT by joining learning to align&amp; translate paper</li></ol><p>the two papers are important papers for neural translation system the two papers the seq2seq and neural machine translation by joining learning to align &amp; translate paper lets first discuss both the papers in detail of short note on it so that we get idea what’s the both the papers about</p><h4>1.seq2seq paper-</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hdbVzPg02NnKO_19.png" /></figure><p>it was published in 2014 by llya Sutskever , Oriol Vinyals , and Quoc V. Le in this paper introduces sequence to sequence model. introduced a revolutionary approach to sequence transduction tasks, such as machine translation and text summarization.</p><p>in detail, the seq2seq paper two recurrent neural networks (RNNs) connected in an encoder-decoder architecture.</p><h4>1.encoder:</h4><p>the input sequence is fed into the encoder RNN, which process the token by token it fixed-dimensions represents the semantic information about the entire sequence the vectors supports the initial stage for the decoder</p><h4>2.decoder:</h4><p>the decoder RNN takes the context vector from the vector as the initial hidden state and generates the output sequences token by token .at each stage it initial predicts the token based on the current hidden state and previously generated layer</p><h4>advantages and disadvantages of it</h4><ol><li>it can be handle in variable - length with input and output sequences.</li><li>end-to-end learning</li><li>flexibility</li><li>contextual learning</li><li>unified Architecture</li><li>state of art performers</li></ol><h4>2.Neural Machine Translation by Joint Learning to Align &amp; Translate:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*7xj0aK4BagwmPOX_.png" /></figure><p>the paper was published in 2015 and this paper was published by Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio this paper proposed an improvement to traditional Seq2Seq models by introducing an attention mechanism.</p><p>by allowing the model to focus on relevant part of the input during decoding This innovation addressed limitations of traditional Seq2Seq models, leading to significant improvements in translation accuracy and fluency.</p><h3>introduction to transformers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SvImZ2UIHkgr-2HB.png" /></figure><p>transformers are the division of deep learning we this transformers in the nlp process we use mainly about this transformers we can gained more information from this paper(Attention is all you need)by Vaswani et al. in 2017.</p><p>before transformers , rnn and cnn where mainly used in deep learning this both where widely used for sequential integration like text generation ,data pre processing. but how ever the traditional architectures have many limitations such as its has the Vanishing Gradient Problems ,capturing long-range dependence ,Parallelization</p><p>key important feathers of transformers</p><ol><li>Self-Attention Mechanism: This mechanism computes attention scores between all pairs of positions in an input sequence, enabling the model to weigh the importance of each token based on its relevance to other tokens in the sequence.</li></ol><p>2.Multi-Head Attention: To capture different types of dependencies at different positions, the self-attention mechanism is applied multiple times in parallel, with different learned linear projections of the input. These parallel attention mechanisms are referred to as “attention heads.”</p><p>3.Positional Encoding: Since Transformers do not inherently possess sequential order information like RNNs, positional encoding vectors are added to the input embeddings to provide the model with information about the positions of tokens in the sequence.</p><p>4.Feedforward Neural Networks: After applying self-attention, the model passes the resulting representations through a feedforward neural network layer, which introduces non-linearity and allows the model to learn complex transformations of the input.</p><p>5.Layer Normalization and Residual Connections: These techniques are used to stabilize and speed up training by normalizing the inputs to each layer and adding residual connections that help alleviate the vanishing gradient problem.</p><h4>Why transformers?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Zecg-PaNEw246uhy.png" /></figure><p>transformers have become more important and widely increasingly popular in various fields mostly in nlp(network language programming)its due to good performance of the model in many ways .</p><p>the main reason for this why transformers used widely</p><p>1.attention mechanism :the transformers uses attention mechanism that allows us to focus the revalant parts of the input to get better output</p><p>2.parallezation:unlike the rnn,the transformers can process the input sequencess the making them more effiecent way to perform well</p><p>3.Scalbility :the transformer can scale the to larger dataset and loger sequence by using techniques like attention masking and hierarchical attention mechanisms. This scalability is crucial for tasks involving extensive documents or corpora.</p><p>4.transferlearning:pre trained models -BERT,GPT,T5 have been used to get trined our dataset to get best output. in the we usd larg dataset andcorps to get best output</p><p>5.Flexibility: Transformers are highly flexible and can be adapted to different types of input data and tasks. For example, they have been successfully applied to not only text but also image processing, time series analysis, and even reinforcement learning.</p><h4>Explain the working of each transformer component.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*1Fxuk76gJYAH1dBE.png" /></figure><p>components of transformer</p><ol><li>input embedding</li></ol><p>— At the beginning of the transformer, each token in the input sequence is represented as a vector, typically using word embeddings or positional encodings.</p><ul><li>Word embeddings capture the semantic meaning of each token, while positional encodings provide information about the position of tokens in the sequence.</li></ul><p>2.self-attention mechanism</p><ul><li>The core of the transformer architecture is the self-attention mechanism, which allows the model to weigh the importance of each token in the input sequence when generating the output.</li><li>For each token in the input sequence, self-attention computes attention scores with respect to all other tokens, indicating how much focus should be given to each token during the encoding process.</li></ul><p>3.multi-head attention</p><p>To capture different types of information at different representation subspaces, the self-attention mechanism is usually applied multiple times in parallel, each with its own set of learned Query, Key, and Value matrices.</p><p>4.Feedforward Neural Networks (FFNN)</p><p>To capture different types of information at different representation subspaces, the self-attention mechanism is usually applied multiple times in parallel, each with its own set of learned Query, Key, and Value matrices.</p><p>5.Layer Normalization and Residual Connections</p><ul><li>Layer normalization is applied before each sub-layer (self-attention and FFNN) to stabilize the training process.</li><li>Additionally, residual connections are used to preserve information from the original input, which helps alleviate the vanishing gradient problem during training.</li></ul><p>6.output embedding-Finally, the output of the transformer model is passed through a linear transformation followed by a softmax layer to produce the final output probabilities for each token in the output sequence.</p><h4>5. How is GPT-1 trained from Scratch? (Take Reference from BERT and GPT-1 Paper)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEmi3ng9njEVkIYLZVbfkA.jpeg" /></figure><p>GPT-1, like other transformer-based models, is trained using a variant of the unsupervised learning approach known as self-supervised learning. In self-supervised learning, the model is trained on a large corpus of text data without explicit supervision, meaning that it doesn’t require labeled data for training. Instead, it learns to predict the next word in a sequence based on the context provided by preceding words.</p><p>Here’s an overview of how GPT-1 is trained from scratch, drawing reference from the BERT and GPT-1 papers:</p><ol><li>Pre-training Objective:</li></ol><ul><li>GPT-1 uses a pre-training objective known as “masked language modeling” (MLM), which is similar to BERT’s pre-training objective.</li><li>In MLM, a certain percentage of tokens in the input sequence are randomly replaced with a special “mask” token, and the model is trained to predict the original tokens based on the surrounding context.</li><li>Additionally, GPT-1 uses a left-to-right language modeling objective, where the model is trained to predict the next token in the sequence given the preceding tokens.</li></ul><p>2.Model Architecture:</p><ul><li>GPT-1 consists of a stack of transformer decoder layers, where each layer contains multiple attention heads and feedforward neural networks.</li><li>Unlike BERT, which utilizes bidirectional attention, GPT-1 employs a unidirectional left-to-right architecture, where each token can attend only to the preceding tokens in the sequence.</li></ul><p>3.Text Corpus:</p><ul><li>GPT-1 is trained on a large corpus of text data, typically sourced from books, articles, websites, and other textual sources.</li><li>The larger and more diverse the text corpus, the better the model’s ability to generalize to different domains and tasks.</li></ul><p>4.Tokenization:</p><ul><li>Before training, the text data is tokenized into subword or word-level tokens using a tokenizer such as Byte Pair Encoding (BPE) or WordPiece.</li><li>The tokens are then converted into token embeddings using an embedding layer, which initializes each token with a learned vector representation.</li></ul><p>5.Training Procedure:</p><ul><li>During training, the model is presented with input sequences of tokens, with a certain percentage of tokens randomly masked.</li><li>The model then predicts the original tokens for the masked positions based on the context provided by the surrounding tokens.</li><li>This process is iterated over multiple epochs, with the model’s parameters updated using techniques like stochastic gradient descent (SGD) or Adam optimization to minimize the prediction loss.</li></ul><p>6.Fine-Tuning:</p><ul><li>After pre-training, the GPT-1 model can be fine-tuned on specific downstream tasks using labeled data.</li><li>During fine-tuning, task-specific layers may be added on top of the pre-trained GPT-1 model, and the entire network is fine-tuned using supervised learning.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*iSufRmlxAp5gV1zQ.png" /></figure><p>“Explore cutting-edge data science and AI insights, with contributions from leading organizations like <a href="https://medium.com/u/c69a54cb6253">Innomatics Research Labs</a>.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37a2ebd2033f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[language modeling]]></title>
            <link>https://medium.com/@kakarlasarathreddy/language-modeling-8d3a504025cd?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d3a504025cd</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 16:34:43 GMT</pubDate>
            <atom:updated>2024-04-04T16:34:43.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bytrK3M-k2q94JzSSpdl0Q.jpeg" /></figure><p>here we are going to see about LLM and its working and how they are working in text data what is LLM, how does it work, what techniques does it used to build and examples of LLMs.</p><p>LLMS are also called as large Language Model are advanced AI systems designed to understand and generate human-like text. They work by leveraging deep learning techniques, such as transformer architectures, and are trained on vast amounts of textual data. LLMs excel at tasks like text generation, comprehension, and translation. Examples include GPT-3 and BERT. LLMs have diverse applications in natural language processing, including chatbots, sentiment analysis, and language translation.</p><h3><strong>what is a model?</strong></h3><p>In short, a model in the context of artificial intelligence is a mathematical representation learned from data that enables predictions or simulations of real-world phenomena.</p><p>A model in artificial intelligence is a learned representation of data that enables prediction or simulation. It learns from data by adjusting internal parameters, aiming to minimize the difference between predicted and actual outcomes. Once trained, it can make predictions on new data. Models vary in complexity and type, such as linear regression, decision trees, or neural networks, each suited to different tasks. Evaluation measures its performance, ensuring it generalizes well beyond the training data.</p><p><strong>What is Language Modeling?</strong></p><p>To put it simply, the Language Model is nothing more than recording the link between words and sentences in a language.</p><p>Language modeling is a technique in natural language processing (NLP) where statistical models are built to predict the next word in a sequence of words based on the context provided by the preceding words. It forms the basis for various NLP tasks like text generation, machine translation, and speech recognition.</p><h3>What is Large Language Model?</h3><p>A Large Language Model (LLM) is an advanced artificial intelligence system that excels in understanding and generating human-like text. These models are characterized by their immense size, complexity, and ability to process vast amounts of textual data. Large Language Models leverage deep learning techniques, particularly transformer-based architectures, and are trained on extensive datasets using unsupervised learning methods. Examples of Large Language Models include OpenAI’s GPT series (Generative Pre-trained Transformer) and Google’s BERT (Bidirectional Encoder Representations from Transformers). These models have a wide range of applications in natural language processing, including text generation, translation, sentiment analysis, and more.</p><ol><li>BERT — Bi-Directional Encoder Representative with Transformer by Google</li><li>GPT — Generative Pre-trained Transformer by OpenAI</li><li>Gemini AI by Google</li><li>LLaMA — Large Language Model by Meta AI</li><li>T5 — Text-To-Text Transfer Transformer by Google</li></ol><h4>What are the applications if we can model the language?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OKcL_XnJjEvuhRQ4.jpg" /></figure><p>Modeling language has numerous applications across various domains. Some key applications include:</p><ol><li>Text Generation: Language models can generate human-like text for various purposes, such as generating content for websites, creating product descriptions, or composing personalized messages.</li></ol><p>2.Machine Translation: Language models can be used to translate text from one language to another, enabling communication across language barriers. Systems like Google Translate rely on language modeling techniques for accurate translation.</p><p>3.Question Answering: Language models can answer questions posed in natural language by extracting relevant information from text sources. This application is useful for tasks like customer support, information retrieval, and virtual assistants.</p><p>4.Sentiment Analysis: Language models can analyze the sentiment expressed in text data, such as social media posts, customer reviews, or news articles. This application is valuable for businesses to understand customer feedback and public opinion.</p><p>5.Summarization: Language models can summarize large volumes of text into concise and coherent summaries. This application is useful for distilling key information from documents, news articles, or research papers.</p><p>6.Speech Recognition: Language models play a crucial role in speech recognition systems by converting spoken language into text. This application enables voice-controlled devices, virtual assistants, and dictation software.</p><p>7.Text Classification: Language models can classify text documents into predefined categories or labels based on their content. This application is used in spam detection, topic modeling, sentiment classification, and more.</p><p>8.Natural Language Understanding (NLU): Language models can understand the intent and meaning of text data, enabling more sophisticated interactions with machines. This application is essential for chatbots, virtual assistants, and intelligent systems.</p><p>9.Language Modeling as a Service (LMaaS): Companies offer language modeling as a service, providing APIs and tools for developers to integrate language modeling capabilities into their applications easily.</p><h4>How do you model a language?</h4><p>Language modeling tasks come in two varieties: A<strong>utoencoding</strong> tasks and A<strong>utoregressive</strong> tasks.<br>Based on the tokens that have come before in a sentence, <strong>autoregressive</strong> language models are trained to predict the token that will come after it. These models match the transformer model’s decoder portion. To ensure that the attention head sees just the tokens that came before it, a mask is applied to the entire sentence. These models are perfect for creating text. For instance, <strong>GPT</strong></p><ol><li>Data Collection: Gather extensive text data.</li><li>Model Selection: Choose transformer-based architecture (like GPT or BERT).</li><li>Pre-training: Train model on large corpus with unsupervised learning.</li><li>Fine-tuning: Adapt model to specific tasks or domains.</li><li>Evaluation: Assess model performance.</li><li>Iterative Refinement: Improve model based on evaluation results.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jBN_OqUuWwh7B85l.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d3a504025cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cost function]]></title>
            <link>https://medium.com/@kakarlasarathreddy/cost-function-3c921a77f7a1?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c921a77f7a1</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 03:29:53 GMT</pubDate>
            <atom:updated>2023-10-25T03:59:48.484Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>A cost function is an important parameter that determines how well a machine learning model performs for a given dataset.</em></strong> It calculates the difference between the expected value and predicted value and represents it as a single real number.</p><p>In machine learning, once we train our model, then we want to see how well our model is performing. Although there are various accuracy functions that tell you how your model is performing, but will not give insights to improve them. So, we need a function that can find when the model is most accurate by finding the spot between the undertrained and over trained model.</p><h3>Gradient Descent: Minimizing the cost function</h3><p>As we discussed in the above section, the cost function tells how wrong your model is? And each machine learning model tries to minimize the cost function in order to give the best results. Here comes the role of Gradient descent.</p><p><strong><em>“Gradient Descent is an optimization algorithm which is used for optimizing the cost function or error in the model.”</em></strong> It enables the models to take the gradient or direction to reduce the errors by reaching to least possible error. Here direction refers to how model parameters should be corrected to further reduce the cost function. The error in your model can be different at different points, and you have to find the quickest way to minimize it, to prevent resource wastage.</p><p>Gradient descent is an iterative process where the model gradually converges towards a minimum value, and if the model iterates further than this point, it produces little or zero changes in the loss. This point is known as convergence, and at this point, the error is least, and the cost function is optimized.</p><p>Below is the equation for gradient descent in linear regression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*MkwAfcs3ZgdSuRtS.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_3RALmN8CqgE720G.png" /></figure><h3>What is a loss/Cost function?</h3><p>‘Loss’ in Machine learning helps us understand the difference between the predicted value &amp; the actual value.</p><p>The Function used to quantify this loss during the training phase in the form of a single real number is known as the “Loss Function”.</p><p>These are used in those <a href="https://en.wikipedia.org/wiki/Supervised_learning">supervised learning</a> algorithms that use optimization techniques. The terms cost function &amp; loss function are analogous.</p><p><strong>Loss function:</strong> Used when we refer to the error for a single training example.<br><strong>Cost function:</strong> Used to refer to an average of the loss functions over an entire training data.</p><h3>Why Cost Function?</h3><p>Consider a scenario where we wish to classify data. Suppose we have the height &amp; weight details of some cats &amp; dogs. Let us use these 2 features to classify them correctly.</p><p>If we plot these records, we get the following scatterplot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/0*-EO3T-lUS_AsXB11.png" /></figure><p>Fig 1: Scatter Plot for Height &amp; Weight</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*u8XuGtd1Ae_OSIel.JPG" /></figure><p>Fig 2: Probable Solutions of classification problems</p><p>Blue dots are cats and red dots are dogs.</p><p>Essentially all three classifiers have very high accuracy but the third solution is the best because it does not misclassify any point. The reason why it classifies all the points perfectly is that the line is almost exactly in between the two groups, and not closer to any one of the groups. This is where the concept of cost function comes in. Cost function helps us reach the optimal solution. The cost function is the technique of evaluating “the performance of our algorithm/model”.</p><p>It takes both predicted outputs by the model and actual outputs and calculates how much wrong the model was in its prediction. It outputs a higher number if our predictions differ a lot from the actual values. As we tune our model to improve the predictions, the cost function acts as an indicator of how the model has improved. This is essentially an optimization problem. The optimization strategies always aim at “minimizing the cost function”</p><ol><li>The loss function computes the error for a single training example, while the cost function is the average of the loss functions of the entire training set</li><li>Definition:</li></ol><ul><li>Cost Function: Evaluates the overall cost or error associated with the system.</li><li>Loss Function: Measures the penalty or error between predicted and actual values.</li></ul><p>3.Application:</p><ul><li>Cost Function: Used in various fields such as economics, physics, and engineering.</li><li>Loss Function: Primarily used in the context of supervised machine learning.</li></ul><p>4.Objective:</p><ul><li>Cost Function: Minimizing the cost function may involve various system parameters.</li><li>Loss Function: Minimizing the loss function improves model predictive accuracy.</li></ul><p>5.Use in Machine Learning (ML):</p><ul><li>Cost Function: Relevant when understanding system behavior beyond just training.</li><li>Loss Function: Specifically used during the model optimization and training process.</li></ul><p>6.Examples:</p><ul><li>Cost Function: Utility function, risk function, objective function.</li><li>Loss Function: Mean squared error, mean absolute error, cross-entropy loss.</li></ul><h3>Types of the cost function</h3><p>There are many cost functions in machine learning and each has its use cases depending on whether it is a regression problem or classification problem.</p><ol><li>Linear Regression:</li></ol><ul><li>Mean Squared Error (MSE):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/163/0*dWVdat3f4wDF1Y2-.png" /></figure><p>2.Logistic Regression:</p><ul><li>Binary Cross-Entropy (Log Loss)</li></ul><h4>Cross-entropy(D) = — y*log(p) when y = 1</h4><h4>Cross-entropy(D) = — (1-y)*log(1-p) when y = 0</h4><p>The error in binary classification is calculated as the mean of cross-entropy for all N training data. Which means:</p><h4>Binary Cross-Entropy = (Sum of Cross-Entropy for N data)/N</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*gGhqHSB3y43unMuvURmuwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*BMFEZK6g7lcJjDhWcEdpJA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c921a77f7a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fuzzy Wuzzy]]></title>
            <link>https://medium.com/@kakarlasarathreddy/fuzzy-wuzzy-35376913ed98?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/35376913ed98</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 17:05:46 GMT</pubDate>
            <atom:updated>2023-09-25T17:05:46.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*yJIcfX-VUgBg_SsWADMw5A.png" /></figure><p>The term “Fuzzy Wuzzy algorithm” typically refers to a specific type of fuzzy string matching algorithm used for text comparison and similarity measurement. Fuzzy string matching is a technique used in computer science and natural language processing to find strings that are approximately equal to a given pattern. It’s useful for tasks like spell checking, data deduplication, and record linkage, where exact matches may not be available or appropriate.</p><p>we have many methods of comparing string in python ,some the main methods are</p><ol><li>Using regex</li><li>simple compare</li><li>using diff lib</li></ol><p>but by using fuzzy Wuzzy library we where we can have a score out of 100, that denotes two string are equal by giving similarity index. This article talks about how we start using fuzzy Wuzzy library.</p><p>Fuzzy Wuzzy is a library of Python which is used for string matching. Fuzzy string matching is the process of finding strings that match a given pattern. Basically it uses Levenshtein distance to calculate the differences between sequences.<br><a href="https://github.com/seatgeek/fuzzywuzzy">Fuzzy Wuzzy</a> has been developed and open-sourced by SeatGeek, a service to find sport and concert tickets</p><h4>What is Fuzzy Wuzzy library in Python?</h4><p>Fuzzy Wuzzy is a Python library that uses Leven shtein distance to calculate the differences between sequences and patterns. It was developed and also open-sourced by SeatGeek, a service that finds event tickets from all over the internet and showcases them on one platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/0*YYOFDEcsQ5K50Mqu.jpg" /></figure><h3>FuzzyWuzzy</h3><p>Fuzzy Wuzzy is an open-source library developed and released by SeatGeek. You can read their original blog <a href="https://chairnerd.seatgeek.com/fuzzywuzzy-fuzzy-string-matching-in-python/">here</a>. The simple implementation and the unique score (out of 100) metic makes it interesting to use Fuzzy Wuzzy for text comparison and it has numerous applications.</p><p>It is a process of finding strings that match a given pattern. It uses <strong>Levenshtein Distance</strong> to calculate the difference between sequences.</p><h3>Example</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*6kioWhtINuvfIUdTRsAZXA.png" /></figure><pre>True</pre><p>The above code returns true because strings are matched an exactly (100 %), what if we make the change in str2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*hCzHPuqCLd5ycIJ2M-f9Aw.png" /></figure><pre>False</pre><p><em>Here the above code returns the false, and strings are pretty identical to the human eyes, but not for the interpreter. However, we can solve this problem by converting both strings to lower case.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*xAQgSqzq7VEkmmtfwNQfhg.png" /></figure><pre>True</pre><p>But if we make changes in charset, we will get another problem</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*6kioWhtINuvfIUdTRsAZXA.png" /></figure><pre>True</pre><p>To resolve such types of problems, we need more effective tools to compare the strings. And fuzzywuzzy is the best tool to calculate the strings.</p><h3>The Levenshtein Distance</h3><p>The <strong>levenshtein distance</strong> is used to calculate the distance between two sequences of words. It calculates the minimum number edits that we need to change in the given string. These edits can be insertion, deletions or substitution.</p><p>example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*9gkbAtKNRmFRhruu7qZB2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*1j-KNZ122q6eH-qHXwd7fQ.png" /></figure><h3>The FuzzyWuzzy Package</h3><p>The name of this library something weird and funny, but it is advantageous. It has a unique way to compare both strings and returns the score out of 100 of how much string is matched. To work with this library, we need to install it in our Python environment.</p><h3>Fuzz Module</h3><p>The fuzz module is used to compare the two given string at a time. It returns a score out of 100 after comparison using the different methods.</p><h3>Fuzz.ratio()</h3><p>It is one of the important methods of fuzz module. It compares the string and score on the basis of how much the given string are matched. Let’s understand the following example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*rupysKtpswiAii5QJlB8RA.png" /></figure><h3>Fuzz.partial_ratio()</h3><p>The <strong>fuzzywuzzy</strong> library provides another powerful method — <strong>partial_ratio().</strong> It is used to handle the complex string comparison such as substring matching. Let’s see the following example.</p><p>Example -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*uKAmP-lMH1ti-YLucTnEnA.png" /></figure><h3>Fuzz.token_sort_ratio</h3><p>This method does not guarantee to get an accurate result because if we make the changes in the order of string. It may not give an accurate result.</p><p>But fuzzy wuzzy module provides the solution. Let’s understand the following example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*rrpVVwdXTwEH62ZRNO2RfA.png" /></figure><p>The fuzzywuzzy package provides the <strong><em>process</em></strong> module that allows us to calculate the string with the highest similarity. Let’s understand the following example.</p><p><strong>Example -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*qmW2jaGPoZcpb9YOT3xxwg.png" /></figure><h3>Conclusion</h3><p>In this tutorial, we have discussed how to match the string and determine how closely they are. We have illustrated the simple example but they are enough to clear that how computer treats the mismatched strings. Many real-life applications such as spell checking, bioinformatics to match, DNA sequence etc. are based on the fuzzy logic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35376913ed98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KNN-imputer]]></title>
            <link>https://medium.com/@kakarlasarathreddy/knn-imputer-4dfd8490509e?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/4dfd8490509e</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 15:59:40 GMT</pubDate>
            <atom:updated>2023-09-25T15:59:40.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HW2HbwtE9XjllsH4.png" /></figure><p><strong>KNN imputer</strong> is a scikit -learn class used to fill out or predict the missing values in a dataset. It is a more useful method which works on the basic approach of the KNN algorithm rather than the naïve approach of filling all the values with mean or the median.</p><p>in this approach we specifies the distance from the missing value which is also know as k imputer this missing values will be predicated in references to mean of the neighbour .It is implemented by the <strong>KNN imputer() </strong>method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/0*VTlGgPm9d8zOi4c5.png" /></figure><p>In today’s world, data is being collected from a number of sources and is used for analyzing, generating insights, validating theories, and whatnot. This data collected from different resources may often have some information missing. This may be due to a problem in the data collection or extraction process that could be a human error.</p><p>Dealing with these missing values, thus becomes an important step in data preprocessing. The choice of method of imputation is crucial since it can significantly impact one’s work.</p><p>To see this imputer in action, we will import it from Scikit-Learn’s impute package -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/0*tWe8PEbHU1c_61LE.png" /></figure><p>One thing to note here is that the KNN Imputer does not recognize text data values. It will generate errors if we do not change these values to numerical values. For example, in our Titanic dataset, the categorical columns ‘Sex’ and ‘Embarked’ have text data.</p><p>A good way to modify the text data is to perform one-hot encoding or create “dummy variables”. The idea is to convert each category into a binary data column by assigning a 1 or 0. Other options would be to use Label Encoder or Ordinal Encoder from Scikit - Learn’s preprocessing package.</p><p>cat_ variables = df[[‘Sex’, ‘Embarked’]]<br>cat_ dummies = pd. get_ dummies(cat_ variables, drop _first=True)<br>cat_ dummies. head()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/0*HYrVSThinDzJPoMs.png" /></figure><p>Now we have 3 dummy variable columns. In the “Sex_ male” column, 1 indicates that the passenger is male and 0 is female. The “Sex_ female” column is dropped since the “drop_ first” parameter is set as True. Similarly, there are only 2 columns for “Embarked” because the third one has been dropped.</p><p>Next, we will drop the original “Sex” and “Embarked” columns from the data frame and add the dummy variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/0*aO4ZZYAyLnfHHpJH.png" /></figure><p>Another critical point here is that the KNN Imptuer is a distance-based imputation method and it requires us to normalize our data. Otherwise, the different scales of our data will lead the KNN Imputer to generate biased replacements for the missing values. For simplicity, we will use Scikit-Learn’s MinMaxScaler which will scale our variables to have values between 0 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*JOUxJRAUfDdD6N7P.png" /></figure><p>Now that our dataset has dummy variables and normalized, we can move on to the KNN Imputation. Let’s import it from Scikit-Learn’s Impute package and apply it to our data. In this example, we are setting the parameter ‘n_neighbors’ as 5. So, the missing values will be replaced by the mean value of 5 nearest neighbors measured by Euclidean distance.</p><h3>Conclusion</h3><p>There are different ways to handle missing data. Some methods such as removing the entire observation if it has a missing value or replacing the missing values with mean, median or mode values. However, these methods can waste valuable data or reduce the variability of your dataset. In contrast, KNN Imputer maintains the value and variability of your datasets and yet it is more precise and efficient than using the average values.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4dfd8490509e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Weighted K-NN]]></title>
            <link>https://medium.com/@kakarlasarathreddy/weighted-k-nn-2bd580daafe1?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bd580daafe1</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 10:34:51 GMT</pubDate>
            <atom:updated>2023-09-25T10:34:51.850Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*ASwCNO3aX8TwSZ5a" /></figure><p><strong>Weighted </strong>k-NN is a modified version of k nearest neighbors. One of the many issues that affect the performance of the k-NN algorithm is the choice of the hyperparameter k. If k is too small, the algorithm would be more sensitive to outliers. If k is too large, then the neighborhood may include too many points from other classes.</p><p>lets consider any example of training data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/0*htMpiSvDWXG9HWCh.png" /></figure><p>the red ball indicate the class 0 and blue ball indicate class1.then now consider a white ball of query( the point whose class label has to be predicted)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/0*eS1dHjQEH8Y0KdNl.png" /></figure><p>If we give the above dataset to a k-NN based classifier, then the classifier would declare the query point to belong to the class 0. But in the plot, it is clear that the point is more closer to the class 1 points compared to the class 0 points. To overcome this disadvantage, weighted k-NN is used. In weighted k-NN, the nearest k points are given a weight using a function called as the kernel function. The intuition behind weighted kNN, is to give more weight to the points which are nearby and less weight to the points which are farther away. Any function can be used as a kernel function for the weighted knn classifier whose value decreases as the distance increases. The simple function which is used is the inverse distance function.</p><p><strong>Algorithm:</strong></p><ul><li>Let L = { ( xi , yi ) , i = 1, . . . ,n } be a training set of observations xi with given class yi and let x be a new observation(query point), whose class label y has to be predicted.</li><li>Compute d(xi, x) for i = 1, . . . ,n , the distance between the query point and every other point in the training set.</li><li>Select D’ ⊆ D, the set of k nearest training data points to the query points</li><li>Predict the class of the query point, using distance-weighted voting. The v represents the class labels. Use the following formula</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/0*4Wov0EmgGHHkvymK.jpg" /></figure><p>To overcome this disadvantage, weighted k-NN is used.</p><p>In weighted k-NN, the nearest k points are assigned a weight. The intuition behind weighted KNN is to give more weight to the points which are nearby and less weight to the points which are farther away…</p><p>The simple function which is used is the inverse distance function which implies that as the distance increases weight decreases and as the distance decreases, weight increases</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bd580daafe1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image pre processing]]></title>
            <link>https://medium.com/@kakarlasarathreddy/image-pre-processing-5fe4f1fd2891?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fe4f1fd2891</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 21 Aug 2023 02:33:29 GMT</pubDate>
            <atom:updated>2023-08-28T10:53:47.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/775/0*9ZO6EFW2zr_YFM7U" /></figure><p>Image preprocessing refers to a series of techniques and steps applied to raw images before they are fed into a machine learning model or computer vision algorithm for further analysis or processing. The goal of image preprocessing is to enhance the quality of the images, reduce noise, and extract relevant features that can improve the performance of the subsequent tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/0*zRleL-XLl50TyP8N.png" /></figure><h4><strong>Tools for image pre processing</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*TbDw920xYDIS9moh.jpg" /></figure><h3>Visualizing RGB Channels</h3><p>To split the image into each RGB colors, you can use the below code:</p><pre>img = np.array(Image.open(&#39;emma_stone.jpg&#39;))<br>img_R, img_G, img_B = img.copy(), img.copy(), img.copy()<br>img_R[:, :, (1, 2)] = 0<br>img_G[:, :, (0, 2)] = 0<br>img_B[:, :, (0, 1)] = 0<br>img_rgb = np.concatenate((img_R,img_G,img_B), axis=1)<br>plt.figure(figsize=(15, 15))<br>plt.imshow(img_rgb)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_co4AbBPigRPRhq3.PNG" /></figure><h3><strong>RGB</strong></h3><p>RGB (Red, Green, Blue) image processing in machine learning involves working with images that are represented as a combination of three color channels: red, green, and blue. Each pixel in an RGB image is composed of intensity values for these three channels, which together create the full spectrum of colors that we perceive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*2WZVALU8Fho1Kf9VvByeOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*ZYVRLpsdMzT0P2UDU4J8hw.png" /></figure><p>Before we start exploring preprocessing techniques, let’s first explore the RGB channels of our original image;</p><pre># plotting the original image and the RGB channels  <br><br>i, (im1, im2, im3, im4) = plt.subplots(1, 4, sharey=True)<br>i.set_figwidth(20) <br><br>im1.imshow(image)  #Original image<br>im2.imshow(image[:, : , 0]) #Red<br>im3.imshow(image[:, : , 1]) #Green<br>im4.imshow(image[:, : , 2]) #Blue<br>i.suptitle(&#39;Original &amp; RGB image channels&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/0*0l0B7hkePaSzPBE7.png" /></figure><h4><strong>Flipping</strong></h4><p>Flipping images is a common technique in image preprocessing for data augmentation. It involves creating new training examples by horizontally or vertically flipping existing images. This technique helps the model become more robust to variations in object orientations and can increase the diversity of your training dataset. Here’s how flipping images is typically applied in image preprocessing:</p><p><strong>Horizontal Flipping:</strong> Horizontal flipping involves creating a mirror image of the original image along a vertical axis. For example, if the original image contains a person facing right, the horizontally flipped version would show the person facing left.</p><p><strong>Vertical Flipping</strong>: Vertical flipping involves creating a mirror image of the original image along a horizontal axis. This can be useful for certain tasks, but it might not be as commonly used as horizontal flipping.</p><pre># ImageDataGenerator for flipping<br>datagen = ImageDataGenerator(horizontal_flip=True, vertical_flip=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/0*EIn775rJeSdMv0yX.png" /></figure><p><strong>sub plot for images</strong></p><p>Using subplots in image processing within machine learning can be helpful when you want to visualize multiple images or their processing results together for comparison or analysis. The matplotlib library in Python provides a way to create subplots, allowing you to display multiple images in a single figure</p><pre>fig, axarr = plt.subplots(2,2)<br>axarr[0,0] = plt.imshow(image_datas[0])<br>axarr[0,1] = plt.imshow(image_datas[1])<br>axarr[1,0] = plt.imshow(image_datas[2])<br>axarr[1,1] = plt.imshow(image_datas[3])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4LWlvjvn0RAFEDaf.jpg" /></figure><h4><strong>Roll image</strong></h4><p>Rolling an image in image preprocessing refers to shifting the pixels along one or both dimensions (horizontal and vertical) to create a visual effect similar to rolling a piece of paper. Rolling can be used for various purposes, such as simulating camera motion, creating panoramic views, or generating augmented data for machine learning. Here’s how you can perform image rolling using Python and the numpy library</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gOwEmRl3Z_CzqPI2Qhk9HA.png" /></figure><h4><strong>Rotation</strong></h4><p>In image processing, rotation refers to the process of changing the orientation of an image by a specific angle around a chosen point or center. This is a common operation used to adjust the positioning of images, correct alignment, or achieve artistic effects. Image rotation can be performed through various methods, each with its own advantages and use cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*OXlaXwRH2_zGhqmd49w9Pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/0*46dwVMe_B790qzX6.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*0FMRmNPPQBc1CXwvcauuRQ.png" /></figure><h4><strong>Changing brightness</strong></h4><p>This is the process of increasing or decreasing image contrast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*MIg1bC0J7QBKBhsW-AbzJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/0*-trCrZuafyu_vc45.png" /></figure><h4><strong>Cropping</strong></h4><p>This is the process of creating a random subset of an original image which is then resized to the size of the original image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*l0hWfz5dEpb125GJrFfqYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*rr0ydPDzq5sqLckPGNkn-w.png" /></figure><h4><strong>Image Enhancers</strong></h4><p>Image enhancement is the process of adjusting digital images so that the results are more suitable for display or further image analysis. For example, you can remove noise, sharpen, or brighten an image, making it easier to identify key features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*37NtRQN6dPCQHywA2UVd3g.jpeg" /></figure><p>types of Enhancing: colour , brightness , contrasrt</p><h4>Color Enhancement:</h4><ul><li>Color Balance Adjustment: Tweaking the balance of colors in an image to correct color cast or to achieve a desired color effect.</li><li>Color Channel Equalization: Equalizing the histograms of individual color channels (R, G, B) to improve color distribution and vibrancy.</li><li>Saturation Adjustment: Enhancing or reducing the intensity of colors to make images more vivid or muted.</li></ul><h4>Brightness Enhancement:</h4><ul><li>Gamma Correction: Adjusting pixel intensities using a gamma value to control brightness levels.</li><li>Histogram Stretching: Rescaling pixel values to span the full dynamic range, effectively increasing contrast and brightness.</li><li>Exposure Adjustment: Simulating changes in exposure settings to brighten or darken images.</li></ul><h4>Contrast Enhancement:</h4><ul><li>Histogram Equalization: Spreading out pixel intensities to better utilize the full range, enhancing contrast and details.</li><li>Adaptive Contrast Enhancement: Applying histogram equalization to local regions, preserving details while improving contrast.</li><li>CLAHE (Contrast Limited Adaptive Histogram Equalization): A variant of adaptive histogram equalization that prevents excessive amplification of noise</li></ul><h4>filters</h4><p>basicFilters = [‘BLUR’, ‘CONTOUR’, ‘DETAIL’, ‘EDGE_ENHANCE’, ‘EDGE_ENHANCE_MORE’, ‘EMBOSS’, ‘FIND_EDGES’, ‘SHARPEN’, ‘SMOOTH’, ‘SMOOTH_MORE’]</p><h4>BasicFilters</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*nxzyGmgoakBfNh5v8Y-RdA.png" /></figure><h4>BLUR:</h4><ol><li>Effect: Applies a simple blur effect to the image.</li><li>Use: Smoothing, reducing high-frequency noise.</li></ol><h4>CONTOUR:</h4><p>Effect: Emphasizes edges by highlighting abrupt intensity changes.</p><p>Use: Edge detection, simplifying image structure.</p><h4>DETAIL:</h4><p>Effect: Enhances details and textures in the image.</p><ul><li>Use: Accentuating fine patterns and textures.</li></ul><h4>EDGE_ENHANCE:</h4><ul><li>Effect: Emphasizes edges, similar to sharpening.</li><li>Use: Edge enhancement, improving edge visibility.</li></ul><h4>EMBOSS:</h4><ul><li>Effect: Creates a 3D-like effect by enhancing edges and depressions.</li><li>Use: Adding depth and texture to images.</li></ul><h4>FIND_EDGES:</h4><p>.Effect: Emphasizes edges by detecting sudden intensity changes.</p><ul><li>Use: Edge detection, preparing images for further processing.</li></ul><h4>SHARPEN:</h4><ul><li>Effect: Increases contrast along edges, enhancing image sharpness.</li><li>Use: Sharpening images, improving overall clarity.</li></ul><h4>SMOOTH:</h4><ul><li>Effect: Applies a gentle smoothing effect to the image.</li><li>Use: Noise reduction, blurring for subtle softening.</li></ul><h4>RankFilters = [‘MaxFilter’, ‘MedianFilter’, ‘MinFilter’, ‘ModeFilter’]</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*TT1C5f82U8F0dpChXE2dAw.png" /></figure><p>multiBandFilters = [‘BoxBlur’, ‘UnsharpMask’, ‘GaussianBlur’]</p><h4>multiBandFilters</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*aDIKf8SwQUv2Aa4R0h7HdA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fe4f1fd2891" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Leakage]]></title>
            <link>https://medium.com/@kakarlasarathreddy/data-leakage-884b5c28ab45?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/884b5c28ab45</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 14:16:08 GMT</pubDate>
            <atom:updated>2023-08-14T15:46:35.695Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LQOgP_xQN9hsqdxm.jpg" /></figure><p>A data leak is when information is exposed to unauthorized people due to internal errors. This is often caused by poor data security and sanitization, outdated systems, or a lack of employee training. Data leaks could lead to identity theft, data breaches, or ransomware installation.</p><ol><li>Data leakage threats usually occur via the web and email, but can also occur via mobile data storage devices such as optical media, USB keys, and laptops.</li><li>Data leakage occurs when information from the test or validation data unintentionally leaks into the training process, leading the model to make erroneous predictions.</li></ol><h4>How data leakage effect the model?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*euG_iqFcdeHcSihr.jpg" /></figure><ol><li><strong>Overfitting</strong>: Data leakage often leads to overfitting, where the model captures noise and random variations in the training data, rather than learning the true underlying patterns. This can cause the model to perform well on the training data but poorly on new, unseen data.</li><li><strong>Inflated Performance Metrics</strong>: Leakage can artificially inflate evaluation metrics like accuracy, precision, and recall during model development. This can give a false sense of the model’s effectiveness and lead to poor decisions when deploying the model in real-world scenarios.</li><li><strong>Unrealistic Generalization</strong>: Models affected by data leakage might generalize poorly to new data since they have learned specific patterns present in the training data that do not exist in the broader population.</li></ol><p>4.<strong>Misleading Feature Importance</strong>: Leakage can cause the model to assign high importance to features that are not truly predictive but happen to be correlated with the target due to the leakage. This can misguide feature selection and interpretation efforts.</p><p>5.<strong>Privacy and Security Concerns</strong>: Data leakage can result in exposing sensitive or confidential information, which can have legal, ethical, and security implications.</p><p>6.<strong>Model Robustness</strong>: A model trained with data leakage may not be robust to changes or variations in the input data, making it less reliable in real-world scenarios.</p><h4>how to avoid or prevent model from data leaking</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*N39vPakhTTzMTgeo.jpg" /></figure><p><strong>1.Data Splitting</strong>: Divide the dataset into distinct training, validation, and test sets. Ensure that there is no overlap between the sets.</p><p><strong>2.Feature Engineering:</strong> Be cautious when creating features from the data. Ensure that the features are based solely on information that would be available at the time of prediction.</p><p><strong>3.Temporal Consistency</strong>: If working with time-series data, ensure that the data split respects the temporal order to prevent future information from leaking into the past.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*124i-yQOQe76Moun.png" /></figure><p><strong>4.Cross-Validation</strong>: Use proper cross-validation techniques to assess model performance. This helps to validate the model’s generalization capabilities and reduce the risk of overfitting.</p><p><strong>5.Feature Scaling</strong>: Perform feature scaling and preprocessing within the cross-validation loops to avoid information leakage.</p><p><strong>6.Domain Knowledge</strong>: Understand the domain and the data thoroughly to identify potential sources of leakage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IOuOLbXJb3z_cRgK.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=884b5c28ab45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tabular pre processing-Categorical encoding]]></title>
            <link>https://medium.com/@kakarlasarathreddy/categorical-encoding-6583f1d93578?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/6583f1d93578</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 13:40:39 GMT</pubDate>
            <atom:updated>2023-08-28T11:09:35.785Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/756/0*sMfIy5pgbSgSYjG5.png" /></figure><p>Encoding categorical data is a process of converting categorical data into integer format so that the data with converted categorical values can be provided to the different models. In the field of data science, before going for the modelling, data preparation is a mandatory task.</p><p>There are plenty of methods to encode categorical variables into numeric and each method comes with its own advantages and disadvantages.</p><p>To discover them, we will see the following ways to encode categorical variables:</p><ol><li>One-hot/dummy encoding</li><li>Label / Ordinal encoding</li><li>Target encoding</li><li>Frequency / count encoding</li><li>Binary encoding.</li><li><strong>One-hot/dummy encoding:</strong></li></ol><p>One hot encoding is a technique that we use to represent categorical variables as numerical values in a machine learning model. One Hot Encoding can be defined as a process of transforming categorical variables into numerical format before fitting and training a Machine Learning algorithm. For each categorical variable, One Hot Encoding produces a numeric vector with a length equal to the number of categories present in the feature.</p><p><em>Example :</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*XIrCuBFQ_ufb9j9pIE7N7Q.png" /></figure><p><strong>Advantages :</strong></p><ol><li>One-hot encoding ensures that machine learning does not assume that higher numbers are more important. For example, the value ‘8’ is bigger than the value ‘1’, but that does not make ‘8’ more important than ‘1’. The same is true for words: the value ‘laughter’ is not more important than ‘laugh’.</li><li>It can help to avoid the problem of ordinality, which can occur when a categorical variable has a natural ordering (e.g. “small”, “medium”, “large”)</li></ol><p><strong>Dis — advantages :</strong></p><ol><li>Because this procedure generates several new variables, it is prone to causing a large problem (too many predictors) if the original column has a large number of unique values. Another disadvantage of one-hot encoding is that it produces multicollinearity among the various variables, lowering the model’s accuracy.</li><li>It can lead to overfitting, especially if there are many categories in the variable and the sample size is relatively small.</li></ol><p><strong>2 .Leave — one-out encoding:</strong></p><p>Leave one out encoding is just target encoding where the average or expected value is calculated ignoring the value in the current row.</p><p>examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*ED407N2l7_Fvs7oeQt1MNw.png" /></figure><p><strong>Advantages of Leave-One-Out Encoding:</strong></p><ol><li>Capturing Category Relationships: Leave-one-out encoding can capture valuable information about the relationships between categories and the target variable by considering the behavior of similar instances while encoding.</li><li>Applicability to Small Datasets: Leave-one-out encoding might work well on small datasets where other encoding techniques, like one-hot encoding, could lead to high-dimensional data and potential over fitting.</li></ol><p><strong>Disadvantages of Leave-One-Out Encoding:</strong></p><ol><li>Increased Complexity: Leave-one-out encoding can introduce additional complexity to the encoding process, as it requires calculating and incorporating statistics based on neighboring instances for each observation.</li><li>Sensitivity to Noise: Since leave-one-out encoding relies on the behavior of similar instances, it can be sensitive to noise or outliers in the data. Extreme values could lead to inaccurate encodings.</li><li>Potential Over fitting: While leave-one-out encoding aims to reduce data leakage, it might still introduce a level of over fitting if not properly controlled or regularized.</li></ol><p><strong>Cardinality</strong></p><p>it refers to the number of distinct values or categories within a categorical variable. In other words, it measures the diversity or uniqueness of the data within that variable.</p><p>For example, the variable “US State” is one that has 50 possible values. Dealing with high cardinality turned out to be one of the most interesting parts of the challenge.</p><p><strong>Frequency encoding</strong></p><p>It is a way to utilize the frequency of the categories as labels. In the cases where the frequency is related somewhat with the target variable, it helps the model to understand and assign the weight in direct and inverse proportion, depending on the nature of the data.</p><p><strong>example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dOYm-gY0cTrxBb6U.jpg" /></figure><h4>Target encoding</h4><p>the process of replacing a categorical value with the mean of the target variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*aMfp7YIg1dU07Wug.png" /></figure><h4>leave one out target encoding</h4><p>target encoding where the average or expected value is calculated ignoring the value in the current row. the process of replacing a categorical value with the mean of the target variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*V9mT-GLq0Gwj60Ngm80Jgw.png" /></figure><h4><strong>4 fold cross validation</strong></h4><p>In the 4-fold crossvalidation method, all sample data were split into four groups. One group was set as the test data and the remaining three groups were set as the training and validation data. An average of four times of investigations was estimated as the performance of the machine learning mode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/0*eJz0u8Syz69S3sRA.png" /></figure><h4><strong>validation</strong></h4><p>In machine learning, model validation is referred to as the process where a trained model is evaluated with a testing data set. The testing data set is a separate portion of the same data set from which the training set is derived.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/0*NrtC9dqgcScdu8O-" /></figure><h3>Column Transformer</h3><p>Column Transformer is a sciket-learn class used to create and apply separate transformers for numerical and categorical data. To create transformers we need to specify the transformer object and pass the list of transformations inside a tuple along with the column on which you want to apply the transformation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*JJUVfOfduwpGNn5j.png" /></figure><h3>Label Encoding</h3><p><strong>Label Encoding</strong> is a technique that is used to convert categorical columns into numerical ones so that they can be fitted by machine learning models which only take numerical data. It is an important pre-processing step in a machine-learning project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*ExSSusX8ChNoEBP2.jpg" /></figure><h4><strong>Binary encoding</strong></h4><p>Binary encoding uses the binary digit, or <em>bit</em>, as the fundamental unit of information, and a bit may only be a ‘0’ or a ‘1’ (only two possibilities since it is a binary-encoded system). By combining bits, numbers larger than 0 or 1 may be represented, and these bit collections are called <em>words</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y1guGTkSbBO9T5ul.png" /></figure><h3>Pipeline</h3><p>On the basis of the use cases of the ML model and the requirement of the organization, each machine learning pipeline may be different to some extent. However, each pipeline follows/works upon the general workflow of Machine learning, or there are some common stages that each ML pipeline includes. Each stage of the pipeline takes the output from its preceding stage, which acts as the input for that particular stage. A typical ML pipeline includes the following stages:</p><p><em>1. </em><strong><em>Data Ingestion</em></strong></p><p><strong><em>2. Data Validation</em></strong></p><p><strong><em>3. Data Pre-processing</em></strong></p><p><strong><em>4. Model Training &amp; Tuning</em></strong></p><p><strong><em>5. Model Analysis</em></strong></p><p><strong><em>6.Model Versioning</em></strong></p><p><strong><em>7.Model Deployment</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z_7V9M9WjbE02L47.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6583f1d93578" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine learning]]></title>
            <link>https://medium.com/@kakarlasarathreddy/machine-learning-780091aa5078?source=rss-70031b8a6f36------2</link>
            <guid isPermaLink="false">https://medium.com/p/780091aa5078</guid>
            <dc:creator><![CDATA[Kakarlasarathreddy]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 01:37:53 GMT</pubDate>
            <atom:updated>2023-08-14T01:37:53.998Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Normalization types:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ZUtKLLcwAp__C2U7.png" /></figure><p>Normalization is a data preprocessing technique used to transform features to a common scale, helping machine learning algorithms work better and converge faster. There are several types of normalization methods, each with its own advantages and use cases.</p><h4>&gt; MinMax Scaling</h4><h4>&gt; Mean Scaling</h4><h4>&gt;Absolute Maximum Scaling</h4><p><strong>1)Min-Max Scaling</strong> (Min-Max Normalization):</p><p>. Scales features to a specified range, often between 0 and 1.</p><ul><li>Formula: X_normalized = (X - X_min) / (X_max - X_min)</li><li>Useful when features have a clear minimum and maximum value.</li></ul><ol><li><strong>1 Mean Scaling</strong></li></ol><p><em>mean Scaling, also known as Centering, is a data preprocessing technique used to shift the values of a feature so that they have a mean of zero. It involves subtracting the mean of the feature from each data point, effectively centering the data around zero. This technique is particularly useful when the mean of the feature is significant for the analysis, or when you want to remove any potential bias caused by the mean.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*bPgaWHaSCsY1eLnH.png" /></figure><p><em>X(scaled) = x(old) — x(MEAN)/x(max) — x(min)</em></p><ul><li>Where:</li><li>X_centered is the centered data.</li><li>X represents the original dataset.</li><li>mean(X) is the mean of the original dataset.</li></ul><h3>1.2 Absolute Maximum Scaling</h3><ul><li>We should first select the maximum absolute value out of all the entries of a particular measure.</li><li>Then after this, we divide each entry of the column by this maximum value.</li><li>we will observe that each entry of the column lies in the range of -1 to 1.</li><li>But this method is not used that often the reason behind this is that it is too sensitive to the outliers.</li></ul><h4>Formula: X(scaled) = x(old) — Max(|x|)/ Max(|x|)</h4><ul><li>x(old): it represents the original value of a data point</li><li>MAX(|x|):This is the absolute maximum value of the dataset, calculated by taking the maximum value of the absolute values of all data points.</li><li>x(scaled):This is the scaled value of the data point after applying the formula.</li></ul><h3><strong>SK learning</strong></h3><p>Scikit-learn is an open-source library that provides simple and efficient tools for data mining and data analysis. It is built on top of other scientific computing libraries like NumPy, SciPy, and matplotlib. Scikit-learn is designed to be user-friendly and accessible, making it a great choice for beginners and experienced data scientists alike.</p><p><a href="https://scikit-learn.org/stable/documentation.html">for sk learning https://scikit-learn.org/stable/documentation.html</a></p><h4>2.STANDARDIZATION</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*P-4OLKUU2wVPuYZtS-UOsQ.jpeg" /></figure><p>Standardization, also known as Z-Score Normalization, is a common data preprocessing technique used to transform features so that they have a mean of 0 and a standard deviation of 1. This process helps bring features to a common scale, making them comparable and suitable for algorithms that assume Gaussian-distributed data or require features to be centered around zero.</p><h4>formula: X(scaled) =x(old) — MEAN/standard deviation</h4><p>or <em>x </em>standardized​=<em>x</em>−<em>μ</em>​ /<em>σ</em></p><p>where :X_ standardized is the standardized feature.</p><p>x represents the original feather,</p><p>mean(X) is the mean (average) of the original feature.</p><p>standard_deviation(X) is the standard deviation of the original feature.</p><h3>3.ROBUST SCALING</h3><p>Robust Scaling, also known as Robust Standardization, is a data preprocessing technique used to scale features in a way that is robust to the presence of outliers. It is similar to Z-Score Normalization (Standardization), but instead of using the mean and standard deviation, Robust Scaling uses the median and the interquartile range (IQR) to scale the data.</p><p>formula: x (scaled)=x(old)-Q2/Q3-Q1</p><p>OR</p><p>x(old)-x(median)/IQR</p><p>where :</p><ul><li>median(X) is the median of the original feature.</li><li>IQR(X) is the interquartile range of the original feature.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Mzs-YmwUh8GIiCTUwRtnDA.png" /></figure><h3>power transform:</h3><p>Power transfom is a family of functions that transform data using power laws. The idea is to apply a transformation to each feature of our dataset.</p><p>What’s the purpose of a power transform? The idea is to increase the symmetry of the distribution of the features. If a features is asymmetric, applying a power transformation will make it more symmetric.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*TTQrDqFQHUK63E6m.png" /></figure><p>Some models may not work properly if the features are not symmetric. For example, models based on distances like KNN or K-means may fail if the distributions are skewed. In order to make these models work, power transformations will symmetrize the features without affecting their predictive power too much.</p><h3>Some power transformations</h3><p>The most common power transformations are the Box-Cox and the Yeo-Johnson transformations.</p><h4>Box-Cox transformation :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*7U7XwMLLwDaVa2_KM1WtzQ.png" /></figure><p>As you can see, we have a λ parameter that can be estimated using maximum likelihood. For example, we can try to minimize the skewness keeping the variance as stable as possible.</p><p>This formula must be applied to each feature independently. Each feature may potentially have different values for λ.</p><p>Since the independent variable appears inside a logarithm, this transformation can be applied only to strictly positive features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*eUXrqhr1jFnykxzv.jpg" /></figure><h4>Yeo-Johnson transformation :</h4><p>This transformer supports both positive and negative data and can handle data that includes zero and negative values. It applies a power transformation that is defined for all real values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*_db-jOerh47tVeneOQjMrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*3o83Xm8R7mr2RcB_.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=780091aa5078" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>