{"id":19888480,"url":"https://github.com/dynamicanupam/classification_of_customer_complaints_using_nlp","last_synced_at":"2025-08-22T07:42:42.826Z","repository":{"id":254137476,"uuid":"818957918","full_name":"dynamicanupam/Classification_of_customer_complaints_using_NLP","owner":"dynamicanupam","description":"Create a solution that will help in identifying the type of complaint ticket raised by the customers of a multinational bank using NLP and Topic Modelling (NMF)","archived":false,"fork":false,"pushed_at":"2024-09-29T09:17:17.000Z","size":14580,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T04:42:23.157Z","etag":null,"topics":["nlp","nmf","tfidf-vectorizer","topicmodelling"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynamicanupam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-23T11:13:33.000Z","updated_at":"2024-09-29T09:17:20.000Z","dependencies_parsed_at":"2024-11-12T18:17:21.925Z","dependency_job_id":null,"html_url":"https://github.com/dynamicanupam/Classification_of_customer_complaints_using_NLP","commit_stats":null,"previous_names":["dynamicanupam/automatic-ticket-classification-using-nlp","dynamicanupam/classification_of_customer_complaints_using_nlp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FClassification_of_customer_complaints_using_NLP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FClassification_of_customer_complaints_using_NLP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FClassification_of_customer_complaints_using_NLP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynamicanupam%2FClassification_of_customer_complaints_using_NLP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynamicanupam","download_url":"https://codeload.github.com/dynamicanupam/Classification_of_customer_complaints_using_NLP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241317596,"owners_count":19943201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nlp","nmf","tfidf-vectorizer","topicmodelling"],"created_at":"2024-11-12T18:07:23.920Z","updated_at":"2025-03-01T04:42:28.580Z","avatar_url":"https://github.com/dynamicanupam.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Automatic Ticket Classification using NLP\n\u003e Create a solution that will help in identifying the type of complaint ticket raised by the customers of a multinational bank\n---\n\n## Overview\nThis project aims to classify customer complaints into different topics using machine learning techniques. The dataset contains text data related to customer complaints, and the goal is to predict the category or topic of each complaint. Various models such as Logistic Regression, Decision Tree, and Random Forest have been evaluated for their effectiveness in classifying the complaints accurately.\n\n## Dataset Description\nThe dataset consists of customer complaints categorized into several topics:\n- Bank account services\n- Credit Card/Prepaid Card\n- Mortgages/loans\n- Theft/Dispute reporting\n- Others\n\nEach complaint is associated with text data that describes the issue faced by the customer.\n\n## \u003cb\u003eApproach\u003c/b\u003e\n\n1.\tData Loading \u0026 Preprocessing: Conversion of .json data to a dataframe, followed by text cleaning and preprocessing.\n2.\tExploratory Data Analysis (EDA): Detailed analysis to understand the data distribution and extract meaningful insights.\n3.\tFeature Extraction \u0026 Topic Modeling: Use of Non-Negative Matrix Factorization (NMF) to identify patterns and categorize complaints.\n4.\tModel Building: Training multiple supervised learning models including logistic regression, decision tree, random forest, and naive Bayes.\n5.\tModel Evaluation: Comparison of models based on accuracy and other evaluation metrics to select the best-performing model.\n\n## Key Methodology\n### Data Preprocessing\n- Text cleaning: Tokenization, removing stopwords, punctuation, and stemming/lemmatization.\n- Vectorization: Transforming text data into numerical features using TF-IDF vectorization.\n\n### Model Building\n1. **Logistic Regression**\n   - Model trained using `LogisticRegression` from scikit-learn.\n   - Evaluation metrics: Accuracy, Confusion Matrix, Classification Report.\n   \n2. **Decision Tree**\n   - Model trained using `DecisionTreeClassifier` with and without hyperparameter tuning.\n   - Hyperparameters tuned: `max_depth`, `min_samples_leaf`, `criterion`.\n   - Evaluation metrics: Accuracy, Confusion Matrix, Classification Report.\n   \n3. **Random Forest**\n   - Model trained using `RandomForestClassifier` with and without hyperparameter tuning.\n   - Hyperparameters tuned: `n_estimators`, `max_depth`, `min_samples_leaf`, `max_features`.\n   - Evaluation metrics: Accuracy, Confusion Matrix, Classification Report.\n   \n4. **Naive Bayes (Optional)**\n   - Model trained using `MultinomialNB`.\n   - Evaluation metrics: Accuracy, Confusion Matrix, Classification Report.\n   - Hyperparameter tuning: Alpha parameter for Laplace smoothing.\n\n### Model Evaluation\nSeveral machine learning models were evaluated for their effectiveness in classifying complaints:\n\n![image](https://github.com/user-attachments/assets/0e3f3f3e-d518-4692-9999-609164cf81a1)\n\n### Model Selection\n- **Logistic Regression** performed the best overall with the highest test accuracy of 88.37%, indicating robust performance in classifying customer complaints.\n- **Decision Tree** showed improvement after hyperparameter tuning but did not match Logistic Regression's performance.\n- **Random Forest** and **Naive Bayes** models demonstrated lower accuracies compared to Logistic Regression and Decision Tree.\n\n## \u003cb\u003eKey Libraries and Frameworks\u003c/b\u003e\n\n•\tPandas: For data manipulation and analysis.\n\n•\tNumPy: For numerical computations.\n\n•\tScikit-learn: For machine learning algorithms, including logistic regression, decision tree, random forest, and naive Bayes.\n\n•\tNLTK: For natural language processing tasks such as text preprocessing.\n\n•\tSpaCy: For advanced NLP tasks and text processing.\n\n•\tMatplotlib \u0026 Seaborn: For data visualization and exploratory data analysis.\n\n•\tScikit-learn: For feature extraction, model building, and evaluation.\n\n•\tNon-Negative Matrix Factorization (NMF): For topic modeling and identifying patterns in text data.\n\n## Conclusion\nBased on the evaluation results, **Logistic Regression** is recommended for predicting customer complaint topics due to its superior performance in both training and test sets. Further optimizations could involve:\n- Exploring additional text preprocessing techniques.\n- Collecting more diverse complaint data to enhance model generalization.\n- Experimenting with ensemble methods or deep learning architectures for potentially better performance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamicanupam%2Fclassification_of_customer_complaints_using_nlp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynamicanupam%2Fclassification_of_customer_complaints_using_nlp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynamicanupam%2Fclassification_of_customer_complaints_using_nlp/lists"}