<?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 Omkar Gawade on Medium]]></title>
        <description><![CDATA[Stories by Omkar Gawade on Medium]]></description>
        <link>https://medium.com/@omkargawade?source=rss-79b20752c44d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c_hnfPLMdgnJMU1nuO4OKg.jpeg</url>
            <title>Stories by Omkar Gawade on Medium</title>
            <link>https://medium.com/@omkargawade?source=rss-79b20752c44d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:09:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@omkargawade/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[Building a Data Review Tool with AI-Assisted Development (Open AI Codex x Handshake Challenge…]]></title>
            <link>https://omkargawade.medium.com/building-a-data-review-tool-with-ai-assisted-development-open-ai-codex-x-handshake-challenge-1aefedf035de?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1aefedf035de</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[openai-codex]]></category>
            <category><![CDATA[vercel]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Thu, 21 May 2026 20:27:58 GMT</pubDate>
            <atom:updated>2026-05-21T20:27:58.555Z</atom:updated>
            <content:encoded><![CDATA[<h3>AI-Assisted Full Stack Development: Building a Data Review Tool with OpenAI Codex, FastAPI &amp; Next.js</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zz9j4NtJ2a9-31ArVoCC8Q.avif" /><figcaption>Image by Alex Shuper from <a href="https://unsplash.com/photos/a-robot-hand-holding-a-letter-that-says-ai-OFxYMp8VkdI">Unpashed.com</a></figcaption></figure><h3>Most business teams sit on valuable data — but the moment someone opens a CSV, progress slows down. Columns are unclear. Missing values appear. Stakeholders wait for analysts.</h3><p>I wanted to change that. So I built a tool that turns raw files into instant, plain insights in seconds.Modern teams collect more data than they can interpret. But for non-technical users, even opening a CSV or JSON file can feel like hitting a wall.</p><p>That’s what motivated me to build a <strong>Data Review Tool, </strong>a production-style MVP that helps users instantly understand what’s inside their data files before involving analysts or writing a single line of code.</p><p>This project was built as part of the <strong>Codex AI Challenge on Handshake</strong>, using AI-assisted development workflows and a full-stack architecture deployed using free-tier infrastructure.</p><h3>Why I Built It</h3><p>In real-world workflows, a lot of time is wasted on:</p><ul><li>Opening unfamiliar datasets</li><li>Cleaning broken files</li><li>Figuring out column meaning</li><li>Explaining data quality to stakeholders</li></ul><p>This tool acts as a <strong>first-pass intelligence layer</strong> over raw data especially useful for:</p><ul><li>Business users</li><li>Product managers</li><li>Non-technical stakeholders</li><li>Analysts doing quick exploratory checks</li></ul><h3>What the Data Review Tool Does</h3><p>The goal is simple:</p><blockquote><em>Upload a file → instantly understand its structure, quality, and insights.</em></blockquote><p>Supports 7 file formats: CSV, TSV, Excel (.xlsx, .xls), JSON, JSONL, and Parquet.</p><p>Once a file is uploaded, the system performs three layers of analysis:</p><ul><li><strong>Structure</strong> — identifies schema, data types, missing fields</li><li><strong>Quality</strong> — detects duplicates, inconsistencies, outliers</li><li><strong>Insights</strong> — generates charts, trends, and summaries</li></ul><h3>System Architecture</h3><p>The system is split into two main layers:</p><h3>Backend (FastAPI + Python)</h3><p>A modular analytics engine responsible for:</p><ul><li>File ingestion (CSV, JSON, Excel, Parquet, TSV)</li><li>Schema inference and validation</li><li>Data cleaning pipeline</li><li>Statistical analysis engine</li><li>Insight generation layer</li></ul><p>Key modules:</p><ul><li>ingestion.py → Safe file parsing + encoding detection</li><li>validation.py → Schema inference + data quality checks</li><li>cleaning.py → Missing value handling, normalization, deduplication</li><li>analysis.py → Stats, correlations, aggregations, trends</li><li>insights.py → Rule-based executive summaries</li></ul><p>Internal database: <strong>SQLite</strong></p><h3>Frontend (Next.js Dashboard)</h3><p>A clean UI built for fast exploration:</p><ul><li>Drag-and-drop file upload</li><li>Sample dataset support</li><li>Data quality visualization</li><li>Plotly-based charts</li><li>Insight panels in plain English</li></ul><p><strong>Preview of the start page after uploading the file:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-OZrLpxeOq9MzaL9LyGyg.png" /><figcaption>Image uploaded by Author</figcaption></figure><p><strong>Analysis results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r399NqiCIKvCOYC23jPzLg.png" /><figcaption>Image uploaded by Author</figcaption></figure><p><strong>Cleanup notes, Raw details &amp; Auto-Generated Visualizations:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFnCWmLibqEDYpjvTH5aXg.png" /><figcaption>Image uploaded by Author</figcaption></figure><p><strong>Possible Correlations:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHqD-EGkec7H5U8vghpX8w.png" /><figcaption>Image uploaded by Author</figcaption></figure><h3>Example API Flow</h3><p><em>The frontend sends a POST /upload request with the user’s file. FastAPI ingests the file, validates its structure, cleans the data, runs analysis, and generates insights. The API then returns a structured JSON payload containing quality checks, chart data, and plain-English takeaways, which the frontend displays in a user-friendly dashboard.</em></p><p>The system returns:</p><ul><li>ingestion report</li><li>validation report</li><li>cleaning log</li><li>analysis results</li><li>insights summary</li></ul><p>This allows the frontend to render a complete data breakdown instantly.</p><h3>Deployment Strategy</h3><p>To keep the project production-like but cost-efficient:</p><h3>Backend</h3><ul><li>Hosted on <strong>Render (free tier)</strong></li><li>Python 3.11</li><li>SQLite</li></ul><h4>Heartbeat loop implemented:</h4><p>To improve the experience on Render’s free tier, I added a lightweight heartbeat loop to the backend. Every 10 minutes, the service sends a request to its own /health endpoint while it is running. This helps keep the instance warm and reduces the chance that the app goes idle between user visits. It is intentionally simple and low-cost, so it improves responsiveness without changing the core product flow.</p><h3>Frontend</h3><ul><li>Hosted on <strong>Vercel</strong></li><li>Connected via NEXT_PUBLIC_API_URL</li></ul><h3>App Limits:</h3><pre>export MAX_UPLOAD_SIZE_MB=25 MB<br>export LARGE_UPLOAD_WARNING_MB=10 MB</pre><h3>GitHub Repo</h3><p><a href="https://github.com/omkargawade777/Handhshake-AI-_-insights">https://github.com/omkargawade777/Handhshake-AI-_-insights</a></p><h3>Built with Codex AI</h3><p>A major part of this project was built using <strong>Codex-assisted development workflows</strong>.</p><blockquote><em>I used OpenAI Codex to scaffold the initial FastAPI file-ingestion layer, then iteratively refined validation logic and edge-case handling through AI-assisted debugging.</em></blockquote><p>This dramatically reduced development time while maintaining a production-style architecture.</p><h3>Measurable Outcomes</h3><ul><li>Built a data review platform that supports 7 file formats and uploads up to 25 MB. Recommended file size: up to 10 MB for the fastest review. Files between 10 and 20 MB may take longer on the free backend.</li><li>Validated the backend with 27 passing reliability tests covering ingestion, analysis, and edge cases.</li><li>Deployed the frontend on Vercel and the backend on Render free tier using a lightweight SQLite-based architecture.</li><li>Reduced demo load time by shrinking the sample dataset to 42 rows while preserving the core analytical signals.</li><li>Improved startup efficiency by deferring heavy analytics imports until the first request.</li></ul><p><strong>Benchmark Table:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1uWz3YZoF8dmYsy8MBB4Q.png" /><figcaption>Image uploaded by Author</figcaption></figure><h3>Key Learnings</h3><p>This project reinforced a few important ideas:</p><ul><li>Data tools should explain themselves, not just compute results</li><li>Structured pipelines make AI outputs reliable and debuggable</li><li>Even simple rule-based systems can create strong AI experiences when well designed</li><li>Free-tier infrastructure is enough to build and deploy meaningful products.</li></ul><h3>Live Demo</h3><p><a href="http://frontend-b37x3amh5-omkargawade777-gmailcoms-projects.vercel.app/">Demo live website</a></p><h3>References:</h3><ul><li>Handshake. <em>Build with AI Program</em>.<br> <a href="https://app.joinhandshake.com/build-with-ai">https://app.joinhandshake.com/build-with-ai</a></li><li>OpenAI. <em>Codex Documentation (OpenAI Developers Platform)</em>.<br> <a href="https://developers.openai.com/codex">https://developers.openai.com/codex</a></li><li>Render. <em>Web Services Documentation</em>.<br> <a href="https://render.com/docs/web-services">https://render.com/docs/web-services</a></li><li>Vercel. <em>Frontend deployment Documentation <br></em><a href="https://vercel.com/docs">https://vercel.com/docs</a></li></ul><h3>Verdict:</h3><p>This project reminded me that AI isn’t replacing engineering; it’s amplifying it. By combining structured pipelines with AI-assisted development, a single developer can now build production-style products faster than ever before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1aefedf035de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning for Insurance Risk: An End-to-End Claim Severity Modeling Case Study]]></title>
            <link>https://omkargawade.medium.com/machine-learning-for-insurance-risk-an-end-to-end-claim-severity-modeling-case-study-a265acc04275?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a265acc04275</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[insurance-analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gradient-boosting]]></category>
            <category><![CDATA[case-study]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 12:45:33 GMT</pubDate>
            <atom:updated>2026-02-17T12:45:33.905Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pn7CkOoKDVikXrJyTzSjVw.avif" /><figcaption>Image from Unspash.com by <a href="https://unsplash.com/@vladdeep">Vlad Deep</a></figcaption></figure><h3>Introduction</h3><p>Insurance pricing is fundamentally a risk estimation problem. In this project, I built an end-to-end machine learning model to predict claim severity (loss amount) using the Allstate Claims Severity dataset. The goal was to develop a robust regression model that accurately estimates loss while maintaining strong generalization performance.</p><p>This project demonstrates the complete machine learning workflow — from data preprocessing to hyperparameter optimization and model evaluation.</p><h3>Problem Statement</h3><p>Insurance companies must estimate how severe a claim might be to:</p><ul><li>Set premiums appropriately</li><li>Manage financial reserves</li><li>Improve underwriting decisions</li><li>Reduce unexpected loss exposure</li></ul><p>The objective of this project was to: <em>Predict continuous claim loss using structured tabular data containing categorical and numerical features.</em></p><p>This is a classic regression problem, but with real-world complexities such as high-cardinality categorical variables and potential noise in the target.</p><h3>Dataset Overview</h3><p>The dataset was extracted from OpenML: Allstate claim severity challenge, this dataset has 188318 instances with 14 numeric continuous features and 116 categorical features. All the features are anonymized so extracting semantic meaning of EDA is difficult. The target variable for this analysis is continuous (Loss) .</p><p>Below is the link for the dataset:</p><p><a href="https://www.openml.org/search?type=data&amp;status=active&amp;id=42571">OpenML</a></p><h3><strong>Exploratory data analysis</strong></h3><p>Since the dataset has almost 100 plus categorical variables, we need to assess if these categorical features have cardinality</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GqKGVKQCT6W7YloIuRvxZg.png" /><figcaption>Image by Author</figcaption></figure><p>Lets look at the distribution of cardinality across categorical features</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANnkuuHLtYrXDi52lpWOIw.png" /><figcaption>Image by Author</figcaption></figure><p>Since all of the features are anonymized and there no reliable path for us to make industry domain decisions based on Correlation plot — we will have to remove categorical features based on Chi-square (x²) contingency test and p_values.</p><p>Get p_values for all categorical features in dataset and remove features which have p_value &gt; 0.05:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xKUO26dJrcW0ic649HUhLA.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Target variable analysis</strong></p><p>Lets look at the density plot for target variable to assess how the data is distributed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*ETYJGZNJ-bfVgChfBpIgCQ.png" /><figcaption>Image by Author</figcaption></figure><p>We can clearly see that the target variable is left skewed. The best next approach to solve this problem is to take log of target variable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*V6vYRCahSLv_VT9VyKOblQ.png" /><figcaption>Image by Author</figcaption></figure><p>After taking the log of target variable we can see that the distribution appears to be normal.</p><h3>Encoding for categorical variables</h3><p>Since majority of the features for this dataset are categorical variables, its important we encode the features so that machine learning model can understand the signal.</p><p>Based on the chart in EDA, Top 20 High-Cardinality Categorical Features — we can clearly see that there are only two categorical features which have high cardinality.</p><p><strong>cat116</strong> : 326 unique labels</p><p><strong>cat113 </strong>: 61 unique labels</p><p>Rest of the categorical features have less than 20 unique values which do not account for high cardinality.</p><p><strong>One hot encoding</strong> for categorical features with unqiue values ≤ 20:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8oUQk5_gYgxw_Horztdyvw.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Target encoding</strong> for features with high cardinality (unique labels &gt; 50):</p><p>We need to make sure there is no data leakage, so we fit transform target encoding on train set and transform test data for high cardinality features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-K9bWa6T76CpA2K_tnrWg.png" /><figcaption>Image by Author</figcaption></figure><h3>Model Selection: Why LightGBM?</h3><p>I selected <strong>LightGBM</strong> because:</p><ul><li>Efficient training on large datasets</li><li>Strong performance in regression tasks</li><li>Built-in regularization and tree-based feature learning</li></ul><p>Tree-based boosting models typically outperform linear models in structured insurance datasets due to nonlinear feature interactions.</p><h3>Hyperparameter Optimization with Optuna</h3><p>Rather than manually tuning parameters, I used <strong>Optuna</strong> for Bayesian hyperparameter optimization. <strong>Bayesian optimization</strong> is an efficient, iterative strategy for hyperparameter tuning that models the objective function (rmse) as a probability model (surrogate model) to find optimal hyperparameters in fewer evaluations than grid or random search.</p><p>Parameters tuned included:</p><ul><li><strong>n_estimators: </strong>The number of boosting iterations (trees) built sequentially. More trees can improve performance but may increase training time and risk of overfitting if not properly regularized.</li><li><strong>learning_rate:</strong> Controls how much each new tree contributes to the overall model. Lower values make learning more gradual and stable, often requiring more trees but improving generalization.</li><li><strong>num_leaves:</strong> Maximum number of leaves per tree. Higher values increase model complexity and ability to capture nonlinear patterns but may lead to overfitting if too large.</li><li><strong>max_depth: </strong>Maximum depth of each tree. Limits how deep trees can grow, helping control model complexity and prevent overfitting.</li><li><strong>min_child_samples:</strong> Minimum number of data points required in a leaf node. Higher values make the model more conservative by preventing overly specific splits.</li><li><strong>subsample:</strong> Fraction of training data randomly sampled for each boosting iteration. Helps reduce overfitting and improves model robustness by introducing randomness.</li><li><strong>colsample_bytree:</strong> Fraction of features randomly selected for each tree. Reduces feature dominance and improves generalization by adding diversity among trees.</li><li><strong>reg_alpha / reg_lambda:</strong> L1 (reg_alpha) and L2 (reg_lambda) regularization terms applied to leaf weights. They penalize overly complex models and help prevent overfitti</li></ul><p>This ensured the model found an optimal bias–variance tradeoff. We also apply k-fold cross validation strategy to account for randomness in train, validation splits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTgzSkkn8ryQf6y03bKaqw.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kbhDzgpkK9wldWPyUF7hA.png" /><figcaption>Image by Author</figcaption></figure><h3>Model Performance metrics</h3><h4>Training Performance</h4><ul><li>RMSE: <strong>0.5062</strong></li><li>Adjusted R²: <strong>0.6114</strong></li></ul><h4>Test Performance</h4><ul><li>RMSE: <strong>0.5373</strong></li><li>Adjusted R²: <strong>0.5548</strong></li><li>MSE Gap (Test — Train): <strong>0.032</strong></li></ul><h4><strong>Model Plots:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r6qmDxDRvRhikVY-quZ5GA.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TN8Y2_f5xWpSuhQ4Y_ZiNg.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qjruIB1z3EGLGyLNoJItlw.png" /><figcaption>Image by Author</figcaption></figure><h3>The optimized LightGBM regression model demonstrates:</h3><ul><li>Stable generalization (low train–test MSE gap ≈ <strong>0.0324</strong>)</li><li>Test RMSE = <strong>0.537</strong></li><li>Adjusted R² = <strong>0.5548</strong></li><li>Error ≈ <strong>6.5%</strong> of total target range</li><li>Mean of residuals<strong> ~ 0.00041 </strong>(Indicating residuals are normally distributed)</li><li>The difference in (MAE-MDE) ~ <strong>0.077</strong> (Indicating stable model and less outliers)</li><li>Average predictions are off by less than <strong>7.0%</strong></li><li>No evidence of overfitting</li><li>Consistent performance across metrics (MAE, RMSE, R²)</li></ul><h3>Why R² Isn’t Extremely High (And Why That’s OK)</h3><p>The model explains <strong>~55%</strong> of variance in the target.</p><p>In insurance severity modeling, several factors contribute to natural variance:</p><ul><li>Latent risk factors not captured in features</li><li>Human-driven claim processes</li><li>Random external influences</li></ul><p>For structured real-world insurance data, an test adjusted R² above 0.5 with strong stability is considered solid performance.</p><h3>Final Thoughts: Beyond Model Metrics</h3><p>Building a predictive model for insurance claim severity is not just about optimizing RMSE or maximizing R²; it’s about delivering reliable, generalizable insights that can support real-world decision-making. In this project, the LightGBM model achieved strong generalization with a low train–test gap and a relatively small prediction error compared to the overall target range, indicating a well-balanced bias–variance tradeoff. More importantly, the results highlight a key principle in applied machine learning: once a model captures the available signal in structured data, further gains come from better features and domain understanding — not endless hyperparameter tuning. Insurance claim outcomes inherently contain noise and latent factors, so stability, interpretability, and practical usability matter more than chasing marginal metric improvements.</p><p>Ultimately, this project demonstrates how thoughtful modeling, careful evaluation, and business-context interpretation together create predictive systems that are both technically sound and strategically valuable.</p><p>That’s all, folks 🥕</p><p>Happy coding!</p><h4>Citations:</h4><ol><li><strong>“Allstate Claims Severity Dataset on OpenML”</strong>: The foundational dataset used in this project, originally released as a Kaggle competition to explore regression modeling techniques for <a href="https://www.openml.org/search?type=data&amp;status=active&amp;id=42571">predicting insurance claim loss.</a></li><li><strong>“LightGBM Documentation”</strong>: Official documentation detailing <a href="https://lightgbm.readthedocs.io/en/stable/Python-Intro.html">LightGBM’s</a> tree-based boosting framework, optimization techniques, and parameter tuning strategies used in this project.</li><li><strong>“Optuna Documentation — Hyperparameter Optimization Framework”</strong>: Comprehensive guide on Bayesian optimization with <a href="https://github.com/optuna/optuna-examples/blob/main/lightgbm/lightgbm_simple.py">Optuna</a>, used to systematically search for optimal hyperparameters in this regression task.</li><li><strong>“Scikit-learn Documentation — Regression Metrics”</strong>: Reference for <a href="https://scikit-learn.org/stable/api/sklearn.metrics.html">evaluation metrics</a> such as RMSE, MAE, and R² used to assess model performance.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a265acc04275" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI-Enhanced Trip Planner: A Personalized Road Trip Experience]]></title>
            <link>https://omkargawade.medium.com/ai-enhanced-trip-planner-a-personalized-road-trip-experience-ff19a8df2135?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff19a8df2135</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[roadtrip]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 22:12:41 GMT</pubDate>
            <atom:updated>2024-08-15T22:12:41.478Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*m5AGYOtgjZTDlZskXG8dYQ.png" /><figcaption>Image by <a href="https://unsplash.com/@karsten116">Karsten Winegeart</a> on Unsplash.com</figcaption></figure><p>Imagine planning a road trip that not only meets your travel preferences but also tailors the journey to your unique profile, from scenic routes to dining options. Enter the AI-Enhanced Trip Planner, a cutting-edge tool designed to create personalized travel itineraries based on user-specific inputs. In this article, we’ll explore how this tool works and how it can transform the way you plan your next adventure.</p><h3><strong>What is Powering the tool?</strong></h3><p>Architecture powering AI-Enhanced Trip Planner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMgr5yKO_MniM-htxUNVLQ.png" /><figcaption>Image by Author</figcaption></figure><p><strong>User info to be passed to tool API:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*NKlMIrrlkbOkYtamJsKWZA.png" /><figcaption>Image by Author</figcaption></figure><h3>The Power of Personalization</h3><p>One of the standout features of the AI-Enhanced Trip Planner is its ability to cater to the individual needs of each traveler. Let’s take a closer look at how the tool uses user data to craft a customized travel experience.</p><h3>User Profile: Who’s Traveling?</h3><p>Meet John, a 28-year-old from Portland who loves nature and is planning a road trip with his family. His user profile might look something like this:</p><ul><li><strong>Name:</strong> John Doe</li><li><strong>Age:</strong> 28</li><li><strong>Home Location:</strong> Portland, OR</li></ul><h3>Travel Profile: What’s the Vibe?</h3><p>John’s travel preferences are key to designing the perfect trip. The AI tool takes into account his love for nature, his preference for staying in motels, and his desire to find Indian cuisine along the way. Here’s a snapshot of his travel profile:</p><ul><li><strong>User Theme:</strong> Nature</li><li><strong>Preferred Accommodation:</strong> Motel</li><li><strong>Dining Preference:</strong> Non vegetarian</li><li><strong>Group Composition:</strong> Family</li><li><strong>Travel Style:</strong> Nature-based road trip</li></ul><h3>Location Details: Where and When?</h3><p>Finally, the tool considers the specifics of John’s trip, including the start and end dates, the type of vehicle he’s driving, and the scenic routes he’s interested in exploring:</p><ul><li><strong>Destination Location:</strong> Los Angeles, CA</li><li><strong>Start Date:</strong> 08/08/2024</li><li><strong>End Date:</strong> 08/15/2024</li><li><strong>Stops of Interest:</strong> Scenic routes</li><li><strong>Vehicle Type:</strong> Sports sedan</li></ul><h3>The AI-Generated Travel Summary</h3><p>Based on John’s inputs, the AI-Enhanced Trip Planner generates a comprehensive travel summary that offers various route options, key attractions, and even real-time weather information. Let’s explore what John’s personalized trip looks like.</p><h3><strong>Trip Summary:</strong></h3><p>Starting in Portland, Oregon, and ending in Los Angeles, California, this trip covers a distance of 960 to 1,370 miles, depending on the route you choose. The estimated driving time ranges from 15 to 28 hours. The tool provides you google map links of each route option.</p><h3>Key Stops and Attractions:</h3><ul><li>If you take the <strong>Coastal Route via the Pacific Coast Highway</strong>, you’ll pass by famous bays and beaches in Oregon and California, enjoying the iconic ocean views and charming coastal towns along the cliffs.</li><li>If you prefer the <strong>Mountain/Desert Route</strong>, you’ll encounter the stunning landscapes of Death Valley and the scenic views in Nevada.</li></ul><h3>Route Options:</h3><p><strong>1.Direct Route</strong>: This is the quickest option, covering 960 to 1,150 miles in 15 to 19 hours. You can view the route on <a href="https://www.google.com/maps/dir/Portland,+OR/Los+Angeles,+CA">Google Maps</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wSf0j7w8LwPoJvY_39bPKQ.png" /><figcaption>Image by Author</figcaption></figure><p><strong>2. Scenic Coastal Route</strong>: This option takes you 1,370 miles along the coast, requiring at least three days to drive with an estimated travel time of 28 hours. Enjoy stops at coastal bays and beaches. See the route on <a href="https://www.google.com/maps/dir/Portland,+OR/Newport,+OR/Coos+Bay,+OR/Eureka,+CA/San+Francisco,+CA/Los+Angeles,+CA">Google Maps</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsxGzbTQmGZRlyQem2Kz1Q.png" /><figcaption>Image by Author</figcaption></figure><p><strong>3. Mountain/Desert Route</strong>: Covering 1,150 miles, this route will take you through Death Valley, with an estimated travel time of 19 hours. Explore the route on <a href="https://www.google.com/maps/dir/Portland,+OR/Death+Valley,+CA/Los+Angeles,+CA">Google Maps</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bqqhe48WwWk9VLkLbyIM4g.png" /></figure><h3>Weather Information:</h3><ul><li><strong>Portland, OR</strong>: Currently, the weather includes broken clouds, a wind speed of 3.6 m/s from the northeast, 53% humidity, and a temperature of around 25°C.</li><li><strong>Los Angeles, CA</strong>: The weather is clear with a wind speed of 5.14 m/s from the south, 56% humidity, and a temperature of approximately 30°C.</li></ul><h3>Travel Tips:</h3><ul><li>Start your drive early in the morning to avoid traffic.</li><li>The coastal route is known for its great food scenes, especially in the beach towns.</li><li>Don’t miss out on exploring landmarks like Bixby Bridge or enjoying family-friendly activities like a visit to Disneyland Resort in Anaheim.</li></ul><h3>Overall Experience:</h3><p>This road trip offers the perfect blend of direct routes for quick travel and scenic routes for a more leisurely, memorable journey. Whether you choose the coastal adventure along the Pacific Coast Highway or the unique desert experience through Death Valley, the drive from Portland to Los Angeles is sure to be a beautiful and diverse experience.</p><h3>The Future of Travel Planning</h3><p>The AI-Enhanced Trip Planner represents the future of travel planning, combining the power of artificial intelligence with the personal touch of a human travel agent. By understanding your preferences, this tool ensures that every road trip is tailored to your needs, offering an experience that’s not just convenient, but also memorable.</p><p>Whether you’re a nature enthusiast like John or someone with a completely different travel style, this AI-driven tool can help you design the perfect road trip and provide google links for every route option provided. With features like route customization, real-time updates, and personalized recommendations, the possibilities are endless.</p><h3><strong>Next Steps:</strong></h3><ol><li><strong>Enhance Trip Summary:</strong> Refine the trip itinerary to include more detailed stops, such as restaurants, dining spots, and accommodations, directly within the generated Google Maps route.</li><li><strong>Budget Recommendations:</strong> Implement a feature that suggests a budget range based on user preferences.</li><li><strong>Dining Reviews and Ratings:</strong> Integrate restaurant reviews and overall ratings to assist users in making informed dining choices.</li><li><strong>Dynamic Route Management:</strong> Develop the tool to allow users to dynamically add or remove stops, automatically updating the map route.</li><li><strong>Real-Time Weather Updates:</strong> Integrate a weather API to provide dynamic updates on the current weather at both the user’s location and the destination.</li></ol><p>Follow my medium blog and add me on <a href="https://www.linkedin.com/in/omkar-gawade/">linked in</a> — would love to connect with ya’ll.</p><p>That’s all, folks 🥕</p><p>Happy coding!</p><p><strong>Citations:</strong></p><ul><li><strong>“Integrating DuckDuckGo with LangChain: A Tool for Efficient Web Searches”</strong>: Introduces how to integrate <a href="https://python.langchain.com/v0.2/docs/integrations/tools/ddg/">DuckDuckGo</a> with LangChain, showcasing its utility for efficient web searches.</li><li><strong>“Weather Data Integration in LangChain: Utilizing OpenWeatherMap”</strong>: Explains the process of integrating <a href="https://python.langchain.com/v0.2/docs/integrations/tools/openweathermap/">OpenWeatherMap</a> with LangChain for weather data retrieval.</li><li><strong>“Leveraging Agents in LangChain: A Modular Approach”</strong>: Provides insights into the use of <a href="https://python.langchain.com/v0.1/docs/modules/agents/">agents within LangChain</a>, highlighting its modular capabilities.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff19a8df2135" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Future of Interaction: Design Your AI Chatbot with LangChain]]></title>
            <link>https://omkargawade.medium.com/the-future-of-interaction-design-your-ai-chatbot-with-langchain-79df0669ba7f?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/79df0669ba7f</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[langchain]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Mon, 15 Apr 2024 22:09:26 GMT</pubDate>
            <atom:updated>2024-04-15T22:09:26.141Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IqytjX72CmAx9WOx4Rm3gg.jpeg" /><figcaption>Image from Unspash.com by <a href="https://unsplash.com/@lunarts">Volodymyr Hryshchenko</a>.</figcaption></figure><p>As a first generation immigrant myself who came here on F-1 visa for my masters, I can empathize the pain international students go through while applying for jobs — couple of common questions all of us have are “ Will they sponsor h1b visa ?” “ what would be approximate salary for the role”?</p><p>Drawing from my own journey of job seeking, coupled with a deep-rooted passion for data science, I was inspired to initiate this project: the development of a LangChain chatbot designed to interact seamlessly with H1B and LCA datasets from USCIS.</p><p>Here is short demo of how the h1b bot works:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYy9RjnIcU2I%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYy9RjnIcU2I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYy9RjnIcU2I%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e67a047aded655e318ef50846d8535af/href">https://medium.com/media/e67a047aded655e318ef50846d8535af/href</a></iframe><p>Now that you’ve seen what the H1B bot does, lets go about how you can build your own AI bot with any data you desire in <strong>python</strong>:</p><p><strong>Database: </strong>The database used in this project is sqlite database.</p><ol><li>H1B data : Downloaded from <a href="https://www.uscis.gov/tools/reports-and-studies/h-1b-employer-data-hub/h-1b-employer-data-hub-files">USCIS website</a> for h1b petitions. The descriptions of columns used in the data are here in the <a href="https://www.uscis.gov/tools/reports-and-studies/h-1b-employer-data-hub/understanding-our-h-1b-employer-data-hub">link.</a></li><li>LCA data: All LCA data for this project was downloaded from <a href="https://www.dol.gov/agencies/eta/foreign-labor/performance">USCIS PERFORMANCE DATA</a> — (<em>fyi LCA data is not consistent with column naming over years.)</em></li></ol><p>Both these databases were written into a sqlite database as two separate tables. Below is the code to convert <em>csv</em> files into <em>sqlite .db file</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ifY8ZSosTvn-5QrfNzQbQ.png" /><figcaption>Image by Author</figcaption></figure><p>This how two tables we uploaded look inside sqlite db:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*aZEeQWddRyP9YKynHV-o_w.png" /><figcaption>Image by Author</figcaption></figure><p>Note: You can query other databases such <a href="https://stackoverflow.com/questions/77167937/langchain-querying-from-postgresql-database-using-sqldatabasechain">Postgres SQ</a>L, M<a href="https://github.com/langchain-ai/langchain/issues/17628">ysql</a>, S<a href="https://github.com/langchain-ai/langchain/issues/9804">ql-server</a>, <a href="https://python.langchain.com/docs/integrations/document_loaders/snowflake/">Snowflake</a>.</p><p><strong>LangChain agent: </strong>Let’s create a custom LangChain agent with a custom prompt!</p><p>Libraries to install &amp; import for LangChain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*rOztW3eC4bPuib_5Eu2kZQ.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sDsyhFlGqd_1LOxXMAkiHg.png" /><figcaption>Image by Author</figcaption></figure><p>After importing all these libraries we are going to create a custom prompt and store it in a local variable.</p><p>Below is an prompt example from <a href="https://python.langchain.com/docs/use_cases/sql/agents/">LangChain documentation</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_YxorJ6LMnyjrURGJd62bg.png" /><figcaption>Image by Author</figcaption></figure><p>We will use LangChain’s <strong>ChatPromptTemplate</strong> to create a dynamic dialogue framework that includes the system&#39;s messages, optional chat history for context, the user&#39;s input, and an internal scratchpad for the agent&#39;s use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZllBxO3Dh65Quj2KpoeowA.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Define the LLM instance:</strong></p><p>For my use case I have used <a href="https://python.langchain.com/docs/integrations/chat/openai/">Open-AI’s</a> Chat GPT 3.5 ; but LangChain does support multitude of language models, you can find documentation <a href="https://python.langchain.com/docs/integrations/chat/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oS0nyCdAN_tMQJb9g-dsUg.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Create custom LangChain agent:</strong></p><p>agent_type =”openai-tools” indicates that we are using custom prompt to create llm agent, <a href="https://github.com/langchain-ai/langchain/blob/15271ac83270ea2b9aa00232344ba22f7ed9bd64/libs/community/langchain_community/agent_toolkits/sql/base.py">here</a> is the documentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4FlQLHPwKxXLp0upc7lN_w.png" /><figcaption>Image by Author</figcaption></figure><p>This below is how LangChain architecture works:</p><p>Question from user in natural language → llm to create sql query in db dialect → run that query generated on sqlite db → get the response and pass it to user as Answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*meX5_bIJ7OG2sN3Q0fvCGA.png" /><figcaption>Image from<a href="https://python.langchain.com/docs/use_cases/sql/quickstart/"> Langchain documentation</a></figcaption></figure><p>Now that we have created our very own custom LangChain agent — let’s invoke the instance to get a response!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpdX29FnhrSyYKapMYhyyQ.png" /><figcaption>Image by Author</figcaption></figure><p>And just like that in a couple of lines of code you have your own chat bot!</p><p>To make this project end-to-end solution, it was essential to make the Python script accessible through an API endpoint. For this purpose, the Flask framework was utilized to encapsulate the script within a Flask API.</p><p>Here is tutorial on youtube about how to create a simple api and host it on <a href="https://www.youtube.com/watch?v=z6q9kug0PL0&amp;t=573s">python anywhere</a></p><p>The frontend for this project was hosted on google app script!</p><p><strong>Frontend Architecture:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AcJFE3ZC_Ir8uCtJabvOZA.png" /><figcaption>Image by Author</figcaption></figure><p>Below are couple of examples of my h1b chat bot responses and sample questions in website I built on Google app script:</p><p>Example 1: <em>What is the average decision approval time for Amazon? provide me the underlying sql query</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VyIRbwjDUGIITq9eaHAdJQ.png" /><figcaption>Image by Author</figcaption></figure><p>Example 2: <em>Provide me the best job title to have to improve my chances of getting h1b?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lv94_nKqcC2ufLBJx7YEuQ.png" /><figcaption>Image by Author</figcaption></figure><p>Example 3:<em> Provide me the top 3 companies based on their highest approval rate and top 3 companies based on their lowest approval rate? provide me the underlying sql query (Response too long to fit in a screenshot)</em></p><pre>The top 3 companies based on their highest approval rate are:<br>1. QUALCOMM TECHNOLOGIES INC with an approval rate of 100% (429 approvals, 0 denials)<br>2. ORACLE USA INC with an approval rate of 100% (420 approvals, 0 denials)<br>3. UNIVERSITY OF CA SAN FRANCISCO with an approval rate of 100% (345 approvals, 0 denials)<br><br><br>The top 3 companies based on their lowest approval rate are:<br>1. COVEY INFOTECH LLC with an approval rate of 0% (0 approvals, 39 denials)<br>2. SRIT INC with an approval rate of 0% (0 approvals, 38 denials)<br>3. BPM LABS INC with an approval rate of 0% (0 approvals, 31 denials)<br><br>The underlying SQL query used to find the top 3 companies with the highest approval rate is:<br>```sql<br>SELECT <br>Employer, <br>SUM(Initial_Approvals) + SUM(Continuing_Approvals) AS Total_Approvals,<br>SUM(Initial_Denials) + SUM(Continuing_Denials) AS Total_Denials,<br>(SUM(Initial_Approvals) + SUM(Continuing_Approvals)) * 1.0 / (SUM(Initial_Approvals) + SUM(Continuing_Approvals) + SUM(Initial_Denials) + SUM(Continuing_Denials)) AS Approval_Rate<br>FROM h1b_data GROUP BY Employer HAVING Total_Approvals + Total_Denials &gt; 0 ORDER BY Approval_Rate DESC, Total_Approvals DESC LIMIT 3<br>``` <br>And the query used to find the top 3 companies with the lowest approval rate is:<br>```sql<br>SELECT Employer,<br>SUM(Initial_Approvals) + SUM(Continuing_Approvals) AS Total_Approvals, <br>SUM(Initial_Denials) + SUM(Continuing_Denials) AS Total_Denials,<br>(SUM(Initial_Approvals) + SUM(Continuing_Approvals)) * 1.0 / (SUM(Initial_Approvals) + SUM(Continuing_Approvals) + SUM(Initial_Denials) + SUM(Continuing_Denials)) AS Approval_Rate<br>FROM h1b_data <br>GROUP BY Employer <br>HAVING Total_Approvals + Total_Denials &gt; 0 <br>ORDER BY Approval_Rate ASC, Total_Denials <br>DESC LIMIT 3<br>```</pre><p>Example 4: <em>lets be creative! How can one lead a happy life? (Response too long to fit in a screenshot)</em></p><pre>Leading a happy life is a quest that many embark on, and while I&#39;m just a virtual assistant without personal experiences, I can offer some universally acknowledged tips:<br><br>1. **Find Purpose**: Engage in activities that give you a sense of meaning and purpose.<br>2. **Build Relationships**: Cultivate strong connections with family and friends.<br>3. **Stay Active**: Regular physical activity can boost your mood and reduce stress.<br>4. **Practice Gratitude**: Focus on what you have, rather than what you lack.<br>5. **Learn and Grow**: Keep your mind active with continuous learning and new experiences.<br>6. **Help Others**: Altruism and volunteer work can increase your own happiness.<br>7. **Manage Stress**: Develop healthy coping mechanisms for life&#39;s inevitable stresses.<br>8. **Live in the Moment**: Practice mindfulness and savor the present.<br>9. **Balance**: Strive for a good balance between work, rest, and play.<br>10. **Laugh Often**: Don&#39;t take life too seriously; find humor in everyday situations.<br><br>Remember, happiness is not a destination, but a way of traveling through life.<br>Now, if you have any questions related to H-1B or LCA data, I&#39;m your go-to assistant for that!</pre><p><strong>Idea Validation:</strong></p><p>April 11, 2024 — Snowflake announces <a href="https://docs.snowflake.com/en/user-guide/snowflake-copilot">Snowflake co-pilot</a>, a similar feature for natural language to SQL script which will be coming out in two weeks for below regions:</p><ul><li>AWS us-east-1</li><li>AWS us-west-2</li></ul><p>which will available for no charge until may 31st 2024 — Snowflake will probably release a pricing model soon.</p><p><em>“Craft it yourself — free of charge, or pay the price!”</em></p><p>This proves validation that this idea has real world application!</p><p>That’s all, folks 🥕</p><p>Happy coding!</p><p>Citations:</p><ol><li>“LangChain Documentation: Your Comprehensive Guide”: Perfect for introducing readers to the foundational resource for LangChain, emphasizing its role as a <a href="https://python.langchain.com/docs/get_started/introduction">comprehensive guide</a>.</li><li>“Synthesizing Data with LangChain: A Step-by-Step Tutorial”: Highlights the practical tutorial aspect of using LangChain for synthetic data generation and <a href="https://blog.langchain.dev/how-to-safely-query-enterprise-data-with-langchain-agents-sql-openai-gretel/">querying</a>.</li><li>“LangChain GitHub Repository: Dive into the Code”: Encourages readers interested in the technical details or contributing to the project to explore the LangChain <a href="https://python.langchain.com/docs/get_started/introduction">GitHub repository</a>.</li><li>“”Exploring LangChain’s Capabilities: A Deep Dive into Our Latest Blog Post””: Offers readers insights into common issues users are facing with LangChain, suggesting the post provides valuable techniques and <a href="https://blog.langchain.dev/">examples</a>.</li><li>“Launch Your First Python Web App with Flask: A Beginner’s Guide”:This comprehensive tutorial on Medium by <a href="https://medium.com/@bhavaniravi">Bhavani Ravi</a> serves as an ideal starting point for beginners aiming to develop their first web application using Flask, a popular <a href="https://medium.com/bhavaniravi/build-your-1st-python-web-app-with-flask-b039d11f101c">Python web framework</a>.</li><li>“Hosting Your Flask App for Free on PythonAnywhere: A Step-by-Step Guide” This insightful article on Medium’s The Startup explains how to host a Flask application on PythonAnywhere at no cost. Ideal for developers looking to deploy their Flask projects online without incurring hosting fees, the guide walks readers through the entire process, from setting up a PythonAnywhere account to configuring and deploying a <a href="https://medium.com/swlh/how-to-host-your-flask-app-on-pythonanywhere-for-free-df8486eb6a42">Flask application</a>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79df0669ba7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GPT-3: The All-in-One Solution for Automated Emails, Sentiment Analysis and Topic Detection]]></title>
            <link>https://omkargawade.medium.com/gpt-3-the-all-in-one-solution-for-automated-emails-sentiment-analysis-and-topic-detection-4c79eacb747f?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c79eacb747f</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[gpt-3]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Sat, 21 Jan 2023 23:41:18 GMT</pubDate>
            <atom:updated>2023-01-21T23:41:18.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pd6p_4O7d5WHE74JYmG5lQ.jpeg" /><figcaption>Image by <a href="https://unsplash.com/@jdiegoph">Diego PH</a> on<a href="https://unsplash.com/"> Unsplash.com</a></figcaption></figure><p>Generating automated emails with GPT-3 can be a powerful tool for businesses and organizations looking to improve their communication with customers and clients. One of the key advantages of using GPT-3 is its ability to understand the context and intent of a given message, which allows it to generate highly personalized and accurate responses.</p><p>GPT-3 is trained on a massive dataset of text, which includes a diverse range of sources such as books, articles, websites, and more. The training dataset for GPT-3 is estimated to be on the order of billions of words, which allows the model to learn a wide variety of language patterns and styles.</p><p>The training dataset for GPT-3 is preprocessed to clean and preprocess the text, such as lowercasing, tokenization, and stemming. The cleaned text used to train the model, which is based on a transformer architecture. The transformer architecture allows the model to learn the underlying patterns and relationships between words in the text, which enables it to generate highly coherent and natural-sounding text.</p><p>Since GPT-3 has been already trained on about 45 TB text data and has 175 trainable parameters, even without fine tuning it can be used to effectively generate automated responses to incoming emails based on the context and intent of the message. For example, if a customer sends an email asking for help with a product, the model can generate a personalized response that provides the necessary information and assistance. Similarly, if a sales prospect sends an email expressing interest in a product or service, the model can generate a tailored sales pitch that addresses their specific needs and concerns.</p><p>Lets look at the code in python to connect to GPT-3 api and generate email responses:</p><p><strong>Step 1: </strong>Import required libraries and import generic csv email file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dDH6NSkoJXZMWSbEwtU2SQ.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Step 2: </strong>Define a function in python which calls GPT-3 public api — In order to do this you will need to create a personal account on open AI with your personal email; Open AI provides an $18 credit for you to explore and experiment with various models. After the account is created click on your account on the top right corner and go to view API keys ; once you are in the API keys page you can create a new API secret key — be sure to copy this key in secret variable in python.</p><p>Define a function with api key, mention a prompt to GPT-3 text model <strong>“text-davinci-003”</strong>— in our case we will use text string joining with prompt “Reply to this below email”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uB9HWTGeWr5azRpEb0j5ig.png" /><figcaption>Image by Author</figcaption></figure><p>Once the function is defined — we can use pandas with apply functionality to apply the function defined above to generate responses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QJ2t_bia4LYbtfGREyGitA.png" /><figcaption>Image by Author</figcaption></figure><p>You can see in the above example how effective GPT-3 is to generate human like responses to the email.</p><p>Similarly you can change the prompt in define function provided to GPT-3 to provide sentiment &amp; detect email type of the email received:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUk-ZoT5F-l-V9v4vuInZQ.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Psxr4NQKGhFZfhlRrluP2Q.png" /><figcaption>Image by Author</figcaption></figure><p>Create two columns Sentiment_email &amp; Email_type by using apply functionality in pandas to apply above two defined functions.</p><p>Let’s checkout the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NmelFOPy170VARLw4teodw.png" /><figcaption>Image by Author</figcaption></figure><p>The possibilities are endless with GPT-3- you can generate essay’s , have it write resume or songs or whatever floats your boat!</p><p>Let’s get coding ya’ll!</p><p>Follow my medium blog and add me on linked in — would love to connect with ya’ll.</p><p>Linked in: <a href="https://www.linkedin.com/in/omkar-gawade/">Omkar-gawade</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c79eacb747f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate hyperparameter tuning in amazon sagemaker notebooks]]></title>
            <link>https://omkargawade.medium.com/automate-hyperparameter-tuning-in-amazon-sagemaker-notebooks-cdd45f158225?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdd45f158225</guid>
            <category><![CDATA[bayesian]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[hyperparameter-tuning]]></category>
            <category><![CDATA[xgboost]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Mon, 26 Dec 2022 18:13:42 GMT</pubDate>
            <atom:updated>2022-12-26T18:13:42.080Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_gUeIkvJb00vlkMJzZmpw.jpeg" /><figcaption>Image by Alex Baydoun on <a href="https://unsplash.com/">Unsplash.com</a></figcaption></figure><p>Although machine learning may seem a tempting option to have informed decisions or automate a manual process — it is not something which needs no supervision. Machine learning algorithms need to be recalibrated from time to time when model metrics fall down below a threshold — that may be because of deterioration of data quality, data spread or drastic change in training datasets. One of the most popular methods of making sure model is performing well within our threshold model metrics is executing hyperparameter tuning from time to time. Similar analogy for hyperparameter tuning would be tuning an instrument — when you tune a guitar doesn’t mean that its gonna be in tune in a month, it has to be re-tuned to make sure it sounds great!</p><p><strong>Types of Hyperparameter tuning:</strong></p><ol><li><strong>GridSearchCV</strong> : Tests all possible hyperparameter’s specified and gives the best performing model out of it.</li><li><strong>RandomizedSearchCV</strong>: Randomly selects hyperparameter’s specified and gives the best performing model out of it.</li><li><strong>Bayesian Optimization:</strong> In this method we learn from our previous hyperparameter combination runs to move the model towards more performance ( ex. minimizing ‘rmse’ in Regression problem or increasing ‘auc’ in binary classification problem)</li></ol><p>In this article, we will explore on how to automate <strong>bayesian tuning</strong> job via amazon notebooks:</p><p>To run hyperparameter tuning in notebook we need train.csv, validation.csv and output file path in your s3 bucket. We will be using XGBoost algorithm image for out hyperparameter tuning so we need to make sure the files are in accordance to <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/xgboost.html">AWS instructions</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFFzUf8SKUnspXgoziKpcA.png" /><figcaption>Image by Author</figcaption></figure><p>Below is how we specify path for our training, validation and output location to save model artifacts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gO1wlNo7Y3ANQuM3MlhVUw.png" /><figcaption>Image by Author</figcaption></figure><p><strong>We will consider select hyperparameter’s to tune:</strong></p><ol><li><strong>ETA:</strong> learning rate for xgboost classifier</li><li><strong>alpha:</strong> L1 regularization term on weights</li><li><strong>gamma:</strong> Minimum loss reduction required to make a further partition on a leaf node of the tree.</li><li><strong>lambda:</strong> L2 regularization term on weights.</li><li><strong>colsample_bylevel:</strong> subsample ratio of columns for each level.</li><li><strong>colsample_bytree:</strong> subsample ratio of columns when constructing each tree</li><li><strong>max_depth:</strong> Maximum depth of a tree. Increasing this value will make the model more complex and more likely to overfit.</li><li><strong>num_round: </strong>The number of rounds to run the training.</li></ol><p>Please follow <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/xgboost_hyperparameters.html">Xgboost documentation</a> in aws to select &amp; understand all hyperparameter’s.</p><p>Below is how you set up tuning_job_config:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nczzUS3Jl0BCbmL2WghmWw.png" /><figcaption>Image by Author</figcaption></figure><p>In the above image we can see that we selected <strong>“Bayesian”</strong> for tuning strategy and <strong>“validation:auc”</strong> as metric to focus on — since we want to maximize <strong>auc, </strong>we specify <strong>“Maximize” </strong>in type.</p><p>We also have to specify number of jobs we need to initiate and how many jobs will run in parallel.</p><p><strong>“MaxNumberOfTrainingJobs”:</strong> 20 <br><strong> “MaxParallelTrainingJobs”</strong>: 4</p><p><strong>Get model image from amazon:</strong> provide train_path, validation_path, instance_type, objective and maxruntimeinseconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rc3JCgN4jO0Xjlf99QazfA.png" /><figcaption>Image by Author</figcaption></figure><p>After specifying all details in training image we can go ahead and start hyperparameter job:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tVUPy8xCMXzn6k4aIUTapw.png" /><figcaption>Image by Author</figcaption></figure><p>Once we run the above code &amp; hyperparameter job starts, we track the progress in Amazon console&gt;Training&gt;Hyperparameter tuning jobs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*RPRTjZGOYFoUoTkNtEtyVw.png" /><figcaption>Image by Author</figcaption></figure><p>Once hyperparameter tuning job completes — we can check the hyperparameter’s for maximum auc:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H1izqeXfYsccKMhkbzhgJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxU5ZAtSDTM9P08-dgHx-w.png" /><figcaption>Image by Author</figcaption></figure><p>The script we have written above can be automated to run at any frequency (monthly, bi-monthly, weekly) using lambda functions.</p><p>Let’s get coding ya’ll !</p><p>Follow my medium blog and add me on linked in — would love to connect with ya’ll.</p><p>Linked in: <a href="https://www.linkedin.com/in/omkar-gawade/">Omkar-gawade</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd45f158225" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating Synthetic Data using deep learning model.]]></title>
            <link>https://omkargawade.medium.com/generating-synthetic-data-using-deep-learning-model-5066aed80e30?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5066aed80e30</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[synthetic-data]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[synthetic-data-vault]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 16:01:00 GMT</pubDate>
            <atom:updated>2022-12-13T16:01:00.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dXvGdDpwmNfnw5iXs0DXA.png" /><figcaption>Image by Mahdis mousavi on <a href="https://unsplash.com/">Unplash.com</a></figcaption></figure><p>There’s no denying that biggest resource in the 21st century is data — Data is often referred as the 4th industrial generation; companies who have adopted this model of collecting data and using it to make informed decisions are the ones who are thriving. But collecting data and generating experiments is not elementary as it sounds — most mid level companies do not have the infrastructure or the resources to store scalable data. In most scenario&#39;s when you have to test a machine learning / AI model with no scalable data we have to generate synthetic data using machine learning. In some used cases synthetic data is generated because the company wants to keep its data confidential.</p><h4>Synthetic Data generation using Synthetic Data Vault (SDV):</h4><p>Synthetic Data Vault (SDV) is a synthetic data generation ecosystem that allows a user to easily create synthetic data by learning from single table, multi-table , text and time series datasets. SDV uses probabilistic graphical models &amp; deep learning techniques to generate synthetic data. You can read more about the library <a href="https://sdv.dev/SDV/">here</a>.</p><p>In our scenario we will be using Gaussian Coupla to generate synthetic data — Gaussian Coupla is methodology in which we generate multivariate random variables by using covariance matrix.</p><p><strong>Below is the code to use install and import Gaussian Coupla instance:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07I1pS_MtL-DiErq92ePfA.png" /><figcaption>Image by author</figcaption></figure><p>To fit the instance in Gaussian Coupla lets import a generic dataset into notebook — lets download <a href="https://www.kaggle.com/datasets/ifteshanajnin/carinsuranceclaimprediction-classification">insurance claim</a> dataset from kaggle. This dataset has categorical, continuous and free text data so that we can see effectiveness/range of SDV library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FgjXbdFacsHqnNDdjjFnOg.png" /><figcaption>Image by author</figcaption></figure><p>We can see that from above image that this insurance claim data as object, int64 and float64 data types.</p><p>Fitting the dataset in Gaussian Coupla instance and generate 100k samples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bJz00rt_m1FWfoBw-_Fnw.png" /><figcaption>Image by author</figcaption></figure><p>Lets check the data type for synthetic variables generated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w7LWyhLgCqzHx5jAbkrzZA.png" /><figcaption>Image by author</figcaption></figure><p>Just eyeballing the data types between original and synthetic data generated; they exactly match — which shows how effective SDV works.</p><p>Let’s take a step further and use <a href="https://pypi.org/project/table-evaluator/">table_evaluator</a> library to compare the real and synthetic datasets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l0hh1urixMATEpyYkne2Fw.png" /><figcaption>Image by author</figcaption></figure><p><strong>Log Mean &amp; Standard deviation comparison between real and fake data</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzZfBaUoCLI_NmUjHyIl5w.png" /><figcaption>Image by author</figcaption></figure><p><strong>Visuals for variable comparison between real and fake data:</strong></p><p>I have included visuals for some select variables — the full report generated for 44 variables would be quite extensive to include here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERrjfV8YsU4KBIr-dj_scA.png" /><figcaption>Image by author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5g-EjMRxKQwJTbWEA06Bnw.png" /><figcaption>Image by author</figcaption></figure><p>From the above charts we can see exactly how powerful SDV is it generates categorical &amp; normalized continuous variables.</p><p>Let’s get coding ya’ll — generate synthetic data and use it train ML models and more!</p><p>Follow my medium blog and add me on linked in — would love to connect with ya’ll.</p><p>Linked in: <a href="https://www.linkedin.com/in/omkar-gawade/">Omkar-gawade</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5066aed80e30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Credit Card Defaulter Prediction model with model Explainability using Shap values.]]></title>
            <link>https://omkargawade.medium.com/how-to-make-credit-card-defaulter-prediction-model-with-model-explainability-using-shap-values-a4ae4cbba077?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4ae4cbba077</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[imbalanced-data]]></category>
            <category><![CDATA[model-explainability]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[smote]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 14:27:30 GMT</pubDate>
            <atom:updated>2022-09-29T12:28:31.330Z</atom:updated>
            <content:encoded><![CDATA[<h3>Credit Card Fraud Prediction model, SMOTE &amp; model Explainability using Shap values.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*NyVs0jpNMEY_eW0aHyGS6g.png" /><figcaption>Image by <a href="https://unsplash.com/@nate_dumlao">Nathan Dumlao</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>Credit card fraud detection is a common problem in machine learning — the only downside being the amount of people who are defaulters are significantly lower to honest working people — this creates a class imbalance which produces poor models. In this analysis we will go through step by step about how to solve class imbalance using SMOTE, hyperparameter tuning and model explainability with Shaply values.</p><h4>Dataset:</h4><p>The dataset for the analysis was exported from <a href="https://www.kaggle.com/datasets/mlg-ulb/creditcardfraud">Kaggle</a>. The data contains credit card data with variables which are encoded after conducting PCA analysis along with Amount &amp; time. The dataset is already cleaned with no nulls and no major correlation with each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AXnJKc26kyOvGIb1dHnNbQ.png" /><figcaption>Image by author</figcaption></figure><h4><strong>Class imbalance:</strong></h4><p>Check for class imbalance of the target variable ‘class’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yi3aPDRaPnz0-oaLKrueUg.png" /><figcaption>Image by author</figcaption></figure><p>Here we can see that class 1 (Defaulters) is ~ 0.17 % of the total data — which would seriously mess up model metrics like Accuracy — it is not a good measure for imbalanced datasets.</p><p>Imagine there are 100 datapoints — 99 with “class 0” and 1 with “class 1” — even though in this case the accuracy might be 99% it is misleading because the model will always predict “class 0” because it has been trained to do so.</p><h4><strong>Create train and test datasets:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SPitBNzRMThZWQqBh_3S4A.png" /><figcaption>Image by author</figcaption></figure><h4><strong>Synthetic minority over-sampling (SMOTE):</strong></h4><p>There are various methods that can be used to solve class imbalance like Oversampling, Under-sampling or Random oversampling / Random under sampling — SMOTE is by far one of the most effective methods to solve this problem.</p><p>SMOTE solves the class imbalance problem by creating synthetic samples — these synthetic samples are not duplicates like oversampling, but in reality closest neighbors to the original minority class datapoints.</p><p>We will be using imblearn library to perform SMOTE on the data — below is the code you’ll need to refit x_train and y_train to overcome class imbalance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhkjAfurjueAZVrR_7EhIQ.png" /><figcaption>Image by author</figcaption></figure><h4>Fitting XG boost Classifier on the refit smote datasets using Randomized CV hyperparameter training</h4><p>We will pip install xgboost library and import XGBClassifieR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Djr_Bp_UendWMj-smMqaVw.png" /><figcaption>Image by author</figcaption></figure><p><strong>Hyperparameter Training: </strong>This is a step where we fine tune the model to get better performance; There several methods for hyperparameter tuning such as:</p><ol><li><strong>GridSearchCV :</strong> Tests all possible hyperparameter’s specified and gives the best performing model out of it.</li><li><strong>RandomizedSearchCV</strong>: Randomly selects hyperparameter’s specified and gives the best performing model out of it.</li><li><strong>Bayesian Optimization:</strong> In this method we learn from our previous hyperparameter combination runs to move the model towards more performance ( ex. minimizing ‘rmse’ in Regression problem or increasing ‘auc’ in binary classification problem)</li></ol><p>In our case we will be utilizing RandomizedSearchCV for our hyperparameter tuning. Below are the lists of hyperparameter’s I specified with the code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ER6L_Vx3FgdmVGf0m29EMA.png" /><figcaption>Image by author</figcaption></figure><p><strong>After all permutations are finished we can grab the hyperparameter’s for the best estimator</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQDfAnBYKDu8X4Mp-T1mBw.png" /><figcaption>Image by author</figcaption></figure><p><strong>Fitting the XGboost Classifier with best estimator</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrY_S9gbIeF_PvQaWXjf0A.png" /><figcaption>Image by author</figcaption></figure><p><strong>Getting classification metrics for model</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7oWH-2wGDkRwrmyko9-PPg.png" /><figcaption>Image by author</figcaption></figure><h4>Shap Analyis for Model Explainability:</h4><p>Shaply values employ the methodology of game theory where it tries to keep all variables constant and vary one variable randomly to see the impact of the feature on the prediction. In a nutshell shaply values quantifies the contribution each feature has on the prediction.</p><p>Below is the code you would need to get shaply values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otP1a31mPJbiPUfqX2OObQ.png" /><figcaption>Image by author</figcaption></figure><p><strong>Summary plot for shap values:</strong></p><p>Summary plot gives an overall outlook on which feature has the most impact on the prediction in a descending order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*GPOI46yMcDf7cvMuCZXW0g.png" /><figcaption>Image by author</figcaption></figure><p>We can also get a visualization on every single row which shows what impact has every feature has on the prediction to be 1 or 0</p><p><strong>For example lets pick a random row and get the shap waterfall graph for it:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPsdu2FLi41u4-ng_uGMUg.png" /><figcaption>Image by author</figcaption></figure><p>Furthermore, we can get a Dataframe with shap values for all rows for further analysis/visualizations.</p><p>If you enjoyed this story — please give me follow here and connect with me on linkedIn: <a href="https://www.linkedin.com/in/omkar-gawade/">https://www.linkedin.com/in/omkar-gawade/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4ae4cbba077" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Russia|Ukraine war — tweets NLP analysis]]></title>
            <link>https://omkargawade.medium.com/russia-ukraine-war-tweets-nlp-analysis-bd10b352316c?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd10b352316c</guid>
            <category><![CDATA[ukraine]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Wed, 16 Mar 2022 15:49:06 GMT</pubDate>
            <atom:updated>2022-03-16T15:49:06.228Z</atom:updated>
            <content:encoded><![CDATA[<h3>Russia|Ukraine war — tweets NLP analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIfDnRWrF2cJphtqY-2L7A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@egorlyfar">Egor Lyfar</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><p>It is sad how the events have uncovered in Ukraine Russia conflict — to think about an active war in this age and society is absolutely scary. The main conflict of the war comes down to the future of Ukraine as an independent nation and it joining NATO — which would cost Russia its prevalence in Europe.</p><p>In this analysis below we will be looking at text data in tweets variable — we will apply Natural language processing to get Compound sentiment, topics, word cloud, personnel loss and equipment loss visuals.</p><h3>Dataset:</h3><p>Datasets contain tweets monitoring the current ongoing <a href="https://www.kaggle.com/bwandowando/ukraine-russian-crisis-twitter-dataset-1-2-m-rows">Ukraine-Russia</a> conflict, We have isolated the tweets from 28th February 2022.</p><p>Below are all the columns present in the dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dKdkZcdqw9Qxa5Rjm-9tLw.png" /><figcaption>Image by Author</figcaption></figure><h3>Data cleaning:</h3><p><strong>Removing redundant variables:</strong> Since we are primarily interested in the tweet text data, variables which contain unimportant data such as links, userid, tweetid etc reduce model performance. Below are all the columns which are removed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XgLXC4GEaPTWwdGTWdt_Fw.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Removing null values: </strong>Null values reduce model performance and skew the data. Since we as a part of the analysis want to look at tweets from <strong>United States</strong> we take out all rows which do not have location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*8QONKeW9fif5nmOymeD2Cg.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Data filters to reduce high variance:</strong> To prevent data with high variance we apply filters to columns and reduce the number of rows. To keep the text analysis to english we filter language to ‘en’ . Filtering the location column is tricky as the data is not clean — so we have to hard code using str.contains to grab highest number of tweets associated with United States.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCc5exuM12pvsDMovATUKw.png" /><figcaption>Image by Author</figcaption></figure><h3>Text Data Cleaning:</h3><p>Text data is a complex and is in natural language (english, german, french etc) — the nature of text data is unstructured and we need to clean and transform it for python to understand and interpret it.</p><p>Below are the steps we take to clean text data:</p><p><strong>Tokenization: </strong>Tokenization is a process of extracting singular words from a statement of words — we import nlkt’s <strong>word_tokenize</strong> function to create tokens for all descriptions of movie/series in dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rVCzUQTsXNfJKZlV.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Removing Stop words: </strong>Stop words are words which do not add any value to the analysis and are merely fillers for natural language — example ‘the’, ‘a’, ‘an’, ‘is’ etc. To remove stop words we need to import stop word dictionary or create a manual dictionary. I have imported stop word dictionary from <strong>Spacy</strong> text modelling library. To remove stop words I have created a function to apply tokenization and remove tokens which match in stop words dictionary from Spacy.</p><p><strong>Lemmatization:</strong> It’s the process of grouping together the inflected forms of a word so they can be analyzed as a single item, identified by the word’s <a href="https://en.wikipedia.org/wiki/Lemma_(morphology)">lemma</a>, or dictionary form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*6PvwVf2g_vroGSXg9tUqRw.png" /><figcaption>Image by Author</figcaption></figure><p>Below is the code we run to apply tokenization, remove stop words and lemmatization to tweets text in dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sq5q8vMlJVLvMTQsY2Zr6Q.png" /><figcaption>Image by Author</figcaption></figure><p>Below is the before and after of applying text data cleaning steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-I6h2Q_L6GX2xpYFDcmnww.png" /><figcaption>Image by Author</figcaption></figure><h3>Word Cloud for Cleaned corpus and hashtags:</h3><p>A word cloud is a visual representation of text data, which are used to visualize free form text. Word cloud usually have single words, and the importance of each word is shown with font size.</p><p>Below is the code to generate Word cloud:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DpNmoC36i1fp3WrOc9dDCg.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Word Cloud for cleaned tweet text:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fshmhxz5grAGKhRWm8PcZA.png" /><figcaption>Image by Author</figcaption></figure><p><strong>Word Cloud for hashtags in cleaned tweet text:</strong></p><p>Code to extract hashtags from cleaned text:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rB_NLGWZI5LQsRzljF6q5w.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZXt2F_fpHv3-NPVfw5E1XA.png" /><figcaption>Image by Author</figcaption></figure><h3>Sentiment Analysis with VADER:</h3><p><strong>VADER (V</strong>alence<strong> A</strong>ware<strong> D</strong>ictionary<strong> </strong>and s<strong>E</strong>ntiment <strong>R</strong>easoner<strong>)</strong> is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media. <strong>VADER</strong> uses a combination of sentiment lexicon is a list of lexical features (e.g., words) which are generally labeled according to their semantic orientation as either positive or negative. <strong>VADER</strong> not only tells about the Positivity and Negativity but also tells us about how positive or negative a sentiment is by giving positive score, negative score, neutral score and a compound score which is sum of all three scores.</p><p>Below is a code snippet to apply Vader Sentiment Analysis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-xtvjbI6OgfcCDFanKlIg.png" /><figcaption>Image by Author</figcaption></figure><p>Below is the piechart() of sentiment type for tweets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUKCQnaoxnKPlPrtXd5xJA.png" /><figcaption>Image by Author</figcaption></figure><h3>Topic Detection with LDA:</h3><p><a href="https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation">Latent Dirichlet Allocation</a> is an unsupervised learning algorithm which represents documents as mixtures of topics that spit out words with certain probabilities.</p><p><strong>Cons of LDA:</strong></p><ol><li>User must define the amount of topics to be created.</li><li>User must interpret what topics are based on probabilities of words assigned to the topics.</li></ol><p>Below is the code you run in python to get Topics assigned to each tweet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cblB1UIgOlgpwcWnmAqGag.png" /><figcaption>Image by Author</figcaption></figure><p>Top 15 words associated with topics:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lX7UQ51IQtPgnfeCNIyynQ.png" /><figcaption>Image by Author</figcaption></figure><p>Countplot() for topics assigned to tweets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G46Edg88S-ACb0BksG-5sA.png" /><figcaption>Image by Author</figcaption></figure><h3>Personnel and equipment loss for Ukraine:</h3><p><a href="https://www.kaggle.com/piterfm/2022-ukraine-russian-war"><strong>Dataset:</strong> </a>This is the dataset that describes Equipment Losses &amp; Death Toll &amp; Military Wounded &amp; Prisoner of War of Russians in 2022 <a href="https://www.kaggle.com/piterfm/2022-ukraine-russian-war">Ukraine-Russia </a>War.</p><h4>Loss in Personnel by Date:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*AXIDXCeaMZem70-guoOBVA.png" /><figcaption>Image by Author</figcaption></figure><h4>Loss in equipment:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D3Iudkrjy85KeSXPcbpffw.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YJ8aJnqtDjpd6qoZeTGNw.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bC4O6rvcTAnxUqDbf_CUJw.png" /><figcaption>Image by Author</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h5_j1YTqi4HJYcuWu39RgA.png" /><figcaption>Image by Author</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd10b352316c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Topic detection and sentiment analysis for Netflix descriptions]]></title>
            <link>https://omkargawade.medium.com/topic-detection-and-sentiment-analysis-for-netflix-descriptions-c7314d244413?source=rss-79b20752c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7314d244413</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sentiment]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <dc:creator><![CDATA[Omkar Gawade]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 21:26:22 GMT</pubDate>
            <atom:updated>2022-03-03T20:15:41.530Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-Ns-4NT-V51YZIcYw8Wiw.png" /></figure><p><a href="https://en.wikipedia.org/wiki/Netflix">Netflix</a> is one of the most popular media and video streaming platforms. They have over 8000 movies or tv shows available on their platform, as of mid-2021, they have over 200M Subscribers globally.</p><p>In this analysis below we will be looking at text data in Movie/series description variable — we will apply Natural language processing to get Compound sentiment and topics.</p><h4>Dataset:</h4><p>This tabular dataset consists of listings of all the movies and tv shows available on <a href="https://www.kaggle.com/shivamb/netflix-shows">Netflix</a>, Below are all the columns present in the dataset</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXyywERAURQYhlcu1bc3Rw.png" /></figure><h4>Data cleaning:</h4><p><strong>Removing null values: </strong>Null values reduce model performance and skew the data. From the below screenshot we see that director, cast and country have the most null values — based on redundant variables we remove columns director and cast . In the next step we us dropna() function to remove all rows with null values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*cyNpkXYMcdqKLuM1Sv47fw.png" /></figure><p><strong>Removing redundant variables:</strong> Variables which contain unimportant data such as links, description reduce model performance. Columns ‘show_id’, ‘type’, ‘country’, ‘rating’, ‘date_added’, ‘duration’, ‘listed_in’ were removed.</p><p><strong>Data filters to reduce high variance:</strong> To prevent data with high variance we apply filters to columns and reduce the number of rows. From the below figure we can see that data is skewed towards the right, to normalize the data we filter release_year &gt; 1980.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfoqQija8yWv0wd9a9iHhg.png" /><figcaption>Distribution Plot</figcaption></figure><h3>Text Data Cleaning:</h3><p>Text data is a complex and is in natural language (english, german, french etc) — the nature of text data is unstructured and we need to clean and transform it for python to understand and interpret it.</p><p>Below are the steps we take to clean text data:</p><p><strong>Tokenization: </strong>Tokenization is a process of extracting singular words from a statement of words — we import nlkt’s <strong>word_tokenize</strong> function to create tokens for all descriptions of movie/series in dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7H10l3QwONzXIoEAte2yFA.png" /></figure><p><strong>Removing Stop words: </strong>Stop words are words which do not add any value to the analysis and are merely fillers for natural language — example ‘the’, ‘a’, ‘an’, ‘is’ etc. To remove stop words we need to import stop word dictionary or create a manual dictionary. I have imported stop word dictionary from <strong>Spacy</strong> text modelling library. To remove stop words I have created a function to apply tokenization and remove tokens which match in stop words dictionary from Spacy.</p><p><strong>Lemmatization:</strong> It’s the process of grouping together the inflected forms of a word so they can be analyzed as a single item, identified by the word’s <a href="https://en.wikipedia.org/wiki/Lemma_(morphology)">lemma</a>, or dictionary form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*TV4f0CUw6i4nicu9MRXXhg.png" /></figure><p>Below is the code we run to apply tokenization, remove stop words and lemmatization to description text in dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Lqq47tw89lVyToFyvBjvQ.png" /></figure><p>Below is the before and after of applying text data cleaning steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cfww4oCmlm_jUFs7ehTuug.png" /></figure><h3>Sentiment Analysis with VADER:</h3><p><strong>VADER (V</strong>alence<strong> A</strong>ware<strong> D</strong>ictionary<strong> </strong>and s<strong>E</strong>ntiment <strong>R</strong>easoner<strong>)</strong> is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media. <strong>VADER</strong> uses a combination of sentiment lexicon is a list of lexical features (e.g., words) which are generally labeled according to their semantic orientation as either positive or negative. <strong>VADER</strong> not only tells about the Positivity and Negativity but also tells us about how positive or negative a sentiment is by giving positive score, negative score, neutral score and a compound score which is sum of all three scores.</p><p>Below is a code snippet to apply Vader Sentiment Analysis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fd3_PeJXVgkiH2PCEU9udA.png" /></figure><p>Below is the snippet of 10 rows with Compound sentiment score and Sentiment_type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vBGXo_r7z0KgpmmcugErZg.png" /></figure><h3>Topic Detection with LDA:</h3><p><a href="https://en.wikipedia.org/wiki/Latent_Dirichlet_allocation">Latent Dirichlet Allocation</a> is an unsupervised learning algorithm which represents documents as mixtures of topics that spit out words with certain probabilities.</p><p><strong>Cons of LDA:</strong></p><ol><li>User must define the amount of topics to be created.</li><li>User must interpret what topics are based on probabilities of words assigned to the topics.</li></ol><p>For python to understand text data we need to vectorize it using Count vectorizer, after a fit transform we get a large matrix of count of words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwKYaOTYiyPgNwIFJ-6Xig.png" /></figure><p>Importing LDA from sklearn library, creating an instance and applying it to matrix spit out of Count vectorizer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9QMbmOs2-_AVlszRmDivw.png" /></figure><p>Printing the top 15 words associated with each topic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5HQpXr8pIqRNG5C0_I2ciA.png" /></figure><p>The next step is manual and totally subjective where the user interprets the highest probability words associated with a topic list above and assigns topic a category name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dh3NMaBoPoPNITWS7jVEJw.png" /></figure><p>We transform the dtm matrix using LDA model created to assign each description cell a mix of probability with each topics. We take the top topic assigned using argmax() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9IQhsMHjTBC9xvb184buA.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2m8ljtHzBhBh-sVLFtR3A.png" /></figure><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7314d244413" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>