<?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 Abhijeetsingh on Medium]]></title>
        <description><![CDATA[Stories by Abhijeetsingh on Medium]]></description>
        <link>https://medium.com/@abhijeetsingh1026?source=rss-18971990cdcf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qrm3dWwXa6A7tcXY</url>
            <title>Stories by Abhijeetsingh on Medium</title>
            <link>https://medium.com/@abhijeetsingh1026?source=rss-18971990cdcf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:23:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhijeetsingh1026/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[Automating Cryptocurrency Data Pipelines with GCP]]></title>
            <link>https://abhijeetsingh1026.medium.com/end-to-end-data-engineering-automating-cryptocurrency-data-pipelines-with-gcp-a978b8370766?source=rss-18971990cdcf------2</link>
            <guid isPermaLink="false">https://medium.com/p/a978b8370766</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Abhijeetsingh]]></dc:creator>
            <pubDate>Sun, 24 Nov 2024 00:33:48 GMT</pubDate>
            <atom:updated>2024-12-12T20:36:04.813Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>The Automated Crypto Data Pipeline and Analytics <a href="https://github.com/Abhijeet1026/Automated_ETL_CRYPTO_DATA_PIPELINE_GCP/tree/main">project</a> focuses on building a robust data pipeline using Google Cloud Platform (GCP) tools to extract, process, and analyze cryptocurrency data from the <a href="https://docs.coingecko.com/reference/coins-markets">CoinGecko</a> API. CoinGecko, a widely used platform, provides real-time information on various cryptocurrencies, capturing key metrics such as prices, market capitalization, trading volumes, and supply data.</p><p>At the heart of this project is a fully automated data pipeline that seamlessly ingests high-frequency crypto data in near real-time. Using GCP tools like Cloud Storage, Cloud Composer, Dataproc, and BigQuery, the pipeline performs efficient data extraction, transformation, and loading (ETL). This setup ensures scalability and reliability, handling large volumes of cryptocurrency data without performance bottlenecks.</p><p>The pipeline not only processes raw data but transforms it into meaningful insights, such as identifying the current prices, total supply, trading volumes, and market capitalizations of top-performing coins. This comprehensive approach enables users to understand cryptocurrency trends and make data-driven decisions in an ever-changing market.</p><p>By combining the power of the CoinGecko API with the scalability of GCP’s data tools, this project demonstrates how cloud-based solutions can be leveraged to build efficient and impactful analytics systems</p><h3>Objective</h3><p>The main objectives of this project are as follows:</p><ul><li>Develop a Near Real-Time Data Pipeline: Utilize Google Cloud Platform (GCP) tools to build a robust data pipeline that extracts cryptocurrency data from the CoinGecko API every 10 minutes, ingesting it into Google Cloud Storage (GCS).</li><li>Data Transformation and Warehousing: Process and transform raw data from GCS using Dataproc, load it into Google BigQuery as the central data warehouse, and archive the raw data back to GCS for backup and future reference.</li><li>End-to-End Automation: Automate and orchestrate the entire pipeline using Apache Airflow running on Cloud Composer to ensure seamless, repeatable workflows.</li><li>Data Visualization: Leverage Looker to create insightful visualizations, enabling users to understand trends and make data-driven decisions.</li></ul><p>This project showcases an end-to-end data engineering solution for real-time cryptocurrency analytics using GCP tools.</p><h3>Architectural Solution</h3><p>The diagram below showcases the architectural solution built using cloud technologies with automation at its core. This architecture is optimized for processing near real-time data and efficiently loading transformed data into BigQuery in batches. It is designed to ensure scalability, performance, and cost-effectiveness by leveraging the advanced capabilities of cloud infrastructure to minimize operational expenses while maximizing efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XG9cbxc6o7-3lfAtizr9oQ.png" /><figcaption>Automated End to End Data Pipeline</figcaption></figure><p>Terraform is used as an Infrastructure as Code (IaC) tool, enabling the automated provisioning and management of cloud resources such as Google Cloud Storage (GCS) buckets and BigQuery tables. By defining infrastructure configurations in code, Terraform ensures consistent, repeatable deployments, which enhances collaboration and reduces the risk of manual errors.</p><p>Apache Airflow, running on Cloud Composer, acts as the workflow orchestration tool in this architecture. It streamlines the execution and monitoring of data workflows, allowing for the creation of complex data pipelines with built-in error handling and retry mechanisms. This ensures tasks are executed in the correct sequence and are easily monitored for performance.</p><p>In the following section, we will explore other tools and technologies that further complement this architecture</p><h3>Data Pipeline</h3><p>A data pipeline is a series of data processing steps that automate the movement and transformation of data from various sources to a destination, typically a data warehouse or data lake. It ensures that data is collected, processed, and made available for analysis in a timely and efficient manner, allowing organizations to derive insights and make informed decisions based on up-to-date information.</p><ul><li><strong>Data Extraction:</strong> This automated pipeline is designed to efficiently handle near-real-time data extraction. Raw data is fetched from the CoinGecko API every 10 minutes. An Airflow DAG has been created to manage and automate this process, ensuring reliable data retrieval. Below is a graphical representation of this DAG in Airflow.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCaIe-Kk2ANrqnNhzkHBSg.png" /><figcaption>Airflow DAG: To extract the Data</figcaption></figure><ul><li><strong>Transformations</strong>: Data transformation is performed using a DataProc cluster, a fully managed cloud service provided by Google Cloud that enables efficient, scalable processing of big data using Apache Spark and Hadoop. It simplifies cluster management, scaling, and integration with other Google Cloud Platform (GCP) services. This transformation process is orchestrated through an Airflow DAG, which is executed every 7 hours. The first task in the DAG creates the DataProc cluster. Once the cluster is operational, a job is submitted using a Python script stored in a GCS bucket to transform the raw data according to the specified job. After the transformation, the job loads the processed data into BigQuery in batches. Once the transformation and loading tasks are complete, the DAG triggers another task to delete the DataProc cluster. Deleting the cluster after each execution helps reduce costs by avoiding charges for idle resources. Finally, the last task of the DAG moves the raw data files that were processed by the DataProc cluster into an archive bucket for future reference, ensuring data preservation. Please refer below to see the screenshot of graphical representation of this dag.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIoQ32fSnoCULLCP0Z7DhA.png" /><figcaption>Airflow DAG: Transform &amp; load Data</figcaption></figure><ul><li><strong>Batch data load:</strong> As part of the transformation process, the job loads the processed data into BigQuery in batches. This batch loading ensures efficient storage and querying in BigQuery, allowing for better performance during data analysis. The data is loaded in scheduled intervals (every 7 hours) as specified in the Airflow DAG, ensuring the warehouse is updated with the latest data while optimizing resource usage.</li><li><strong>Automation:</strong> The entire data pipeline, from data extraction to transformation and batch loading, is automated using Apache Airflow running on Cloud Composer. Airflow orchestrates the entire workflow, managing tasks such as scheduling data extraction every 10 minutes, triggering the transformation process every 7 hours, and ensuring proper task sequencing. This automation reduces manual intervention, streamlines pipeline execution, and enhances reliability by handling errors and retries. It ensures that the data pipeline runs efficiently and consistently without downtime.</li></ul><h3>Visualization</h3><p>Data visualization is the graphical representation of information and data, allowing complex datasets to be easily understood and analyzed. Effective visualizations enable stakeholders to identify trends, patterns, and insights quickly, facilitating informed decision-making; the visualizations for this project are created using Looker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vY9gfBAL3dqDyqKhVh7z9Q.png" /><figcaption>Looker Dashboard</figcaption></figure><p>The Automated Crypto Data Pipeline and Analytics project leverages Google Cloud Platform (GCP) tools to create a fully automated pipeline for extracting, processing, and analyzing real-time cryptocurrency data from the CoinGecko API. This solution automates the ETL (Extract, Transform, Load) process, ensuring scalability, reliability, and high efficiency.</p><p>The pipeline extracts data every 10 minutes, transforms it using DataProc for large-scale processing, and loads it into BigQuery for analysis. The entire process is orchestrated by Apache Airflow on Cloud Composer, ensuring seamless automation and reducing manual intervention. Additionally, Terraform is used for Infrastructure as Code (IaC) to automate the provisioning and management of cloud resources, ensuring consistent and repeatable deployments.</p><p>This solution provides key advantages such as reduced operational overhead, cost optimization by eliminating idle resources, and scalability to handle large volumes of data. The automated pipeline enables real-time insights into cryptocurrency trends, supporting data-driven decision-making. Finally, Looker is used for data visualization, offering easy-to-interpret charts that highlight critical metrics like market capitalization, price trends, and trading volumes, helping stakeholders stay informed about market movements.</p><h3>Reference</h3><ul><li>Project Code : <a href="https://github.com/Abhijeet1026/Automated_ETL_CRYPTO_DATA_PIPELINE_GCP">Click Here</a></li><li>CoinGecko API : <a href="https://docs.coingecko.com/reference/coins-markets">Click Here</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a978b8370766" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub Archive Data Engineering and Analytics Project]]></title>
            <link>https://abhijeetsingh1026.medium.com/github-archive-data-engineering-and-analytics-project-38320b29ffb2?source=rss-18971990cdcf------2</link>
            <guid isPermaLink="false">https://medium.com/p/38320b29ffb2</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[pyspark]]></category>
            <dc:creator><![CDATA[Abhijeetsingh]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 21:44:21 GMT</pubDate>
            <atom:updated>2024-11-03T13:58:26.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G9SwK8HzjoAoaSTnXjiSiQ.png" /></figure><h3><strong>Introduction</strong></h3><p>The GitHub Archive Data Engineering and Analytics <a href="https://github.com/Abhijeet1026/GithubAnalytics_DE/tree/main">project</a> aims to transform raw <a href="https://www.gharchive.org/">GitHub</a> event data into meaningful insights about platform usage and activity trends. GitHub, as a leading platform for version control and collaboration, generates vast amounts of data daily, encompassing millions of user interactions, repository contributions, and events. This project captures, processes, and analyzes this data to provide valuable information, including user engagement levels, the most active repositories, bot identification, popular event types, and daily commit patterns. By developing a robust data pipeline and analytics framework, this project enables stakeholders to gain deeper insights into how GitHub is utilized, revealing trends in developer activity, popular project contributions, and overall platform health.</p><h3><strong>Objective</strong></h3><p>The main objective of this project is as below:</p><ul><li>Develop an efficient data engineering pipeline using PySpark to extract data from a web API and ingest it into Google Cloud Storage (GCS).</li><li>Transform and load raw data from GCS into Google BigQuery as the data warehousing solution.</li><li>Use dbt Cloud to transform data into a star schema and create materialized views based on this schema for optimized analysis.</li><li>Visualize the data using Looker, leveraging materialized views for enhanced performance and insights.</li></ul><h3>Architectural Solution</h3><p>The diagram below illustrates the architectural solution designed utilizing cloud technologies. This architecture is optimized for handling millions of rows through batch processing, ensuring efficiency and scalability. Additionally, it is a cost-effective solution, leveraging cloud capabilities to minimize operational expenses while maximizing performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQ17VdemExT7P-g4iqgKJA.png" /><figcaption><strong>Architecture</strong></figcaption></figure><p>Terraform is utilized as an Infrastructure as Code (IaC) tool, enabling the automated creation and management of cloud resources, including Google Cloud Storage (GCS) buckets and BigQuery tables. By defining infrastructure configurations in code, Terraform facilitates consistent and repeatable deployments, enhancing collaboration and reducing manual errors.</p><p>Prefect serves as the workflow orchestration tool in this architecture, streamlining the execution and monitoring of data workflows. It allows for the creation of complex data pipelines with built-in error handling and retry mechanisms, ensuring that tasks are executed in the correct order and can be easily monitored.</p><p>In the next section, we will explore additional tools and technologies that complement this architecture</p><h3>Data Pipeline</h3><p>A data pipeline is a series of data processing steps that automate the movement and transformation of data from various sources to a destination, typically a data warehouse or data lake. It ensures that data is collected, processed, and made available for analysis in a timely and efficient manner, allowing organizations to derive insights and make informed decisions based on up-to-date information.</p><ul><li><strong>Ingestion:</strong> This pipeline is designed to reliably handle high-volume, raw data extracted from the GitHub Events API. Using PySpark ensures scalability and speed in processing millions of records daily before they are stored in Google Cloud Storage (GCS).</li><li><strong>Processing and Storing: </strong>Data from GCS is cleaned and loaded into BigQuery using PySpark, enabling secure, centralized storage optimized for analytics. BigQuery’s architecture allows for fast querying and seamless integration with downstream tools for analysis and visualization.</li><li><strong>Transformations:</strong> dbt Cloud facilitates the transformation of data into a star schema, improving query performance and data organization. Creating materialized views on top of the star schema enables quicker and more efficient analysis, reducing processing time for large datasets. The diagram below illustrates the lineage information of dbt:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8LRYqhdciJeofr8B9XKDg.png" /><figcaption><strong>dbt cloud lineage</strong></figcaption></figure><h3>Visualization</h3><p>Data visualization is the graphical representation of information and data, allowing complex datasets to be easily understood and analyzed. Effective visualizations enable stakeholders to identify trends, patterns, and insights quickly, facilitating informed decision-making; the visualizations for this project are created using Looker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5xiUdXFMPKUA0cu7DNNqw.png" /><figcaption><strong>Dashboard</strong></figcaption></figure><p>The visualization above provides key insights into GitHub activity, highlighting several important metrics. It displays the repository with the highest number of commits, offering a clear view of which projects are the most actively developed. Additionally, it illustrates the distribution of various types of Git events, helping users understand the nature of interactions on the platform. The visualization further reveals the trend in the number of commits during the first ten days of the month, showcasing patterns in user engagement. Lastly, it effectively distinguishes between bot accounts and real user accounts, providing valuable context on the authenticity of contributions within the data.</p><h3>Performance Optimization</h3><p>In the GitHub Archive Data Engineering and Analytics project, performance optimization plays a crucial role in ensuring the efficient processing and analysis of vast datasets. By leveraging advanced technologies such as PySpark for data ingestion and processing, we enhance the pipeline’s ability to handle millions of records daily with speed and scalability.</p><p>To further optimize performance, we utilize Google BigQuery’s capabilities, which are designed for fast querying and high concurrency, allowing users to analyze large volumes of data without significant delays. The implementation of dbt Cloud facilitates the transformation of data into a star schema, which streamlines queries and improves data organization. Additionally, the creation of materialized views based on the star schema ensures that analytical queries are executed swiftly, reducing processing time and enhancing overall responsiveness.</p><p>By focusing on these optimization strategies, the project not only meets the demands of high data volumes but also delivers timely insights that empower stakeholders to make informed decisions efficiently.</p><h3>Summary</h3><p>The GitHub Archive Data Engineering and Analytics project aims to convert vast amounts of raw GitHub event data into actionable insights regarding platform usage and activity trends. By developing a robust data pipeline using technologies like PySpark and Google Cloud Platform, the project efficiently captures, processes, and analyzes millions of user interactions and repository contributions daily. The architecture incorporates Terraform for infrastructure management and Prefect for workflow orchestration, ensuring streamlined data processing. Visualization tools such as Looker are employed to provide clear insights into user engagement, active repositories, and trends in commits, enhancing decision-making capabilities for stakeholders. Overall, the project emphasizes performance optimization to handle large datasets effectively while delivering timely and meaningful analytics</p><h3><strong>References</strong></h3><ul><li>Project Link <a href="https://github.com/Abhijeet1026/GithubAnalytics_DE/tree/main">click here</a></li><li>GitHub Archive data <a href="https://www.gharchive.org/">click here</a></li><li>To learn about GCP <a href="https://www.youtube.com/watch?v=ae-CV2KfoN0&amp;list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&amp;index=14&amp;ab_channel=DataTalksClub%E2%AC%9B">click here</a></li><li>To learn about Infrastructure as code (IaC) Terraform <a href="https://www.youtube.com/watch?v=s2bOYDCKl_M&amp;list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&amp;index=11&amp;ab_channel=DataSlinger">click here</a></li><li>To learn about Workflow orchestration Prefect <a href="https://www.youtube.com/watch?v=cdtN6dhp708&amp;list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&amp;ab_channel=DataTalksClub%E2%AC%9B">click here</a></li><li>To learn about Data Warehouse BigQuery <a href="https://www.youtube.com/watch?v=jrHljAoD6nM&amp;list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&amp;index=34&amp;ab_channel=DataTalksClub%E2%AC%9B">click here</a></li><li>To learn about dbt cloud <a href="https://www.youtube.com/watch?v=V2m5C0n8Gro&amp;list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&amp;index=46&amp;ab_channel=Victoria">Click here</a></li><li>To learn about spark <a href="https://www.youtube.com/watch?v=FhaqbEOuQ8U&amp;list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&amp;index=52&amp;ab_channel=DataTalksClub%E2%AC%9B">Click here</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38320b29ffb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentiment Classification of Yelp Data]]></title>
            <link>https://medium.com/analytics-vidhya/sentiment-classification-of-yelp-data-293f401c3656?source=rss-18971990cdcf------2</link>
            <guid isPermaLink="false">https://medium.com/p/293f401c3656</guid>
            <category><![CDATA[text-classification]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Abhijeetsingh]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 22:55:31 GMT</pubDate>
            <atom:updated>2021-03-12T15:02:43.905Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sentiment Analysis of Yelp Data — Text classification</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osqvYwMWshtq7DSiFuMp-Q.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>Customer feedbacks in terms of reviews has become very important part of the online business as it helps to understand user emotions towards the product. Online web based business services such as Amazon reviews, Google My Business, yelp, city search give options to their customer to provide reviews as their opinion in the form of textual data as well as numerical rating out of 5. These feedbacks from thousands of the customer acts as the “online word-of-mouth”. These feedbacks given by consumers or reviewers becomes the selection criteria of the product or services for new or existing customers as the reviews overtime provides the current quality of the services being offered. In the recent period several studies have shown that these feedbacks creates both positive and negative impact on the business because of the opinions shared by the customer on the online platform.</p><p><strong>Problem Definition : </strong>The objective of this project is to classify the reviews of the customers in to positive and negative sentiments using natural language processing and machine learning techniques. This is an important problem to solve as it will save time of an individual while making decision about the product to solely allow for checking the ratings instead of textual reviews.</p><h3><strong>Dataset</strong></h3><p>The dataset used in our project is provided by Yelp . This company produces crowd source reviews about the variety of Business sources. The dataset obtained from Yelp is massive in volume. It includes five json files for different aspects of the business namely: tips, check-in, reviews, user, business. Each one of them are stored in json file. The user dataset contains 1968703 records with 22 features, the business dataset contains 209393 records with 14 features records, the review dataset contains 80211222 with 9 features, the tip dataset contains 1320761 records with 5 features, the check-in dataset contains 175187 records.</p><p>The business json file has attributes such as business ID, business name, business location, rating stars, count of the reviews and the information whether the restaurant is open or not, it also has categories as the feature which include the information about the different types of business data present in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ieSuAER_dFpE69j38qbxYA.png" /></figure><p>The review json file also has some attribute column namely review id (indicates the id of the review), user id (indicates the id of the user giving reviews), business id (indicates the id of the different business), it also has star rating as the column and text which stores the reviews of each individual.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yF9YFRrFsfNpdRT-qpKA7w.png" /><figcaption>Reviews Data-frame</figcaption></figure><p>The main data used for building the machine learning model in our project is present in business json and review json file. The yelp dataset adds lot of values to the business as the data from any category of the business can be used to understand the behaviour of the individual towards that product. Therefore, building model on such data can help business to remain competitive in the market by providing accurate recommendation to the user based on their sentiments. Therefore, for our project we will be using the reviews of the restaurant category of the business which has 5056227 records. Due to computing constraints, in this work we only make use of 10000 records to build our model. The target label is binary, as the ratings above 3 stars are labelled as positive review and any other rating are labelled as negative review.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yFxtb45i1fviUkvSMEzfJw.png" /></figure><h3>Data Preprocessing</h3><p>Data clean up and pre-processing is considered one of the main tasks to be performed in any machine learning project to make sure that machine learning models are built on the quality data. Relevant or important information is extracted from the data after doing pre-processing on it.</p><p>In this project we have performed multiple steps to clean and process the data. At first, we dropped all the unnecessary column present in the dataset which were not required in building the models. We also performed the following data pre-processing technique on the reviews.</p><blockquote>Removing the unnecessary column</blockquote><blockquote>Removing the contraction from the reviews</blockquote><blockquote>Removal of digits, special characters and emoticons from the reviews</blockquote><blockquote>Removing of stop words from the review</blockquote><blockquote>Converting all the word in the lowercase format</blockquote><blockquote>Performing lemmatization on the reviews</blockquote><p>The stop words from the dataset of reviews were eliminated by using NLTK python library. The most common stop words such as “I”, “am” etc. were dropped as they tend to skew the results but some of the stop words were not removed such as “not”, “non” etc. As in our project of “S<em>entiment Classification of Yelp data</em>” word importance is crucial factor as it will define the sentiment of the reviews so if we remove the word “not” from “<em>not good” </em>this will convert a negative sentiment sentence to a positive one. Therefore, some of the stop words were not eliminated using the NLTK library while doing data pre-processing to preserve the real sentiments of the reviews. We also did perform lemmatization on the reviews by using NLTK library. Lemmatization is a method in which words are transformed in their lemma form. For example, the word “<em>Walking” </em>will be transformed to “<em>walk”</em>. This process will help in the proper analysis of the words that are present in the reviews and the target label were converted in to binary form ( 0 : Negative Reviews, 1: Positive Reviews).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*RB5ZoAl61ATVuoAiaLtAgw.png" /><figcaption>Processed Data-Frame</figcaption></figure><h3>Data Visualization</h3><p>Quite similar to other components of machine learning, data visualization is also one of the important parts, as it provides a visual insight into the kind of the data model is dealing with. More precise and predictable insights can be drawn from the model if the input data is well understood. As such we created various visualization for the input data to our model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XiS02LKph7XImc6w0-7kLg.png" /><figcaption>Sentiment Polarity plot of the reviews</figcaption></figure><p>The above figure shows the sentiment analysis of positive and negative reviews. This plot provides a clear differentiation between positive and negative review based on their sentiments. As we can see the negative reviews are classified more towards negative polarity and positive reviews are mostly skewed towards positive polarity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eBULx0R8CAR_OGCJnlumlA.png" /><figcaption>Text length of the reviews</figcaption></figure><p>The above figure shows the text length for both positive and negative reviews. It gives more concise understanding as in the above figure the negative reviews have almost same text length distribution as positive reviews. This means that users tend to write both positive and negative reviews with almost same length.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9YrvbFvi95ahN9K9Zm0CzQ.png" /><figcaption>Unigram word frequencies of the reviews</figcaption></figure><p>The above figure shows the top 20 frequent unigram words for both positive and negative reviews. For the negative reviews we have words such as “not”, “bad” most occurring words, and for the positive review’s words such “great”, “best” are more frequent occurring words. Hence, It gives us the clear understanding of the unigram words used in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fa4FN-d_6gVS6CLAcf52iA.png" /><figcaption>Bi-gram word frequencies of the reviews</figcaption></figure><p>The above plot shows the top 20 bigram words that appears both in positive and negative reviews of the text. It can be clearly seen by the above plot that the bigrams are more relevant as we can see the word “not good” completely occurred in the negative reviews whereas the word “good food” has appeared mostly in the positive reviews of the text. Hence, we can conclude that bi-gram vectors of words might be one of the important features in building the models.</p><h3>Feature Engineering</h3><p>Feature Engineering is a task which is carried out to improve the overall predictive performance of a model by transforming its feature space . Feature engineering is central and the most important step in the process as it the source using which machine learning models predict the outcome.</p><p><strong>Textual Feature: </strong>After splitting the dataset in to train and test. Two important feature engineering techniques were used to convert text to vectors.</p><ol><li><strong>Term Frequency Inverse document frequency:</strong> It is the statistical approach in a collection or the corpus. This technique identifies how important is a word in a document. We have used TF-IDF to convert text into numerical representation of vectors. In our project we have used the bigram variant of TF-IDF as we can conclude from the bigram words plot that these feature might be as one of the best while predicting the outcome.</li><li><strong>SpaCy:</strong> The second textual feature engineering technique used for the prediction of positive and negative reviews is called SpaCy. SpaCy is a word embedding technique that is used to convert the reviews from the dataset into vectors. Using “en_core_web_lg” module of SpaCy the textual reviews of each user is tokenized into words and vectors are created from them. These vectors are then averaged to result in 300-dimension numerical features which we feed down to the downstream machine learning algorithm.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-EzzvrsFUw5Yi4P3qfpNg.png" /><figcaption>Reviews converted in to vectors using SpaCy library</figcaption></figure><p><strong>Numerical Feature: </strong>Text length numerical feature was developed using the reviews given by the customers.</p><h3>Implementation</h3><p><strong>Multinomial Naive Bayes : </strong>The first baseline model used was multinomial naive bayes with TFIDF and text length features and all the parameters of the algorithms were set to default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnHJrHBVQ2ICHYafx3ByKg.png" /></figure><p>The above results obtained from the baseline model shows that the model was able to perform better on positive class compared to the negative class. It seems like model is biased towards one class.</p><p><strong>Support Vector Machine: </strong>This algorithm was again used with TFIDF and text length features along with the default parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h0tsY30FGdDpOTZgGL_JSg.png" /><figcaption>Results</figcaption></figure><p>The predictions of the second model was quite similar to first model as again this model was biased towards positive class.</p><blockquote>In order to overcome the above problem and to built accurate models we did oversampling of the training data using the imblearn library so that the size of the minority class can match to the majority class.</blockquote><p><strong>Random Forest : </strong>This algorithms was trained using the oversampled training dataset with features TFIDF and Text length. Hyperparameter tuning was also performed using Grid search algorithm to get the best parameters for the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9x31Um_kklCYk82MpCgQw.png" /><figcaption>Results</figcaption></figure><p>As we can see there is significant improvement in the results of the random forest model. The model was able to perform better on both the classes of the target label.</p><p><strong>Support Vector Machine: </strong>This algorithm was trained on the oversampled dataset with SpaCy vectors and text length features. Grid search algorithm was used to obtain the best parameters for this model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxKiVJif3eI7xPA1gG_fzg.png" /><figcaption>Results</figcaption></figure><p>The results obtained from the above model were satisfying as it performed better on both the classes of the target variable. In fact, Support Vector Machine model was the best performing with F1 score of 90 percent.</p><h3>Conclusion</h3><p>The goal of this project was to build a predictive model to classify the user reviews to either positive or negative sentiments. We build two models with different scenarios. The first model utilized the algorithms with their default parameters and because of the imbalance problem in the classes model 1 performed poorly. The second model was built by training various machine learning algorithm after balancing the classes of the training dataset with different features. The result obtained from the Support vector machine algorithm from model 2 was best among all of them with SpaCy and Text length feature. We conclude that if the data can be curated properly of the yelp reviews and also proper feature engineering should be performed to yield good results.</p><p><strong>Code Link :</strong> <a href="https://github.com/Abhijeet1026/Ml-Projects/blob/master/Sentiment%20classification%20on%20Yelp%20dataset.ipynb">https://github.com/Abhijeet1026/Ml-Projects/blob/master/Sentiment%20classification%20on%20Yelp%20dataset.ipynb</a></p><p><strong>References :</strong></p><p><a href="https://pubsonline.informs.org/doi/10.1287/mnsc.49.10.1407.17308">https://pubsonline.informs.org/doi/10.1287/mnsc.49.10.1407.17308</a></p><p><a href="https://arxiv.org/pdf/1605.05362.pdf">https://arxiv.org/pdf/1605.05362.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=293f401c3656" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/sentiment-classification-of-yelp-data-293f401c3656">Sentiment Classification of Yelp Data</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>