<?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 Mallikarjuna Jana on Medium]]></title>
        <description><![CDATA[Stories by Mallikarjuna Jana on Medium]]></description>
        <link>https://medium.com/@malli.learnings?source=rss-4773b2d1596c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*QeN02WBdiy0D4t6R.jpg</url>
            <title>Stories by Mallikarjuna Jana on Medium</title>
            <link>https://medium.com/@malli.learnings?source=rss-4773b2d1596c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:14:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@malli.learnings/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[Exploring Machine Learning Models: A Comprehensive Comparison of Logistic Regression, Decision…]]></title>
            <link>https://medium.com/@malli.learnings/exploring-machine-learning-models-a-comprehensive-comparison-of-logistic-regression-decision-38cc12287055?source=rss-4773b2d1596c------2</link>
            <guid isPermaLink="false">https://medium.com/p/38cc12287055</guid>
            <category><![CDATA[random-forest]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[svm-algorithm]]></category>
            <category><![CDATA[svm]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[Mallikarjuna Jana]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 16:45:57 GMT</pubDate>
            <atom:updated>2023-09-11T16:47:27.489Z</atom:updated>
            <content:encoded><![CDATA[<h3>Exploring Machine Learning Models: A Comprehensive Comparison of Logistic Regression, Decision Trees, SVM, Random Forest, and XGBoost</h3><p>In today’s data-driven world, machine learning models play a pivotal role in solving complex problems, making predictions, and extracting valuable insights from data. With a plenty of machine learning algorithms available, it’s crucial to understand their strengths, weaknesses, and real-world applications.</p><p>In this comprehensive article, we dive deep into the comparison of five foundational models:</p><p>1. Logistic Regression</p><p>2. Decision Trees</p><p>3. Support Vector Machines (SVM)</p><p>4. Random Forest and</p><p>5. XGBoost (Powerful Gradient Boosting technique)</p><p>By exploring the <strong>pros</strong> and <strong>cons</strong> of each model and showcasing their practical <strong>uses/use cases </strong>across industries,I will try to provide you with a well-rounded understanding of when and how to employ these algorithms effectively.</p><p>Whether you’re a seasoned data scientist or just stepping into the world of machine learning, this article will serve as a valuable guide to help you choose the right tool for your data-driven challenges.</p><p>Join me on this enlightening journey through the world of machine learning models, where we uncover their inner workings and discover how they are playing a vital role the future of AI/ML or data science.</p><p>However ,these models, all under the umbrella of <strong>supervised learning</strong>, are exploit to make predictions and classifications based on <strong>labelled</strong> data. While this session focuses on supervised learning, stay tuned for our upcoming articles, where we’ll understand unsupervised and reinforcement learning too.</p><p>So, what exactly is supervised learning? It’s a machine learning paradigm where the algorithm learns from labelled training data to make predictions or decisions without human intervention.</p><p>Think of it as a teacher guiding a student — the model learns by example, making it an essential tool in various data-driven applications.”</p><blockquote>Labelled training is where each data point is associated with a known, predefined label or category. This label serves as the ground truth, allowing machine learning models to learn and generalize from the labelled.</blockquote><p>Lets dive in to one by one, I am going to cover</p><p>— What Is each model<br> — Pros<br> — Cons<br> — Use cases</p><h3>1. Logistic Regression</h3><p>Logistic regression is a fundamental machine learning algorithm, which is a <strong>classification model </strong>that plays a crucial role in making decisions when there are two possible outcomes, like yes/no or pass/fail. Unlike linear regression, which predicts continuous values like prices or scores, logistic regression output is categorical variable the probability of an event happening, typically a binary outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-E4n_2SFJ3FYDkPd442eA.png" /><figcaption>Logistic regression</figcaption></figure><p><strong>Pros:</strong></p><ul><li>It has widespread industry use. Where logistic regression can be understood by even business people. (Explainability is major concern in ML/AI predictions)</li><li>It is convenient for generating probability scores</li><li>Efficient implementation is available across different tools</li><li>Multicollinearity is not a big issue in this, the issue of multicollinearity can be countered with L2 regularization or if we run PCA before running the Logistic regression you can avoid multi collinearity</li><li><strong>Simplicity</strong>: It is a simple and easy-to-implement algorithm that does not require a lot of computational resources. It is a good choice for problems with a large number of features.</li><li><strong>Interpretable:</strong> The coefficients of the logistic regression model can be interpreted as the degree of influence of each feature on the target variable. This makes the model easy to understand and interpret, even for non-technical people.</li><li><strong>Probabilistic:</strong> This models output a probability score for each prediction, which can be useful in some applications such as fraud detection or medical diagnosis.</li><li><strong>Robust to noise:</strong> It is robust to noisy data and can handle missing values.</li><li><strong>Regularization</strong>: Techniques such as L1 or L2 regularization can be applied to Logistic Regression models to prevent overfitting and improve the generalization performance.</li><li><strong>Outliers:</strong> It is less sensitive to outliers than other classification algorithms such as k-Nearest Neighbors or Support Vector Machines.</li></ul><p>Overall, Logistic Regression is a powerful and versatile algorithm that can be applied to a wide range of applications. Its simplicity and interpretability make it a popular choice for many classification problems.</p><p><strong>Cons:</strong></p><ul><li>It does not perform well when the features space is too large</li><li>It does not perform well when there are a lot of categorical variables in the data</li><li>The nonlinear features have to be transformed to linear features in order to efficiently use them for a logistic model</li><li>It relies on entire data i.e. if there is even a small change in the data, the logistic model can change significantly</li><li><strong>Limited to binary classification:</strong> Designed for binary classification problems where the target variable has only two possible outcomes. It cannot be used for multi-class classification problems without modification</li><li><strong>Assumptions about the data:</strong> Assumes that the relationship between the features and the target variable is linear and that the errors are normally distributed. Violations of these assumptions can affect the model’s performance</li><li><strong>Overfitting:</strong> It can overfit the training data if the number of features is large compared to the number of observations. Regularization techniques such as L1 or L2 regularization can be used to prevent overfitting</li><li><strong>Feature engineering:</strong> Relies heavily on feature engineering, which is the process of selecting and transforming the features to improve the model’s performance. This can be time-consuming and requires domain expertise</li><li><strong>Imbalanced data:</strong> Logistic Regression can be biased towards the majority class if the data is imbalanced, meaning that one class has many more observations than the other.</li><li><strong>No probabilistic outputs for multi-class classification:</strong> If the target variable has more than two possible outcomes, Logistic Regression cannot directly produce probabilistic outputs for each class. However, modifications such as the multinomial logistic regression can be used to extend Logistic Regression to multi-class problems</li></ul><p><strong>Some Use cases:</strong></p><ul><li><strong>Credit risk assessment:</strong> Can be used to predict the probability of default for credit applicants based on their financial and demographic information.</li><li><strong>Marketing campaign optimization:</strong> It can be used to predict the probability of a customer responding to a marketing campaign based on their behavior and demographics.</li><li><strong>Medical diagnosis:</strong> used to diagnose medical conditions based on symptoms and patient data.</li><li><strong>Fraud detection:</strong> Can be used to detect fraudulent transactions based on patterns of behavior or other features.</li><li><strong>Image classification: </strong>Can be used to classify images based on their features, such as pixel values or texture.</li></ul><h3>2. Decision trees</h3><p>As the term suggests, uses a tree-like model to make predictions. It resembles an upside-down tree.</p><p>These ‘trees’ consist of branches (choices) and leaves (outcomes). When faced with a decision, a tree asks a series of questions, each leading to more questions or a final outcome, uses a similar process that you do to make decisions in real life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RnNwHWoo0Zcc0NaKHsdFNQ.png" /><figcaption>Sample Decision Tree A doctor is interpreting a Disease</figcaption></figure><p><strong>Pros:</strong></p><ul><li>Trees handle nonlinear features well.</li><li>The variable interaction is taken into account.</li><li><strong>Interpretability:</strong> E<em>asy to understand and interpret, even for non-technical people.</em> The decision-making process is represented in a tree-like structure, where each branch corresponds to a decision based on a feature or attribute</li><li><strong>Non-parametric:</strong> Trees do not make any assumptions about the underlying data distribution or the relationship between features and the target variable. <em>They can work with both continuous and categorical features</em></li><li><strong>Robust to noise:</strong> Decision trees are robust to noisy data and can handle missing values</li><li><strong>Efficient:</strong> Decision trees are computationally efficient and can handle large datasets with high-dimensional features</li><li><strong>Ensemble learning:</strong> Can be combined to form ensemble models such as Random Forest, Gradient Boosted Trees, or AdaBoost, which can improve the overall performance and reduce overfitting</li></ul><p><strong>Cons:</strong></p><ul><li>Trees are highly biased towards the training set and overfit it more often than not.</li><li>There is no meaningful probability score as the output.</li><li><strong>Overfitting:</strong> These are prone to overfitting, which occurs when the model is too complex and fits the training data too closely, resulting in poor performance on new, unseen data. (Regularization techniques such as pruning or ensemble methods can be used to prevent overfitting )</li><li><strong>Instability:</strong> Small variations in the training data can result in a completely different decision tree. (This instability can be mitigated by using ensemble methods such as Random Forests. )</li><li><strong>Biased towards dominant classes:</strong> Tend to be biased towards classes that have a large number of observations, which can result in poor performance for minority classes.</li><li><strong>Limited expressiveness:</strong> Limited in their ability to represent complex relationships between features and the target variable, particularly if the relationships are non-linear.</li><li><strong>Greedy approach:</strong> At each split, the algorithm chooses the feature that maximizes the information gain or other splitting criteria, without considering future splits. This can lead to suboptimal decisions.</li><li><strong>Difficulty with continuous variables:</strong> It can have difficulty with continuous variables because they require the data to be separated or binned. This can result in loss of information and reduced performance.</li></ul><p><strong>Some Use cases:</strong></p><ul><li><strong>Customer churn prediction:</strong> Decision trees can be used to predict whether a customer will churn or not based on their behavior and demographics.</li><li><strong>Fraud detection:</strong> Can be used to detect fraudulent transactions based on patterns of behavior or other features.</li><li><strong>Medical diagnosis:</strong> Decision trees can be used to diagnose medical conditions based on symptoms and patient data.</li><li><strong>Credit risk assessment:</strong> Can be used to predict credit risk based on financial and demographic information.</li><li><strong>Marketing campaign optimization:</strong> Used to identify the target audience for marketing campaigns based on their behavior and demographics.</li></ul><p>Overall, decision trees are a versatile machine learning algorithm that can be applied to a wide range of applications, from business to healthcare to finance.</p><h3>3. Support vector machines (SVM)</h3><p>SVMs are widely used classification models known for their versatility. They offer several advantages, including the capability to handle computationally intensive datasets and effectively classify data that isn’t linearly separable.</p><p>SVMs belong to the class of <strong>linear machine learning models,</strong> requires <strong>numeric attributes.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7IXjBaTfLI8rjjEgQeR7FQ.png" /><figcaption>Support Vector Machine (SVM)</figcaption></figure><p><strong>Pros:</strong></p><ul><li>SVMs can handle large feature space</li><li>These can handle nonlinear feature interaction</li><li>SVMs do not rely on the entire dimensionality of the data for the transformation</li><li><strong>Effective in high-dimensional spaces:</strong> SVMs perform well in high-dimensional spaces, which makes them suitable for problems with many features, such as text classification or image recognition</li><li><strong>Versatile</strong>: SVMs can be used for both linear and non-linear classification, as well as regression tasks</li><li><strong>Robust to outliers:</strong> SVMs are robust to outliers in the data because they maximize the margin between the decision boundary and the closest points</li><li><strong>Memory efficient:</strong> SVMs only need to store a subset of the training data points, known as support vectors, to make predictions. This makes them memory efficient, particularly for large datasets</li><li><strong>Can handle non-linear decision boundaries:</strong> SVMs use kernel functions to transform the original feature space into a higher-dimensional space, where non-linear decision boundaries can be found</li><li><strong>Global optimization:</strong> SVMs are trained by finding the optimal hyperplane that maximizes the margin between the classes. This is a convex optimization problem, which means that there is a unique global solution that can be found efficiently</li></ul><p><strong>Cons:</strong></p><ul><li>SVMs are not efficient in terms of <strong>computational cost</strong> when the number of observations is large</li><li>It is tricky and time-consuming to find the appropriate kernel for a given data</li><li><strong>Computationally intensive:</strong> SVM can be computationally intensive, particularly when dealing with large datasets. Training an SVM model on a large dataset can be time-consuming and require a lot of memory and processing power</li><li><strong>Sensitivity to hyperparameters:</strong> SVM has several hyperparameters that need to be tuned, such as the kernel function, regularization parameter, and kernel coefficient. The performance of the model can be highly sensitive to the choice of hyperparameters</li><li><strong>Limited interpretability:</strong> SVM produces a black-box model that can be difficult to interpret. The relationships between the features and the target variable are not easily understood from the SVM model</li><li><strong>Only binary classification:</strong> SVM is designed for binary classification problems, and extensions to multi-class classification require additional modifications such as one-vs-all or one-vs-one approaches</li><li><strong>Difficulty with noisy data:</strong> SVM is sensitive to noisy data and outliers, which can affect the performance of the model</li><li><strong>Memory intensive for large datasets:</strong> In some cases, the memory required to store the kernel matrix can become prohibitively large, making it difficult to apply SVM to very large datasets</li></ul><p><strong>Used In:</strong></p><ul><li><strong>Image classification:</strong> SVMs can be used to classify images based on their features, such as pixel values or texture.</li><li><strong>Text classification:</strong> SVMs can be used to classify text documents based on their content, such as sentiment analysis or spam detection.</li><li><strong>Bioinformatics:</strong> SVMs can be used to classify proteins or DNA sequences based on their features.</li><li><strong>Finance:</strong> SVMs can be used to predict stock prices or credit risk based on financial data.</li><li><strong>Medical diagnosis:</strong> SVMs can be used to diagnose diseases based on medical data.</li></ul><p>Overall, SVMs are a powerful and flexible classification model that often associated with binary classification, they can be adapted for both binary and multi-class classification tasks</p><h3>4. Random Forest</h3><p>Random Forest is an ensemble learning method that leverages multiple decision trees to make predictions. It is known for its versatility and robustness. In a Random Forest, a collection of decision trees is trained on different subsets of the data and features. The final prediction is made by aggregating the predictions of individual trees, often through <strong>voting</strong> (for classification) or <strong>averaging</strong> (for regression). The same as depicted below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnB7zn7yTvhKs6HufsDy8Q.png" /><figcaption>Random Forest at high-level</figcaption></figure><p>As we are touching Regression and classification, we better to understand the Random forest by comparing <strong><em>Logistic Regression</em></strong> and <strong><em>Decision Trees</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQK4N9CLLvm5M23L2nL_rA.png" /><figcaption>Basic difference between Logistic , Decision Trees compared to Random Forest</figcaption></figure><p><strong>Pros:</strong></p><ul><li>No need to prune the trees of a forest.</li><li>The <strong>OOB error</strong> can be calculated from the training data itself which gives a good estimate of the model performance on unseen data.</li><li>It is hard for a random forest to <strong>overfit </strong>the training data.</li><li>A random forest is not affected by <strong>outliers</strong> as much because of the aggregation strategy.</li><li>Can handle high-dimensional datasets with many features.</li><li>Can handle both <strong>categorical</strong> and <strong>numerical</strong> data.</li><li>Tend to produce more accurate predictions than decision trees.</li><li>Are less sensitive to small changes in the data, normally Trees are not like that</li><li>Can be used for feature selection and data exploration.</li></ul><p><strong>Cons:</strong></p><ul><li>May be difficult to interpret and explain to stakeholders.</li><li>Can be computationally expensive, especially with large datasets.</li><li>May not perform well on datasets with strong dependencies between features.</li><li>random forests have the same problem of <strong>not predicting beyond the range of the response variable</strong> in the training set.</li><li>The <strong>extreme values are often not predicted</strong> because of the aggregation strategy.</li></ul><p><strong>Use Cases:</strong></p><ul><li><strong>Predictive Modeling: </strong>XGBoost is widely used in predictive modeling tasks such as customer churn prediction, fraud detection, and recommendation systems.</li><li><strong>Structured Data: </strong>It excels with structured data, such as financial data for credit risk assessment and tabular data for various business applications, as it provides more accurate predictions</li><li><strong>Ranking:</strong> XGBoost can be used for ranking tasks, such as web page ranking in search engines.</li><li><strong>Healthcare: </strong>XGBoost is employed in medical diagnosis tasks, predicting disease outcomes based on patient data.</li><li><strong>Energy Forecasting:</strong> It can forecast energy consumption or generation in the energy sector.</li></ul><h3>5. XGBoost</h3><p>XGBoost (Extreme Gradient Boosting) is a powerful machine learning algorithm that belongs to the ensemble learning family. It is particularly effective for both <strong>classification and regression tasks</strong>. XGBoost builds a model that is based on a collection of decision trees and combines their predictions to make accurate and robust predictions.</p><p>XGBoost Overview:</p><ul><li><strong>Boosting: </strong>Models are added sequentially to correct the errors made by previous model. This sequence of weak learners will produce a strong learner</li><li><strong>Gradient boosting: </strong>where the newly added trees are trained to reduce the errors (loss function) of earlier models. So, in gradient boosting, you can optimize the performance of the boosted model by bringing down the loss one small step at a time.</li><li><strong>XGBoost: </strong>is an extended version of gradient boosting, which uses more accurate approximations to tune the model and find the best fit</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*53YSrjysbqdjxeuVDq0F1A.png" /><figcaption>XG Boost Features</figcaption></figure><p>Pros:</p><ul><li><strong>Parallel Computing</strong>: When you run XGBoost, by default it would use all the cores of your laptop/machine enabling its capacity to do parallel computation.</li><li><strong>Tree pruning using depth first approach:</strong> XGBoost uses ‘max_depth’ parameter as specified instead of criterion first, and starts pruning trees backward.</li><li><strong>Missing Values:</strong> XGBoost is designed to handle missing values or noisy data internally. The missing values are treated in such a manner that any trend in missing values (if it exists) is captured by the model.</li><li><strong>Regularization:</strong> The biggest advantage of XGBoost is that it uses regularization in its objective function which helps to controls the overfitting and simplicity of the model, leading to better performance.</li><li><strong>Excellent Performance: </strong>XGBoost often outperforms other algorithms in terms of predictive accuracy</li><li><strong>Handles Nonlinearity: </strong>Like decision trees, XGBoost handles nonlinear relationships between features and the target variable effectively.</li><li><strong>Interpretability:</strong> It’s possible to inspect feature importance in XGBoost models, making them interpretable.</li><li><strong>Regularization:</strong> It includes L1 and L2 regularization to control overfitting.</li><li><strong>Efficiency: </strong>XGBoost is computationally efficient and can handle large datasets with many features.</li><li><strong>Versatile: </strong>It can be used for classification, regression, ranking, and recommendation tasks.</li></ul><p>Cons:</p><ul><li><strong>Complexity: </strong>XGBoost models can be complex, leading to challenges in understanding their inner workings.</li><li><strong>Overfitting: </strong>Without proper tuning, XGBoost can overfit the training data.</li><li><strong>Hyperparameters:</strong> It has several hyperparameters that need optimization for optimal performance.</li></ul><p>Use Cases:</p><ul><li><strong>Predictive Modeling: </strong>XGBoost is widely used in predictive modeling tasks such as customer churn prediction, fraud detection, and recommendation systems.</li><li><strong>Structured Data: </strong>It excels with structured data, such as financial data for credit risk assessment and tabular data for various business applications.</li><li><strong>Ranking: </strong>XGBoost can be used for ranking tasks, such as web page ranking in search engines.</li><li><strong>Healthcare:</strong> XGBoost is employed in medical diagnosis tasks, predicting disease outcomes based on patient data.</li><li><strong>Energy Forecasting: </strong>It can forecast energy consumption or generation in the energy sector.</li></ul><p>In summary, XGBoost is a versatile and powerful machine learning algorithm known for its outstanding performance, adaptability to various tasks, and robustness in handling complex datasets. It’s a valuable addition to the machine learning toolkit for both practitioners and data scientists.</p><p>This article provides an overview of fundamental machine learning models, including Logistic Regression, Decision Trees, and Random Forests. We’ve explored their characteristics, use cases, and pros and cons. Understanding these foundational models is crucial before delving into more advanced topics like <strong>Neural Networks</strong> in Deep Learning, which we’ll explore in our next article. :)</p><p>Thank you for taking the time to read this article. Happy to address any feedback or answer your questions. Please feel free to reach out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38cc12287055" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveraging AI-Powered NLP for Enhancing Customer Support By Automatic Ticket Classification]]></title>
            <link>https://medium.com/@malli.learnings/leveraging-ai-powered-nlp-for-enhancing-customer-support-by-automatic-ticket-classification-ee22057c6db0?source=rss-4773b2d1596c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee22057c6db0</guid>
            <category><![CDATA[top-modeling]]></category>
            <category><![CDATA[tf-idf]]></category>
            <category><![CDATA[nmf]]></category>
            <category><![CDATA[nlp-certification]]></category>
            <dc:creator><![CDATA[Mallikarjuna Jana]]></dc:creator>
            <pubDate>Fri, 01 Sep 2023 14:59:28 GMT</pubDate>
            <atom:updated>2023-09-01T14:59:28.569Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><p>In the dynamic landscape of customer support, streamlining issue resolution is paramount. Imagine a scenario where a company receives a multitude of customer complaints spanning various products and services. Each of these complaints requires swift attention, and an effective way to expedite this process is through intelligent classification.</p><p>This is where the power of machine learning comes into play. The challenge at hand is to construct a model capable of <strong>automatically categorizing customer complaints </strong>based on the specific products or services in question. By achieving this, not only can we allocate these complaints to their respective categories, but we can also facilitate rapid solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qPw9mSICjQuhKyWX1-FRw.jpeg" /><figcaption>Automatic Ticket Classification using NLP</figcaption></figure><h3><strong>Approach:</strong></h3><p>The foundation of this endeavor lies in the domain of topic modeling.</p><p>Since these service ticket data entries lack explicit labels, a technique called Non-Negative Matrix Factorization (<strong>NMF</strong>) emerges as the tool of choice. NMF enables us to uncover underlying patterns and group complaints into distinct clusters that align with the nature of the products or services involved.</p><p>Unraveling the latent topics through NMF empowers us to map each customer complaint to its appropriate category, however, the journey doesn’t stop here.</p><p>To transition from <strong>unsupervised</strong> <strong>learning</strong> to a more refined classification system, we can harness the insights gleaned from <strong>topic modeling</strong> to train <strong>supervised models.</strong> Algorithms like logistic regression, decision trees, and random forests can be employed to learn from the categorized complaints and their corresponding clusters.</p><p>The culmination of this process results in a trained model capable of swiftly categorizing new customer complaint support tickets into their relevant departments. This not only enhances customer satisfaction through quicker issue resolution but also equips support teams with a more structured approach to handle the array of complaints they encounter.</p><p>This approach can be help to classify any kind of service tickets irrespective of Industry.</p><p>In this article, we’ll delve deeper into the mechanics of topic modeling using NMF, explore the transformation of these unsupervised insights into fuel for supervised models.</p><h3><strong>Data:</strong></h3><p>Within the scope of this article, we will utilize a dataset comprising historical customer complaints from some financial institution, (can get from Kaggle). Our objective will be to undertake the classification of these complaints into the following five distinct categories:</p><p>1. Credit Card / Prepaid Card<br>2. Bank Account Services<br>3. Theft / Dispute Reporting<br>4. Mortgages / Loans<br>5. Others</p><p>Through this analysis, we aim to enhance our understanding of how advanced AI techniques, combined with the power of NLP, can efficiently categorize complex financial service-related grievances, thereby contributing to improved customer support strategies.</p><h3><strong>Solution:</strong></h3><p>In this article, I have chosen not to delve into the details of the data cleaning. This includes tasks such as eliminating numerical data, addressing missing values, resolving duplicated data, and so forth. However, I encourage you to refer to the provided final sample code, which does incorporate the this process, offering a comprehensive view of these data cleaning steps.</p><p>Lets dive in to the steps and coding . . .</p><p><strong>Lemmatization:</strong></p><p>Prior to engaging in Exploratory Data Analysis (EDA), let’s perform lemmatization on the data. Lemmatization is a linguistic process that involves reducing words to their base or root form. In this context, we are utilizing the <strong>WordNetLemmatizer</strong> to carry out this lemmatization process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/610943fa6caa41834d7334b87e17c3b5/href">https://medium.com/media/610943fa6caa41834d7334b87e17c3b5/href</a></iframe><p>Attempt to exhibit the top 40 words with the highest frequency in all the raw complaints. To achieve this, utilize a word cloud visualization, both after the lemmatization process and after eliminating the Part-of-Speech (POS) tags from the complaints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*mW5BkdtPceeMul7ulyGRlQ.png" /><figcaption>Top 40 words based on frequency</figcaption></figure><p>[** The personal details of customer has been masked in the dataset with xxxx. Let’s remove the masked text as this will be of no use for our analysis in the next spteps ]</p><p>Identify the most frequent unigrams, bigrams, and trigrams within all the processed complaints, thereby harnessing the power of NLP to uncover prominent linguistic <strong>patterns and relationships</strong> in the text.</p><p>Unigrams:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38814d824473bee20b18866bb7c6f7ad/href">https://medium.com/media/38814d824473bee20b18866bb7c6f7ad/href</a></iframe><p>Bigram:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cc52f838d3141d4a664f6cc65ef9993/href">https://medium.com/media/6cc52f838d3141d4a664f6cc65ef9993/href</a></iframe><p>same we can also do for Trigram by giving <em>ngram_range=(3, 3)</em></p><h3><strong>Feature Extraction:</strong></h3><p>“Transform the raw text into a TF-IDF feature matrix.”</p><p>When working with text data, it’s important to fine-tune the features. Here are two essential parameters:</p><ol><li><strong>max_df (Maximum Document Frequency): </strong>We set max_df to 0.95, which means we want to remove terms that appear too frequently. These are often words that are common across almost all documents and may not carry much <strong>unique</strong> information. In this case, we&#39;re ignoring terms that appear in more than 95% of the complaints. This helps in getting rid of what we call &quot;corpus-specific stop words,&quot; allowing the model to <strong>focus on more meaningful and discriminative terms.</strong></li><li><strong>min_df (Minimum Document Frequency): </strong>We set min_df to 2. This parameter is used to eliminate terms that appear too infrequently. When we set min_df = 2, we&#39;re removing terms that show up in less than 2 complaints. <strong>Rare terms can introduce noise into our analysis</strong> since they may not provide enough information to be meaningful. By setting this threshold, we ensure that the terms considered in our analysis are reasonably common.</li></ol><p>These adjustments in max_df and min_df help us create a more effective TF-IDF representation of our text data for topic modeling and classification tasks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6bc4bd915c374d7ba20e01aacfe2e47/href">https://medium.com/media/a6bc4bd915c374d7ba20e01aacfe2e47/href</a></iframe><p>Due to the unstructured nature of our data, we can extract valuable insights through the application of Topic Modeling.</p><h3><strong>Topic Modelling using NMF:</strong></h3><p>Non-Negative Matrix Factorization (NMF) is an unsupervised technique, meaning it doesn’t rely on predefined topic labels for training. Instead, it operates by decomposing high-dimensional vectors into a lower-dimensional representation. Importantly, the components of this lower-dimensional representation are constrained to be non-negative, including their coefficients.</p><p>In our task, we will:</p><ul><li>Determine the optimal number of clusters.</li><li>Utilize this optimal number to generate clusters of words.</li><li>Scrutinize and validate the relevance of these clusters concerning the customer complaints.</li><li>Make adjustments to cluster labels if necessary.</li><li>Associate these clusters with meaningful topic or cluster names.</li></ul><p>we are going to use NMF from sklearn library</p><p>Exploration through trial and error is necessary to determine the optimal number of topics for your NMF model.</p><p>The sole parameter required is the number of components, which corresponds to the desired number of topics. This step is pivotal within the entire topic modeling process and significantly influences the quality of your resulting topics.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f144f59b0b43ba7dbc66f5212893c10/href">https://medium.com/media/7f144f59b0b43ba7dbc66f5212893c10/href</a></iframe><p>based on our current corpus, the result is like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f578519f7b4a2ef18a5097e083a3ce06/href">https://medium.com/media/f578519f7b4a2ef18a5097e083a3ce06/href</a></iframe><p>Now we can assign the best topic to each of the complaint for better understanding</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/509ab113c6b782464f39beb2c8ba8ead/href">https://medium.com/media/509ab113c6b782464f39beb2c8ba8ead/href</a></iframe><p>With our model in place, we’ve successfully developed a system for categorizing each complaint into specific topics. Now, we’ll leverage this model to classify incoming complaints effectively. We’ll employ a supervised model to predict the appropriate topics for new complaints.</p><p>Apply the supervised models to the prepared training data. In this step, we should perform the following tasks:</p><ol><li>Generate vector counts using Count Vectorizer.</li><li>Transform the word vectors into TF-IDF (Term Frequency-Inverse Document Frequency) format.</li><li>Split the data into training and test sets using the train_test_split function, based on the TF-IDF features and topics</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b30b43548ca7ff1f0a691959a4c74b08/href">https://medium.com/media/b30b43548ca7ff1f0a691959a4c74b08/href</a></iframe><p>now the usual activity, Train and Test split</p><p><em>X_train, X_test, y_train, y_test = train_test_split(X_train_tfidf, training_data.Topic, test_size=0.25, random_state=42)</em></p><p>When it comes to classifying complaints using a supervised model, we have the flexibility to experiment with 2 or 3 different algorithms. Based on the outcomes, we can then select the one that exhibits the most promising results. Some of the algorithms we can consider include</p><ul><li>Logistic Regression</li><li>Decision Trees and</li><li>Random Forest</li></ul><p>we can step-in in to the code for each model and find <strong>F1 </strong>for each model, instead of discussing each algorithm in details and</p><p><strong>Logistic Regression:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/810653bc3b911801b33dcd351fe61bb0/href">https://medium.com/media/810653bc3b911801b33dcd351fe61bb0/href</a></iframe><p>F1 Score: 0.925 ~</p><p><strong>Decision Tree:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42c73f4a967a179a1a2644adfee65f79/href">https://medium.com/media/42c73f4a967a179a1a2644adfee65f79/href</a></iframe><p>F1 Score: 0.790 ~</p><p><strong>Random Forest:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/716689f262679ed7d62617d0ed437131/href">https://medium.com/media/716689f262679ed7d62617d0ed437131/href</a></iframe><p>F1 Score: 0.815 ~</p><p>It appears that Logistic Regression is delivering strong performance with this dataset. Let’s fine-tune it to achieve even better results.</p><p>fine tune for, best hyper parameters,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0dda39d4f7af9fdbb37a88742ed6191/href">https://medium.com/media/e0dda39d4f7af9fdbb37a88742ed6191/href</a></iframe><p>Best F1 Score: 0.946~</p><p>Best Hyperparameters: {‘C’: 1, ‘penalty’: ‘l1’, ‘solver’: ‘saga’}</p><p>Now, lets save this model and do the prediction with this model</p><p><em>pickle.dump(final_logreg_model, open(“final_logreg_model.pkl”, “wb”))</em></p><p>predictions final model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7626e01e0548a6e705a3446487259eb/href">https://medium.com/media/c7626e01e0548a6e705a3446487259eb/href</a></iframe><p>Wow.. Upon confirming the results, our model is excelling at correctly categorizing customer complaints into their respective topics.</p><p>This is precisely the outcome we aimed to achieve.</p><p>Thank you for taking the time to read this article! I trust you found it informative and valuable in gaining insights into topic modeling techniques such as NMF, TF-IDF, and various classification algorithms.</p><p>To further explore these concepts, you can find the referal source code used in the article below:</p><p><a href="https://github.com/Malli-Learn/Automatic_Ticket_Classification_NLP">https://github.com/Malli-Learn/Automatic_Ticket_Classification_NLP</a></p><p>Feel free to utilize and modify the source code according to your requirements. If you have any further questions or need additional assistance, please don’t hesitate to ask.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee22057c6db0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hand Gesture Recognition : Exploring Deep Learning Approaches with Conv3D and Imagenet Transfer…]]></title>
            <link>https://medium.com/@malli.learnings/hand-gesture-recognition-exploring-deep-learning-approaches-with-conv3d-and-imagenet-transfer-d8a2c1163da3?source=rss-4773b2d1596c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8a2c1163da3</guid>
            <dc:creator><![CDATA[Mallikarjuna Jana]]></dc:creator>
            <pubDate>Sat, 08 Jul 2023 07:28:17 GMT</pubDate>
            <atom:updated>2023-07-08T07:28:17.323Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hand Gesture Recognition : Exploring Deep Learning Approaches with Conv3D and Imagenet Transfer Learning</h3><h3><strong>Problem Statement:</strong></h3><p>In order to revolutionize the TV viewing experience, we aim to develop an innovative feature for our smart-TV that enables gesture recognition. By harnessing this technology, users will be able to control their TVs effortlessly, eliminating the need for a remote.</p><p>Our objective is to recognize five distinct gestures, each corresponding to a specific command, as follows:</p><ol><li>Thumbs up: Increase the volume</li><li>Thumbs down: Decrease the volume</li><li>Left swipe: Jump backwards by 10 seconds</li><li>Right swipe: Jump forward by 10 seconds</li><li>Stop: Pause the movie</li></ol><p>Our exploration of these gesture-based controls will leverage the power of deep learning, ensuring accurate and reliable recognition of user gestures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIsBgwmYTl7XAusZbcNhbA.png" /><figcaption>Gesture Recognition Using Deep Learning (CNN, RNN, Transfer Learning)</figcaption></figure><h3><strong>Demystifying the Data:</strong></h3><p>The training dataset comprises several hundred categorized videos, each belonging to one of five distinct classes. These videos, typically lasting 2–3 seconds, are comprised of a sequence of 30 frames or images. The recordings were performed by different individuals in front of a webcam, mimicking the gestures that will be used with the smart TV.</p><p>The data is provided in a compressed zip file, which contains two main folders: ‘train’ and ‘val’, each accompanied by a corresponding CSV file. Within these folders, the data is further organized into subfolders, representing individual videos capturing a specific gesture. Each video subfolder consists of 30 frames or images. Notably, images within a given video subfolder possess identical dimensions, although different videos may have varying dimensions. Specifically, videos exhibit two types of dimensions: either 360x360 or 120x160.</p><p>The CSV files contain one row per video, encompassing three key pieces of information:</p><ul><li>The name of the subfolder containing the 30 images for that video</li><li>The corresponding gesture name and</li><li>Numeric label ranging from 0 to 4, representing the video’s class label</li></ul><h3><strong>Exploring Architectures:</strong></h3><p>In the realm of video analysis with neural networks, two prevalent architectures are commonly employed.</p><p>The first is the widely adopted <strong>CNN + RNN</strong> architecture, wherein the video’s images undergo convolutional neural network (CNN) processing to extract a feature vector per image. These feature vectors are then passed through a recurrent neural network (RNN) to capture temporal dependencies. To further enhance performance, transfer learning from <strong>Imagenet</strong> can be leveraged, utilizing pre-trained weights from the Imagenet dataset.</p><p>The second architecture, which has gained popularity, is an extension of CNNs known as 3D convolutional networks <strong>(Conv3D)</strong>. These networks specifically cater to video processing tasks.</p><blockquote>In this solution, both of these architectures will be explored to examine their effectiveness in addressing the objectives at hand.</blockquote><h3>Architecting the Solution:</h3><h3>1. Convolution 3D</h3><p>Convolutional 3D (Conv3D) is an extension of traditional 2D convolution to process three-dimensional data, such as videos or spatiotemporal volumes. Conv3D operates on three axes: width, height, and time (or depth). It allows for the extraction of spatial and temporal features simultaneously.</p><p>High level feature extraction in this approach</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*w6oDWuH73lPa2CFwKbzEFQ.png" /><figcaption>Conv3D Extracting each Feature</figcaption></figure><p>Lets go in the code</p><p><strong>Importing Key Libraries</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c41a1bb23b6f40b39e6034ee5e59469/href">https://medium.com/media/8c41a1bb23b6f40b39e6034ee5e59469/href</a></iframe><p><strong>Leveraging Python Generators for Efficient Data Feeding</strong></p><p>In video analysis, working with large amounts of data (Video is converted in to Image frames) is a common requirement.However, feeding such massive datasets into memory can be resource-intensive, demanding significant RAM, GPU, and overall system memory. To tackle this challenge, Python <strong>Generators</strong> offer an elegant solution, enabling efficient data feeding without overwhelming system resources.</p><p><strong>Generators</strong> in Python are functions that <strong><em>yield</em></strong> results one at a time, rather than returning them all at once. They enable the generation of data on-the-fly, eliminating the need to load and store massive datasets entirely in memory. By adopting a streaming approach, generators efficiently handle data in smaller chunks, reducing memory overhead.</p><p>Some of the advantages of Generators are</p><ul><li>Memory Efficiency</li><li>On-the-Fly Data Generation</li><li>Scalability</li><li>Faster Iterations</li></ul><p>Finally, by utilizing Python generators, data scientists and machine learning practitioners can unlock the full potential of their models, leveraging the power of large datasets without compromising system resources.</p><p>We are going to Generator part of the solution</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c7d81788c019f6b20b0e58dc193d580/href">https://medium.com/media/1c7d81788c019f6b20b0e58dc193d580/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13d61b5c2ed75fd041ee00411056252b/href">https://medium.com/media/13d61b5c2ed75fd041ee00411056252b/href</a></iframe><p>Cropping an image is easy</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77d70d5fb1f590a8b1385fa741fe065e/href">https://medium.com/media/77d70d5fb1f590a8b1385fa741fe065e/href</a></iframe><p>Conv3D Model</p><p>keeping dropouts as 0.25 and instead of feeding all 30 images from video using only 20 images, it may not reduced accuracy lot</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76d6f93826ec41f9fb468ee2fc436ebe/href">https://medium.com/media/76d6f93826ec41f9fb468ee2fc436ebe/href</a></iframe><p>Let us create the train_generator and the val_generator which will be used in .fit_generator.</p><p>Compile and fit the model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf1a3d0667c1c403304df9f5a90e5c69/href">https://medium.com/media/cf1a3d0667c1c403304df9f5a90e5c69/href</a></iframe><p>In conclusion, we successfully constructed a Conv3D model and employed generators to efficiently handle memory consumption. Subsequently, we trained the model and executed the fitting process to make accurate predictions.</p><h3>2. CNN + RNN</h3><p>I hope the Conv3D solution discussed earlier is clear. In this particular scenario, we will utilize the widely adopted CNN + RNN approach to classify the time series data (video). To enhance the model’s performance, we will leverage pre-trained weights from Imagenet instead of starting the training process from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XApdiczfjXa8JnwB-hQzzg.png" /><figcaption>Example Architecture of CNN + RNN</figcaption></figure><p>Why Imagenet?</p><p>Using Imagenet pre-trained weights in the CNN + RNN approach provides a head start by initializing the CNN with a powerful visual feature extractor. This transfer learning strategy boosts performance, enhances feature representation, facilitates generalization to new datasets, and improves data efficiency.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4ffa8312f12a5255f76ef6bb5b22d10/href">https://medium.com/media/d4ffa8312f12a5255f76ef6bb5b22d10/href</a></iframe><p>It is a MobileNet model with pre-trained weights from Imagenet, while excluding the top layers. This allows us to use the MobileNet model as a feature extractor for our specific task and add custom layers on top for classification or other purposes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e06bbd42d1806532fed565c999a134e5/href">https://medium.com/media/e06bbd42d1806532fed565c999a134e5/href</a></iframe><p>This code sets up a Sequential model (model2) with a TimeDistributed layer containing a MobileNet model as its input. The MobileNet layers are then made non-trainable to preserve their pre-trained weights, freezes the weights of the layers, preventing them from being updated during training. This loop ensures that the MobileNet layers are not trainable while training the entire model2 architecture.</p><p>Compile and Fit the Model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ee0249b5368adee5117ddf9d2b63986/href">https://medium.com/media/8ee0249b5368adee5117ddf9d2b63986/href</a></iframe><p>With this model overall accuracy we achieved</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*eu9CZ-dusKDxYn5QQF2JSA.png" /><figcaption>Overall Accuracy</figcaption></figure><pre>Training Avg Accuracy 0.9503991176684697<br>Validaiton Avg Accuracy 0.729449405272801</pre><p>In the case of GRU</p><p>GRUs have a simpler architecture compared to LSTMs with fewer gating mechanisms and designed to be computationally efficient and have fewer parameters to train.</p><p>In terms of performance, LSTM and GRU architectures tend to show similar results on most tasks. However, GRUs may be more suitable in scenarios where computational efficiency and smaller model size are desired.</p><p>If you want to use GRU it required only small changes in our model</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab8e9ada27577838b14dd8f783df72bb/href">https://medium.com/media/ab8e9ada27577838b14dd8f783df72bb/href</a></iframe><p>Thank you for reading the article! I hope you found it informative and helpful in understanding Gesture video classification with two different approaches in recurrent neural networks.</p><p>We referred</p><ul><li>Convolution 3D</li><li>CNN + RNN</li><li>Transfer Learning</li><li>Imagenet</li><li>LSTM</li><li>GRU</li></ul><p>To further explore these concepts, you can find the final source code used in the article below:</p><p><a href="https://github.com/Malli-Learn/RNN/blob/main/Gesture_Recognition_RNN_Malli_V1.ipynb">RNN/Gesture_Recognition_RNN_Malli_V1.ipynb at main · Malli-Learn/RNN</a></p><p>Feel free to utilize and modify the source code according to your requirements. If you have any further questions or need additional assistance, please don’t hesitate to ask.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8a2c1163da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Melanoma detection using CNN based model: A Deep Learning Approach for Skin Cancer Diagnosis]]></title>
            <link>https://medium.com/@malli.learnings/melanoma-detection-using-cnn-based-model-a-deep-learning-approach-for-skin-cancer-diagnosis-e5e520e34599?source=rss-4773b2d1596c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5e520e34599</guid>
            <dc:creator><![CDATA[Mallikarjuna Jana]]></dc:creator>
            <pubDate>Mon, 12 Jun 2023 06:30:22 GMT</pubDate>
            <atom:updated>2023-06-12T06:32:08.469Z</atom:updated>
            <content:encoded><![CDATA[<h3>Melanoma Detection Using a CNN-Based Model: A Deep Learning Approach for Skin Cancer Diagnosis</h3><p><strong>Introduction:</strong></p><p>Melanoma, a type of skin cancer, is a serious health concern with potentially life-threatening consequences if not detected early. With the advancements in deep learning and computer vision, building a CNN-based model has become a promising approach for accurate melanoma detection. In this blog post, we will explore the steps involved in creating a CNN-based model that can effectively identify melanoma, providing a valuable tool for early diagnosis and treatment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERTsd2PKKy_IJbQ6jjLbew.jpeg" /><figcaption>Melanoma Detection using Convolution Neural Network (<strong>CNNs</strong>)</figcaption></figure><p><strong>Understanding Convolutional Neural Networks (CNNs):</strong></p><p>Convolutional Neural Networks (CNNs) are a class of deep learning models specifically designed to excel in image processing tasks. CNNs consist of multiple layers, including convolutional, pooling, and fully connected layers, which allow them to learn complex patterns and features from images. Leveraging these properties, we can develop a CNN-based model for melanoma detection.</p><p><strong>Lets Understand the Data Set:</strong></p><p><strong>Data Source :</strong> The dataset available in Kaggle , which consists of 2K+ images of malignant and benign oncological diseases, which were formed from the <strong>International Skin Imaging Collaboration (ISIC)</strong>.</p><h3><strong>Construct Model</strong></h3><p><strong>Importing Essential Libraries:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f88ea5dd6a90d6cbe19aa360fb214733/href">https://medium.com/media/f88ea5dd6a90d6cbe19aa360fb214733/href</a></iframe><p><strong>Create Data Set:</strong></p><p>Use 80% of the images for training, and 20% for validation, the parameters for the loader</p><pre>batch_size = 32<br>img_height = 180<br>img_width = 180</pre><p>Create train and Validation set using <strong>keras.preprocessing</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7760b95f5cf860192d6abd23e07c0263/href">https://medium.com/media/7760b95f5cf860192d6abd23e07c0263/href</a></iframe><p><strong>Create Model:</strong></p><p>Below model is having 7 Layers sequential for organising layers in a linear stack, before creating model rescale images to normalize pixel values between (0,1) and with parameters</p><ul><li>activation function <strong>=</strong>’relu’</li><li>filters (3,3) and (5,5)</li><li>Dropout 0.25 and</li><li>Dense layer with activation ‘softmax’</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1dd625e6046951a18126261bcf33b75/href">https://medium.com/media/e1dd625e6046951a18126261bcf33b75/href</a></iframe><p>Above model will bring us the params as</p><pre>Total params: 1,172,265<br>Trainable params: 1,172,265<br>Non-trainable params: 0</pre><p><strong>Compile the Model:</strong></p><p>Compiling the model with recommended parameters</p><ul><li><strong><em>optimizer=’adam’ </em></strong>— Adam is a popular optimization algorithm that combines the benefits of both AdaGrad and RMSProp. It is known for its efficiency and effectiveness in training neural networks.</li><li><strong><em>loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) — </em></strong>Sparse categorical cross-entropy is commonly used for multi-class classification tasks, where the labels are integers representing the class indices .And the from_logits=True indicates that the model&#39;s output is not normalized by a softmax activation, allowing the loss</li><li><strong>metrics=[‘accuracy’] — </strong>model’s accuracy will be calculated and reported during training and evaluation. Accuracy is a commonly used metric that measures the percentage of correctly predicted labels compared to the true labels.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5ad05337a2f9adfde4da7dc5f0d1c00/href">https://medium.com/media/f5ad05337a2f9adfde4da7dc5f0d1c00/href</a></iframe><p><strong>Train the model :</strong></p><p>When trining the model, train a model with many Trainable params will take huge time to process, recommend to not use local system, use Google’s colab instead and enable hardware accelerator as GPU Edit-&gt;NoteBook Settings</p><p>using epochs as 20</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7db5c5080cb9138941b61a7714f2e9e9/href">https://medium.com/media/7db5c5080cb9138941b61a7714f2e9e9/href</a></iframe><p>Visualize the results in graphs to have better understanding on model performance. some of way of graphs using <strong><em>matplotlib.pyplot </em></strong>for <strong>accuracy</strong> and <strong>loss</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74467af2af778e1b50fd5759700ee4e2/href">https://medium.com/media/74467af2af778e1b50fd5759700ee4e2/href</a></iframe><p><strong>Analysis:</strong></p><p>This is completion of model creation, compiling and train and validate the model.</p><p>If the finding are with good accuracy with train and validation set (80% above 70%) that is very good model in my perspective, it may vary based on the data and hyper parameters.</p><p>If your model is having overfitting because of class imbalnce please continue below</p><h3><strong>Data augmentation:</strong></h3><p><strong>Use case :</strong></p><p>Most of the times in real life datasets can have class imbalance, one class can have proportionately higher number of samples compared to the others. Class imbalance can have a detrimental effect on the final model quality. Hence as a sanity check it becomes important to check what is the distribution of classes in the data before proceeding. In such cases Data Agumentation techniques will help</p><h4>Augmentation:</h4><p>Commonly used in Convolutional Neural Networks (CNNs) to artificially increase the size of the training dataset by applying various transformations to the existing data. It helps improve the performance and generalization ability of CNN models by providing more diverse and varied training examples.</p><p>The idea behind data augmentation is to create new training samples by applying random transformations to the original images while preserving the class labels.</p><p>These transformations can include below and these can be combined and applied with random parameters to generate new training samples on-the-fly during the training process.</p><ul><li>Flipping</li><li>Rotation</li><li>Translation</li><li>Scaling</li><li>Zooming</li><li>Shearing</li></ul><p>Data augmentation is typically implemented using data augmentation libraries or frameworks, such as the ImageDataGenerator class in <strong>Keras </strong>or python package <strong>Augmentor</strong> (<a href="https://augmentor.readthedocs.io/en/master/">https://augmentor.readthedocs.io/en/master/</a>)</p><p>Install using <strong><em>!pip install Augmentor </em></strong>in your colab then import</p><p>Below is the code which is generating 500 images using Agumentor in your <strong><em>train_dir, </em></strong>in each labelled directory by keeping extra folder <strong><em>output</em></strong>. Later we can combine both initial set of class images and generated images in output folder tougher to train your model to reduce the class imbalance .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ba5df98d4d89251afb6418a030b312c/href">https://medium.com/media/8ba5df98d4d89251afb6418a030b312c/href</a></iframe><p>With the the help Agumentor we are trying to resolve class imbalance which eventually reduces the model overfitting.</p><p><strong>Complete Notebook: </strong>You can refer complete notebook in my git</p><p><a href="https://github.com/Malli-Learn/NN/blob/main/CNN_Skin_Cancer_predeiction_Mallikarjuna_Jana.ipynb">NN/CNN_Skin_Cancer_predeiction_Mallikarjuna_Jana.ipynb at main · Malli-Learn/NN</a></p><p>Thanks for reading!</p><p>Happy Coding .. 👍🏻 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5e520e34599" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>