<?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 Aghogho  on Medium]]></title>
        <description><![CDATA[Stories by Aghogho  on Medium]]></description>
        <link>https://medium.com/@aghososafe?source=rss-934d6da55eaa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3bds4FD_3HgGqnr1</url>
            <title>Stories by Aghogho  on Medium</title>
            <link>https://medium.com/@aghososafe?source=rss-934d6da55eaa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:54:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aghososafe/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[From Simple Models to Bert: A Walkthrough of Sentiment Analysis Experiment in Google Colab]]></title>
            <link>https://medium.com/@aghososafe/from-simple-models-tobert-a-walkthrough-of-sentiment-analysis-experiment-in-google-colab-b445693f146a?source=rss-934d6da55eaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/b445693f146a</guid>
            <category><![CDATA[bert-model]]></category>
            <category><![CDATA[hugging-face-transformers]]></category>
            <category><![CDATA[machine-learning-models]]></category>
            <category><![CDATA[data-science-projects]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <dc:creator><![CDATA[Aghogho ]]></dc:creator>
            <pubDate>Sat, 02 May 2026 11:12:11 GMT</pubDate>
            <atom:updated>2026-05-02T11:18:12.012Z</atom:updated>
            <content:encoded><![CDATA[<p>When I started building my <strong>ShopEase sentiment analysis project</strong>, I had one big question in mind:</p><p><em>Do I really need a complex nlp learning model like BERT… or can a simple model do the job just as well even if they performed equally?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSPvWZf2RN-6flPIfUzgMg.png" /></figure><p>What followed was a hands-on experimentation journey using Google Colab — full of surprises, debugging headaches, and some very interesting insights.</p><p>This is a complete end-to-end sentiment analysis experimentation pipeline built to analyze customer reviews for an e-commerce platform (ShopEase).</p><p><strong>PROJECT OBJECTIVES</strong></p><p>• Build a scalable data processing pipeline</p><p>• Implement advanced text preprocessing (tokenization, lemmatization, language detection)</p><p>• Develop high accuracy sentiment classification models (Logistic Regression → BERT)</p><p>• Generate human readable summaries of customer feedback (Sentiments)</p><p>• Build interactive dashboards for real time insights</p><p>• Deploy a scalable, real time system (Streamlit/Flask)</p><p><strong>🚀 WHY I CHOSE GOOGLE COLAB</strong></p><p>Before diving into models, I needed an environment that could handle both <strong>fast experimentation</strong> and <strong>heavy models</strong>.</p><p>Google Colab was the obvious choice:</p><p>· Free GPU access</p><p>· No local setup stress</p><p>· Easy integration with my workflow</p><p>It allowed me to move quickly from idea → experiment → result without worrying about system limitations.</p><p><strong>📂 THE DATASET: REAL CUSTOMER VOICES</strong></p><p>The dataset contained real customer reviews from ShopEase, with features like:</p><p>· review_id</p><p>· product_category</p><p>· timestamp</p><p>· country</p><p>· rating</p><p>· review</p><p>· sentiment (target)</p><p><strong>PROJECT GOALS</strong></p><p>To classify each review as <strong>Negative, Neutral, or Positive Sentiment.</strong></p><p>But as always with real-world data… things weren’t that clean.</p><p><strong>IMPORT STATEMENTS</strong></p><p>I started by importing all the libraries needed for the project</p><pre>from pathlib import Path<br>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>import nltk<br>import re<br>import spacy<br>import sys<br>from nltk.corpus import stopwords<br>from nltk.stem import WordNetLemmatizer<br>from nltk.tokenize import word_tokenize<br>from sklearn.feature_extraction.text import CountVectorizer<br>from sklearn.feature_extraction.text import TfidfVectorizer<br>import string<br>import langid<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LogisticRegression<br>from sklearn.metrics import accuracy_score, f1_score, classification_report, confusion_matrix<br>from sklearn.metrics import ConfusionMatrixDisplay<br>import transformers<br>from transformers import AutoTokenizer, BertTokenizer, AutoModelForSequenceClassification<br>import torch<br>from transformers import TrainingArguments, Trainer<br></pre><p><strong>DATA LOADING</strong></p><pre>data_path = Path(&quot;/content/drive/MyDrive/raw_reviews.csv&quot;)<br>df = pd.read_csv(data_path)<br>df.head()</pre><p>I selected 100 samples of observations from my datasets which will be used in my production stage</p><pre>sample_df = df.sample(n=100, random_state=42)<br>sample_df.head()<br>sample_df.to_csv(&quot;/content/drive/MyDrive/sample_reviews.csv&quot;, index=False)</pre><p><strong>INSPECTING THE DATA</strong></p><p>I did initial checks using the following methods:</p><pre>df.shape<br>df.duplicated().sum()<br>df.isna().sum()<br>df.info()<br>df.columns</pre><p><strong>EXPLORATORY DATA ANALYSIS</strong></p><p>I performed series of simple analysis to understand the features of the dataset given.</p><p>- <strong>Product Distribution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*lzv4PKQVm7E0-zcv60HZSw.png" /></figure><p>From the plot we can see that Product categories are evenly distributed (no major imbalance). Ensures fair comparison across categories in analysis.</p><ul><li>Rating Distribution by Product Category</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*8BQ-YS7r2hHs72hCOC9wOg.png" /></figure><p>This plot shows that all categories show a similar pattern: High 5-star dominance followed by 4-star ratings. No category shows unusually poor ratings.</p><ul><li>Rating Distribution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*QGNVoOgvK0oyzPNeaxcrwA.png" /></figure><p>The plot is clearly skewwed toward higher ratings (4 and 5 stars). 5-star ratings are the most frequent, followed by 4-star. Very few low ratings</p><ul><li>Reviews per country</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*oflhFVLTmm9VL_c2flFQRA.png" /></figure><p>Highest activity comes from US, GB, and DE. Other countries contribute smaller but consistent volumes.</p><ul><li>Sentiment per Country</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*KKm2Kpp5SScVlpyje-pjSg.png" /></figure><p>Positive sentiment dominates across all countries. US, GB, and DE again lead in volume of positive reviews. Neutral and negative sentiments are significantly lower, showing consistency with high ratings.</p><p>Before going into data cleaning, I had to check for inconsistencies in the rating and sentiment variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*rmLBvf8yxW84ElF4ewZJYA.png" /></figure><p>Across product categories, sentiment labels generally align with customer ratings, with positive reviews showing higher average ratings. However, certain categories exhibit inconsistencies, where negative sentiment appears alongside high ratings. This suggests either customer experience nuances or potential misclassification in sentiment labeling, highlighting areas for further investigation.</p><p><strong>🧹 Data Cleaning: The Reality of Text Data</strong></p><p>Before any model could learn anything, I had to deal with messy text:</p><p>· Emojis everywhere 😂🔥</p><p>· Random symbols &amp; punctuation</p><p>· Mixed languages</p><p>· Excess whitespace</p><p>· Numbers embedded in reviews</p><p>I started with traditional preprocessing using NLTK, but quickly ran into issues:</p><p>· Missing resources (wordnet, stopwords)</p><p>· Slower processing on large data</p><p>So I switched to a more efficient approach using spaCy pipelines — which significantly improved speed and consistency.</p><p><strong>📊 First Insight: Data Matters More Than Models</strong></p><p>- First I standardize the date and ratings format:</p><p>#Fix date type</p><p>- Then I removed noise by performing data cleaning function called clean_text, with the review text of the dataset. The clean_text function performed the following:</p><p>a. removed URLs</p><p>b. removed mentions</p><p>c. removed numbers</p><p>d. removed symbols</p><p>e. removed emojis</p><p>f. removed punctuation</p><p>g. remove extra whitespaces</p><p>The data cleaning function was applied to the review feature of the dataset to give a new feature in the dataset called clean_review feature.</p><pre>df[&#39;clean_review&#39;] = df[&#39;review&#39;].apply(clean_text)</pre><p>- Another key preprocessing step involved lemmatizing the text to normalize word variations. To support multilingual data, a lightweight language detection approach using <em>langid</em> was applied selectively to the first 200 characters of reviews that were likely to contain non-English content:</p><pre>langid.classify(text[:200])[0]</pre><p>Based on the detected language, lemmatization was then performed using <em>spaCy</em>, primarily for English and multilingual reviews:</p><pre>doc = self.nlp_en(text) if lang == &quot;en&quot; else self.nlp_multi(text)<br>tokens = [token.lemma_ for token in doc]</pre><p>This process reduced words to their base (root) forms, ensuring that similar words were treated as the same feature. As a result, vocabulary size was reduced, model generalization improved, and semantically similar terms were effectively grouped.</p><p>Following this, stopword removal was applied using language-specific stopword lists:</p><pre>[word for word in text.split() if word not in stop_words]</pre><p>This step eliminated common, non-informative words and allowed the model to focus on terms that carry meaningful sentiment. Overall, this reduced noise in the text representation and contributed to improved model efficiency and performance.</p><p>I created a label column to group into 0 for rating (1, 2), 1 for rating (3) and 2 for rating (4 and 5)</p><pre>df[&#39;label&#39;] = df[&#39;rating&#39;].apply(lambda r: 0 if r in (1,2) else ( 1 if r == 3 else 2))<br>df.head()</pre><p><strong>The Baseline: Logistic Regression</strong></p><p>I started simple by creating features to be used by the model by indexing three selected columns from the full sentiment dataset</p><pre>sentiment_data = sentiment_data[[&#39;review&#39;,&#39;final_review&#39;,&#39;label&#39;]]<br>sentiment_data.head()</pre><pre>X = sentiment_data[&#39;final_review&#39;].astype(str)<br>y = sentiment_data[&#39;label&#39;]<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)</pre><p>Using TF-IDF vectorization and scikit-learn, I trained a Logistic Regression model.</p><pre>vectorizer = TfidfVectorizer(max_features=5000)<br>X_train_num = vectorizer.fit_transform(X_train)</pre><pre>lr_model = LogisticRegression()<br>lr_model.fit(X_train_num, y_train)</pre><pre>X_test_num = vectorizer.transform(X_test)<br>lr_model.score(X_test_num, y_test)<br><br>classification_report = classification_report(y_test, lr_model.predict(X_test_num))<br>print(&quot;Classification Report:&quot;)<br>print(classification_report)</pre><p>The Result after performing classification report</p><pre>Classification Report:<br>              precision     recall     f1-score     support<br>0             0.91          0.97       0.94         3602<br>1             0.91          0.97       0.94         3629<br>2             0.99          0.97       0.98         16769<br><br>accuracy                               0.97         24000<br>macro avg     0.94          0.97       0.95         24000<br>weighted avg  0.97          0.97       0.97         24000<br></pre><p>I performed a confusion matrix and did a plot for it.</p><pre>y_pred = lr_model.predict(X_test_num)<br>conf_matrix = confusion_matrix(y_test, y_pred)<br>print(&quot;Confusion Matrix:&quot;)<br>print(conf_matrix)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*0YPm2D1rFrche8p1lbYX9w.png" /></figure><p>From the confusion matrix, the correct predictions are:</p><ul><li>Negative → Negative: 3575</li><li>Neutral → Neutral: 3505</li><li>Positive → Positive: 16108</li></ul><p>Negative Class: Correct (True) is 3575, while misclassified (False) is Neutral: 51, Positive: 51. This gives very few errors</p><p>Neutral Class: Correct classification (True) is 3505 while misclassified (False) is Negative: 59, Positive: 60. Slight confusion with both sides.</p><p>Positive Class: Correct classification(True) is 16108 (very high) while misclassified (False) is Negative: 314, Neutral: 277. Positive class is much larger. So small % error is acceptable.</p><p>The confusion matrix shows that the dataset is imbalanced. The model demonstrates particularly high accuracy for positive reviews (16k vs ~3.5k others), reflecting the dominant class distribution. Minor misclassifications occur between neutral and adjacent sentiment classes, which is expected due to their semantic similarity. The confusion matrix shows strong model performance, with the majority of predictions correctly classified across all sentiment categories. Overall, the model exhibits robust and reliable sentiment classification performance.</p><p><strong>Can BERT actually do better?</strong></p><p>To push things further, I brought in a transformer model using Hugging Face Transformers.</p><p>I used:</p><p>· distilbert-base-multilingual-cased</p><p>· GPU acceleration in Colab</p><p>This was where things got… interesting.</p><p>Before diving into the steps carried out in Bert model analysis, I would like to give a brief explanation of how bert works.</p><p><strong>BERT (Bidirectional Encoder Representations from Transformers)</strong> is a deep learning model developed by Google for understanding text. It is a transformer-based model that understands text context bidirectionally. It uses subword tokenization to break words into meaningful units and applies self-attention to capture relationships between all words in a sentence.</p><p>The core idea of BERT is that it reads text in both directions at the same time. Reads left + right together (bidirectional).</p><p>Key Concepts in BERT</p><ul><li>Transformers Architecture: BERT is based on the Transformer architecture. Uses self-attention</li><li>Self-Attention: Every word looks at every other word in the sentence. Example: “I love this product because it is amazing”. “it” understands it refers to “product”</li><li>Pre-training Tasks BERT learns language using two main tasks:</li><li>Masked Language Modeling (MLM) “I love this [MASK]”. Model predicts missing word → “product”</li><li>Next Sentence Prediction (NSP): Learns relationship between sentences</li></ul><p>How Tokenization Works in BERT:</p><ul><li>Step 1: Split text into tokens. BERT does NOT use simple word splitting. It uses WordPiece Tokenization. WordPiece Tokenization breaks words into smaller subwords. E.g: “playing” →[“play”, “##ing”], “unhappy” → [“un”, “##happy”], where “##” means continuation of a word</li><li>Step 2: Add Special Tokens: BERT adds: [CLS] → start of sentence, [SEP] → end of sentence. Example: “I love NLP” becomes: [CLS] I love NLP [SEP].</li><li>Step 3: Convert tokens to IDs. Each token → numeric ID. “I” → 1045, “love” → 2293. Model only understands numbers.</li><li>Step 4: Attention Masks Tells model which tokens are real vs padding. Tokenization: [CLS], I, am, play, ##ing, football, [SEP].</li></ul><p>The bert workflow….</p><ol><li><strong>Load BERT tokenizer</strong></li></ol><pre>model_name = &quot;distilbert-base-multilingual-cased&quot;<br> <br> tokenizer = AutoTokenizer.from_pretrained(model_name)</pre><p><strong>2. Tokenize text</strong></p><p>From the data split we did and used in logistic regression model, we will be using them (y_train, y_test, X_train and X_test) for the bert model.</p><pre>X_train = X_train.tolist()<br> X_test = X_test.tolist()<br> <br> train_encodings = tokenizer(<br> X_train,<br> truncation=True,<br> padding=True,<br> max_length=128<br> )<br> <br> test_encodings = tokenizer(<br> X_test,<br> truncation=True,<br> padding=True,<br> max_length=128<br> )</pre><p><strong>3. Create PyTorch Dataset</strong></p><p>Before creating the pytorch dataset, I ensured that I convert labels to list to avoid pandas index issues</p><pre>train_dataset = SentimentDataset(train_encodings, y_train)<br> test_dataset = SentimentDataset(test_encodings, y_test)</pre><p><strong>4. Load BERT classification model</strong></p><pre>model = AutoModelForSequenceClassification.from_pretrained(<br> model_name,<br> num_labels=3<br> )</pre><p><strong>5. Define evaluation metrics</strong></p><pre>def compute_metrics(p):<br>    preds = np.argmax(p.predictions, axis=1)<br>    labels = p.label_ids<br><br>    accuracy = accuracy_score(labels, preds)<br>    f1 = f1_score(labels, preds, average=&#39;weighted&#39;)<br>    return {&quot;accuracy&quot;: accuracy, &quot;f1&quot;: f1}</pre><p><strong>6. Set training arguments</strong></p><pre>training_args = TrainingArguments(<br> output_dir=&quot;./bert_results&quot;,<br> num_train_epochs=3,<br> per_device_train_batch_size=16,<br> per_device_eval_batch_size=32,<br> eval_strategy=&quot;epoch&quot;,<br> save_strategy=&quot;epoch&quot;,<br> logging_dir=&quot;./logs&quot;,<br> logging_steps=50,<br> load_best_model_at_end=True,<br> metric_for_best_model=&quot;accuracy&quot;,<br> report_to=&quot;none&quot;<br> )</pre><p><strong>7. Train model</strong></p><pre>trainer = Trainer(<br> model=model,<br> args=training_args,<br> train_dataset=train_dataset,<br> eval_dataset=test_dataset,<br> compute_metrics=compute_metrics<br> )<br>trainer.train()</pre><p><strong>8. Evaluate model</strong></p><pre>results = trainer.evaluate()<br> print(results)</pre><p><strong>9. Make predictions</strong></p><pre>preds = trainer.predict(test_dataset)<br>bert_preds = np.argmax(preds.predictions, axis=1)</pre><p><strong>10. Classification report and Confusion matrix</strong></p><pre>report = classification_report(y_test, bert_preds)<br>print(&quot;Classification Report:&quot;)<br>print(report)<br><br>conf_matrix = confusion_matrix(y_test, bert_preds)<br>print(&quot;Confusion Matrix:&quot;)<br>print(conf_matrix)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*0YPm2D1rFrche8p1lbYX9w.png" /></figure><p>After the getting the reults from the confusion matrix and classification report, we noticed that the results are same as our traditional machine learning model, Logistic regression which is our baseline model. The only reason we are choosing Bert over the traditional machine learning model is because of Bert’s capabilities to be able to know sentence/text predictions and understand context.</p><p><strong>11. Test the Model with single predictions</strong></p><pre>print(&quot;\n&quot; + &quot;=&quot;*50)<br>print(&quot;TESTING THE MODEL&quot;)<br>print(&quot;=&quot;*50)<br><br>#function to test single prediction<br>def test_single_prediction(text, model, tokenizer):<br>    # Tokenize<br>    inputs = tokenizer(text, padding=True, truncation=True, return_tensors=&quot;pt&quot;, max_length=128)<br><br>    #move to same device as model<br>    device = next(model.parameters()).device<br>    inputs = {key: val.to(device) for key, val in inputs.items()}<br><br>    # Make prediction<br>    model.eval()<br>    with torch.no_grad():<br>        outputs = model(**inputs)<br>        probabilities = torch.nn.functional.softmax(outputs.logits, dim=1)<br>        prediction = torch.argmax(probabilities, dim=1).item()<br><br>    # Map to label(Adjust based on label mapping)<br><br>    id2label = {0: &#39;negative&#39;, 1: &#39;neutral&#39;, 2: &#39;positive&#39;}<br>    predicted_label = id2label[prediction]<br>    confidence = probabilities[0][prediction].item()<br><br>    return predicted_label, confidence, probabilities[0].cpu().numpy()<br><br>#Testing on sample text<br>test_sample = [<br>    &quot;I am very impressed with this product&quot;,<br>    &quot;solid build attractive design works as seen in advert&quot;,<br>    &quot;am highly disappointed by the package&quot;,<br> &quot;three stars meets the minimum expectations&quot;,<br>    &quot;Amazing! I would highly recommend&quot;,<br>&quot;broken on arrival return process was a nightmare&quot;,<br>&quot;terrible delivery services&quot;,<br>&quot;superb quality very sturdy and wellmade five&quot;,<br>&quot;its okay, nothing special&quot;<br>]<br><br>print(&quot;/testing on sample test:&quot;)<br>print(&quot;-&quot; * 70)<br>for text in test_sample:<br>    predicted_label, confidence, probs = test_single_prediction(text, model, tokenizer)<br>    print(f&quot;Text: {text}&quot;)<br>    print(f&quot;Sentiment: {predicted_label}&quot;)<br>    print(f&quot;Confidence: {confidence:.3f}&quot;)<br>    print(f&quot;Probabilities: negative={probs[0]:.3f}, neutral={probs[1]:.3f}, positive={probs[2]:.3f}&quot;)<br>    print(&quot;-&quot; * 70)</pre><pre><br>==================================================<br>TESTING THE MODEL<br>==================================================<br>/testing on sample test:<br>----------------------------------------------------------------------<br>Text: I am very impressed with this product<br>Sentiment: positive<br>Confidence: 0.998<br>Probabilities: negative=0.001, neutral=0.001, positive=0.998<br>----------------------------------------------------------------------<br>Text: solid build attractive design works as seen in advert<br>Sentiment: positive<br>Confidence: 0.998<br>Probabilities: negative=0.001, neutral=0.001, positive=0.998<br>----------------------------------------------------------------------<br>Text: am highly disappointed by the package<br>Sentiment: negative<br>Confidence: 0.924<br>Probabilities: negative=0.924, neutral=0.012, positive=0.064<br>----------------------------------------------------------------------<br>Text: three stars meets the minimum expectations<br>Sentiment: neutral<br>Confidence: 0.908<br>Probabilities: negative=0.011, neutral=0.908, positive=0.082<br>----------------------------------------------------------------------<br>Text: Amazing! I would highly recommend<br>Sentiment: positive<br>Confidence: 0.998<br>Probabilities: negative=0.001, neutral=0.001, positive=0.998<br>----------------------------------------------------------------------<br>Text: broken on arrival return process was a nightmare<br>Sentiment: negative<br>Confidence: 0.925<br>Probabilities: negative=0.925, neutral=0.012, positive=0.063<br>----------------------------------------------------------------------<br>Text: terrible delivery services<br>Sentiment: negative<br>Confidence: 0.924<br>Probabilities: negative=0.924, neutral=0.012, positive=0.063<br>----------------------------------------------------------------------<br>Text: superb quality very sturdy and wellmade five<br>Sentiment: positive<br>Confidence: 0.998<br>Probabilities: negative=0.001, neutral=0.001, positive=0.998<br>----------------------------------------------------------------------<br>Text: its okay, nothing special<br>Sentiment: neutral<br>Confidence: 0.910<br>Probabilities: negative=0.011, neutral=0.910, positive=0.079<br>----------------------------------------------------------------------</pre><p><strong>12. Save model</strong></p><pre>model.save_pretrained(&quot;saved_bert_model&quot;)<br>tokenizer.save_pretrained(&quot;saved_bert_model&quot;)</pre><p><strong>📊 The Big Comparison</strong></p><p>After all the effort, it was time to compare:</p><pre>Model                    Accuracy        Speed        Complexity<br><br>Logistic Regression      ~97%            Fast         Low<br>BERT                     ~97%            Slow         High</pre><p>Yes… you’re reading that right.</p><p><strong>They performed almost the same.</strong></p><p><strong>🤯 The Unexpected Lesson</strong></p><p>This was the biggest takeaway of the entire experiment:</p><p><em>A well-cleaned dataset + simple model can compete with advanced deep learning.</em></p><p>Why did this happen?</p><p>· The dataset wasn’t highly complex</p><p>· Sentiment patterns were relatively clear</p><p>· TF-IDF captured enough signal</p><p><strong>🧠 So… Was BERT Worth It?</strong></p><p>Yes, bert was chosen over logistic regression because bert works with context.</p><p>BERT taught me:</p><p>· How to handle large NLP pipelines</p><p>· How to debug real-world ML issues</p><p>· How to think about model trade-offs</p><p><strong>💼 Real-World Perspective</strong></p><p><strong>I considered BERT because:</strong></p><p>· Reviews could be more complex</p><p>· Sarcasm detection mattered</p><p>· Multilingual nuance was critical</p><p><strong>📌 Final Reflection</strong></p><p>This project completely changed how I think about machine learning.</p><p>Before:</p><p>“More complex model = better performance”</p><p>Now:</p><p>“Better data + right model = best outcome”</p><p><strong>🚀 What’s Next?</strong></p><p>Following the experimentation phase, the project progressed into the production stage, where the trained model was deployed using <strong>FastAPI</strong> to serve predictions via API endpoints. Real-time inference was enabled for both single and batch predictions, allowing efficient processing of user inputs. The results were then integrated into a user-friendly interface and visualized through an interactive <strong>Streamlit dashboard</strong>, providing an accessible frontend for monitoring and analyzing model outputs.</p><p>The github repository for this project is <a href="https://github.com/isiakpereaghogho/Sentiment_Analysis_for_ShopEase_Customer_Feedback.git">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b445693f146a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Codecademy Walkthrough Project: Date a Scientist]]></title>
            <link>https://medium.com/@aghososafe/codecademy-walkthrough-project-date-a-scientist-d77ecd90d3ee?source=rss-934d6da55eaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/d77ecd90d3ee</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[okcupid]]></category>
            <category><![CDATA[codecademy]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Aghogho ]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 22:10:26 GMT</pubDate>
            <atom:updated>2026-01-24T22:10:26.918Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my second walkthrough project for Codecademy’s Data Science career path.<br>I will be applying machine learning algorithms to the <em>OkCupid Date a Scientist</em> dataset for completing the <em>machine learning portfolio project</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4b4Gfm5KIgGayxDy" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In recent years, there has been a massive rise in the usage of dating apps to find love. Many of these apps use sophisticated data science techniques to recommend possible matches to users and to optimize the user experience. These apps give us access to a wealth of information that we’ve never had before about how different people experience romance.</p><p>This portfolio project will analyze some data from OKCupid, an app that focuses on using multiple choice and short answers to match users.</p><h3>Project Overview</h3><p>This project explores whether machine learning models can predict users’ zodiac signs using profile data from a dating application. The dataset includes lifestyle behaviors, demographic attributes, and free-text personal essays.</p><p>The motivation was to assess whether zodiac signs — often associated with personality traits — can be inferred from observable user behavior and self-descriptions.</p><h3>Scoping</h3><p>Project scoping creates a structure for the entire project. This includes stating the goals for the project, gathering the data, considering the analytical steps required through analysis and evaluation which will help build conclusions and findings from the analysis. A proper project scope can be a great road map for any project.</p><h3>Project Goals</h3><p>The project goal is to utilize the machine learning skills and its techniques to the OKCupid App User Profile dataset. Zodiac symbols are important for many users, but some users don’t add them in. This project will classify Zodiac signs using drinking, smoking, drugs, and essays as the features and will predict a user’s zodiac signs so we can guess the missing zodiacs when we make matches.</p><h3>Data</h3><p>The data is stored in profiles.csv provided by codecademy. The dataset provided has the following columns of multiple-choice data:</p><ul><li>age: continuous variable of users age</li><li>body_type: categorical variable of body type of user</li><li>diet: categorical variable of dietary information</li><li>drinks: categorical variable of alcohol consumption</li><li>drugs: categorical variable of drug usage</li><li>education: categorical variable of educational attainment</li><li>ethnicity: categorical variable of ethnic backgrounds</li><li>height: continuous variable of height of user</li><li>income: continuous variable of income of user</li><li>job: categorical variable of employment description</li><li>offspring: categorical variable of children status</li><li>orientation: categorical variable of sexual orientation</li><li>pets: categorical variable of pet preferences</li><li>religion: categorical variable of religious background</li><li>sex: categorical variable of gender</li><li>sign: categorical variable of astrological symbol</li><li>smokes: categorical variable of smoking consumption</li><li>speaks: categorical variable of language spoken</li><li>status: categorical variable of relationship status</li><li>last_online: date variable of last login</li><li>location: categorical variable of user locations</li></ul><p>And a set of open short-answer responses to :</p><ul><li>essay0: My self summary</li><li>essay1: What I’m doing with my life</li><li>essay2: I’m really good at</li><li>essay3: The first thing people usually notice about me</li><li>essay4: Favorite books, movies, show, music, and food</li><li>essay5: The six things I could never do without</li><li>essay6: I spend a lot of time thinking about</li><li>essay7: On a typical Friday night I am</li><li>essay8: The most private thing I am willing to admit</li><li>essay9: You should message me if…</li></ul><h3>Analysis</h3><p>After the data is received, summary statistics, descriptive statistics like mean, median, range, correlations,Data visualizations for univariate and multivariate exploration and short summary notes explaining insights gained from exploration. Since zodiac signs are being classified to make predictions on missing zodiac signs, machine learning classification algorithms will be implemented to solve the problem of this project.</p><h3>Evaluation</h3><p>Once the model is created, metrics of success are used to evaluate the model performance(s). This include the use of confusion matrix and finding the accuracy, precision, recall, f1 of the model(s) used, and create graphs showing how they changed.</p><h3>Dataset Features for Machine Learning Models</h3><p>Categorical: sex, body type, diet, drinks, drugs, smokes, job, education, religion</p><p>Numerical: age, height</p><p>Text: combined user essays (essay0–essay9)</p><p>Target: zodiac sign (12 classes)</p><h3>Methods &amp; Models</h3><p>The following models were implemented and evaluated:</p><p>Logistic Regression</p><p>Linear Support Vector Machine (SVM)</p><p>K-Nearest Neighbors (KNN)</p><p>Decision Tree</p><p>Random Forest</p><p>Text data was vectorized using TF-IDF, categorical variables were one-hot encoded, and numerical features were standardized.</p><p>In recent years, there has been a massive rise in the usage of dating apps to find love. Many of these apps use sophisticated data science techniques to recommend possible matches to users and to optimize the user experience. These apps give us access to a wealth of information that we’ve never had before about how different people experience romance.</p><p>This portfolio project will analyze some data from OKCupid, an app that focuses on using multiple choice and short answers to match users.</p><p>IMPORT STATEMENTS</p><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LogisticRegression<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.neighbors import KNeighborsClassifier<br>from sklearn.metrics import classification_report<br>from sklearn.metrics import confusion_matrix <br>from sklearn.model_selection import KFold<br>from sklearn.model_selection import cross_val_score<br>from sklearn.compose import ColumnTransformer<br>from sklearn.feature_extraction.text import TfidfVectorizer<br>from sklearn.preprocessing import OneHotEncoder, StandardScaler</pre><p>LOAD THE DATA</p><pre>profiles = pd.read_csv(&#39;profiles.csv&#39;)<br>profiles.head()</pre><p>INSPECT THE DATA</p><pre>print(profiles.shape)</pre><pre>(59946, 31)</pre><pre>list(profiles.columns)</pre><pre>[&#39;age&#39;,<br> &#39;body_type&#39;,<br> &#39;diet&#39;,<br> &#39;drinks&#39;,<br> &#39;drugs&#39;,<br> &#39;education&#39;,<br> &#39;essay0&#39;,<br> &#39;essay1&#39;,<br> &#39;essay2&#39;,<br> &#39;essay3&#39;,<br> &#39;essay4&#39;,<br> &#39;essay5&#39;,<br> &#39;essay6&#39;,<br> &#39;essay7&#39;,<br> &#39;essay8&#39;,<br> &#39;essay9&#39;,<br> &#39;ethnicity&#39;,<br> &#39;height&#39;,<br> &#39;income&#39;,<br> &#39;job&#39;,<br> &#39;last_online&#39;,<br> &#39;location&#39;,<br> &#39;offspring&#39;,<br> &#39;orientation&#39;,<br> &#39;pets&#39;,<br> &#39;religion&#39;,<br> &#39;sex&#39;,<br> &#39;sign&#39;,<br> &#39;smokes&#39;,<br> &#39;speaks&#39;,<br> &#39;status&#39;]</pre><pre>print(profiles.info())</pre><pre>&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;<br>RangeIndex: 59946 entries, 0 to 59945<br>Data columns (total 31 columns):<br> #   Column       Non-Null Count  Dtype  <br>---  ------       --------------  -----  <br> 0   age          59946 non-null  int64  <br> 1   body_type    54650 non-null  object <br> 2   diet         35551 non-null  object <br> 3   drinks       56961 non-null  object <br> 4   drugs        45866 non-null  object <br> 5   education    53318 non-null  object <br> 6   essay0       54458 non-null  object <br> 7   essay1       52374 non-null  object <br> 8   essay2       50308 non-null  object <br> 9   essay3       48470 non-null  object <br> 10  essay4       49409 non-null  object <br> 11  essay5       49096 non-null  object <br> 12  essay6       46175 non-null  object <br> 13  essay7       47495 non-null  object <br> 14  essay8       40721 non-null  object <br> 15  essay9       47343 non-null  object <br> 16  ethnicity    54266 non-null  object <br> 17  height       59943 non-null  float64<br> 18  income       59946 non-null  int64  <br> 19  job          51748 non-null  object <br> 20  last_online  59946 non-null  object <br> 21  location     59946 non-null  object <br> 22  offspring    24385 non-null  object <br> 23  orientation  59946 non-null  object <br> 24  pets         40025 non-null  object <br> 25  religion     39720 non-null  object <br> 26  sex          59946 non-null  object <br> 27  sign         48890 non-null  object <br> 28  smokes       54434 non-null  object <br> 29  speaks       59896 non-null  object <br> 30  status       59946 non-null  object <br>dtypes: float64(1), int64(2), object(28)<br>memory usage: 14.2+ MB<br>None</pre><pre>profiles.describe()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*LjqW2RkQXs9HjVNBQy0Srg.png" /></figure><pre>print(&#39;number of zodaic_signs:&#39;,profiles[&#39;sign&#39;].nunique())<br>print(&#39;zodaic_signs:&#39;,profiles[&#39;sign&#39;].unique())<br>print(profiles[&#39;sign&#39;].value_counts())</pre><p>From our inspection of the sign column, there are 48, but there should only be 12 signs. Upon closer inspection, there seems to be special characters and text attached with the signs. These text as well as special characters (eg &amp;rsquo; for a single quote ‘) will need to be removed.</p><pre>print(profiles[&#39;age&#39;].unique())<br>print(profiles[&#39;age&#39;].value_counts())</pre><p>From our age column, we have two users with age 110 years and age 109 years which are outliers to the age column. In real life, its impossible for users of these ages to be on a dating site. Since these outliers are just two in numbers, We will keep them because the two data points should have minimal effect on our ML model.</p><pre>print(profiles[&#39;height&#39;].unique())<br>print(profiles[&#39;height&#39;].value_counts())</pre><p>Inspecting outliers for height (eg, 1, 3, 4, 6, 8 or 9 inches) shows there are outliers and this may be as a result of typos. The data can be included since height is not a major indicator to solve the machine learning problem.</p><pre>print(profiles[&#39;income&#39;].unique())<br>print(profiles[&#39;income&#39;].value_counts())</pre><pre>[     -1   80000   20000   40000   30000   50000   60000 1000000  150000<br>  100000  500000   70000  250000]<br>income<br>-1          48442<br> 20000       2952<br> 100000      1621<br> 80000       1111<br> 30000       1048<br> 40000       1005<br> 50000        975<br> 60000        736<br> 70000        707<br> 150000       631<br> 1000000      521<br> 250000       149<br> 500000        48<br>Name: count, dtype: int64</pre><p>Its impossible to have income of -1, this could be as a result of typos. So we will replace the -1 income with NaNs, or null values, and use regex to special characters if any.</p><p>DATA CLEANING</p><p>First to be explored is the number of unique signs. The text as well as special characters (eg &amp;rsquo; for a single quote ‘), that will need to be removed.</p><p>We will replace the -1 income values with NaNs, or no values, and use regex to remove special characters.</p><p>We will also use regex to remove special characters in some other columns.</p><pre># replace special characters<br>profiles_cols = profiles.columns</pre><pre>for col in profiles_cols:<br>    profiles_cols.str.replace(r&quot;&amp;amp;&quot;, &quot;&amp;&quot;, regex=True)<br>    profiles_cols.str.replace(r&quot;&amp;rsquo;&quot;, &quot;&#39;&quot;, regex=True)<br>    # replace html<br>    profiles_cols.str.replace(r&quot;&lt;[^&lt;&gt;]*&gt;&quot;, &quot; &quot;, regex=True)<br>    profiles_cols.str.replace(r&quot;https?://&quot;, &quot; &quot;, regex=True)<br>    #replace \n<br>    profiles_cols.str.replace(r&quot;\n&quot;, &quot; &quot;, regex=True)<br>    profiles_cols.str.replace(r&quot;\&#39;&quot;, &quot;&#39;&quot;, regex=True)<br>    #check if each special characters is replaced<br>    print(f&quot;{col}:{profiles[col].unique()}&quot;)</pre><pre>profiles[&#39;sign&#39;] = profiles.sign.str.split().str.get(0)<br>print(&quot;Number of Zodaic signs:&quot;,profiles.sign.unique())</pre><pre>Number of Zodaic signs: [&#39;gemini&#39; &#39;cancer&#39; &#39;pisces&#39; &#39;aquarius&#39; &#39;taurus&#39; &#39;virgo&#39; &#39;sagittarius&#39;<br> &#39;leo&#39; nan &#39;aries&#39; &#39;libra&#39; &#39;scorpio&#39; &#39;capricorn&#39;]</pre><pre>#checking few rows of the dataset to see if cleaning has been effected<br>profiles.head()</pre><h4>EXPLORATORY DATA ANALYSIS</h4><h4>DATA VISUALIZATION</h4><p>We are going to get the data visualization for our variables. The continuous variables and the categorical variable. Starting with the continuous variable, we visualize data for the age variable.</p><h4>Age Distribution of Users</h4><pre>profile_age_sex = profiles.groupby([&#39;age&#39;,&#39;sex&#39;]).size().unstack(fill_value=0)<br>#profile_age_sex</pre><pre>median_age = profiles.age.median()<br>#charts for age distribution<br>fig = plt.subplots(1,2, figsize=(15,6))<br>plt.subplot(1, 2, 1)<br>sns.histplot(data=profiles, x=&#39;age&#39;, bins=range(20, 110), color=&#39;purple&#39;, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.title(&#39;Age range of OKCupid Users&#39;)<br>plt.xlabel(&#39;Age (years)&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.axvline(median_age, color=&#39;firebrick&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br><br>plt.subplot(1, 2, 2)<br>sns.histplot(data=profiles, x=&#39;age&#39;, hue=&#39;sex&#39;, bins=range(20, 110), color=&#39;blue&#39;, edgecolor=&#39;black&#39;, alpha=0.5, multiple=&#39;stack&#39;)<br>plt.title(&#39;Age range of male and female OKCupid Users&#39;)<br>plt.xlabel(&#39;Age (years)&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()<br>print(&#39;&#39;,)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*6xb-CXpYlLLoTNUUwEY3iQ.png" /></figure><p>The most users are in their mid 20s to early 30s and there is a peak around age 25.It looks like there are slightly more females over the age of 55 on the site than males. Age median is 30 and also we can see that the distribution is right skewed, meaning that in our dataset less number of users fall below age 40.</p><h4>Height Distribution of Users</h4><pre>print(profiles.height.unique())<br>profile_height_sex = profiles.groupby([&#39;height&#39;,&#39;sex&#39;]).size().unstack(fill_value=0)<br>profile_height_sex</pre><pre>[75. 70. 68. 71. 66. 67. 65. 72. 62. 64. 69. 73. 74. 60. 63. 76. 61. 78.<br> 79. 59. 80. 91. 83. 77. 58. 56. 95. 57. 87. 81. 36. 43. 52. 55. 53. 93.<br>  8. 54. 82.  3. 86. 42. 84. 94. 50.  6. 47. 49. 48. 90. 88. nan 37.  9.<br> 51.  1. 92. 26. 85. 89.  4.]</pre><pre>#chart for height distribution<br>Average_height = profiles.height.mean()<br>fig = plt.subplots(1,2, figsize=(15,6))<br>plt.subplot(1, 2, 1)<br>sns.histplot(data=profiles, x=&#39;height&#39;, bins=range(1, 100), color=&#39;purple&#39;, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.title(&#39;Height Distribution of OKCupid Users&#39;)<br>plt.xlabel(&#39;Height (in inches)&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.axvline(Average_height, color=&#39;firebrick&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br><br>plt.subplot(1, 2, 2)<br>sns.histplot(data=profiles, x=&#39;height&#39;, hue=&#39;sex&#39;, bins=range(1, 100), color=&#39;blue&#39;, edgecolor=&#39;black&#39;, alpha=0.5, multiple=&#39;stack&#39;)<br>plt.title(&#39;Height Distribution of male and female OKCupid Users&#39;)<br>plt.xlabel(&#39;Height (in inches)&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()<br>print(&#39;Average height: &#39;, Average_height)</pre><pre>Average height:  68.29528051649066</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*B8EPEw0TdnvW7W9LFqk4xw.png" /></figure><p>The average height is 68 inches, The most frequent height of all users is about 70 inches. Most men are 70 inches, while most women are 64 inches. Its obvious that females tend to be shorter than males and the charts appears as a normal distribution.</p><h4>Income Distribution of OKCupid Users</h4><pre>print(profiles.income.unique())</pre><pre>[     -1   80000   20000   40000   30000   50000   60000 1000000  150000<br>  100000  500000   70000  250000]</pre><p>It’s impossible for a user to have an income of -1. It is assumed that users with -1 as income are users who failed to fill their income information. So we take every -1 as missing data. I will replace -1 as nan showing that its a missing data</p><pre>profiles[&quot;income&quot;] = profiles[&quot;income&quot;].replace(-1, np.nan)<br>print(profiles[&quot;income&quot;].unique())</pre><pre>[     nan   80000.   20000.   40000.   30000.   50000.   60000. 1000000.<br>  150000.  100000.  500000.   70000.  250000.]</pre><pre>print(profiles[&#39;income&#39;].isna().sum())</pre><pre>48442</pre><pre>print(profiles[&quot;income&quot;].unique())</pre><pre>[     nan   80000.   20000.   40000.   30000.   50000.   60000. 1000000.<br>  150000.  100000.  500000.   70000.  250000.]</pre><pre>print(profiles[&quot;income&quot;].value_counts(normalize=True, dropna = False) * 100)</pre><pre>income<br>NaN          80.809395<br>20000.0       4.924432<br>100000.0      2.704100<br>80000.0       1.853335<br>30000.0       1.748240<br>40000.0       1.676509<br>50000.0       1.626464<br>60000.0       1.227772<br>70000.0       1.179395<br>150000.0      1.052614<br>1000000.0     0.869116<br>250000.0      0.248557<br>500000.0      0.080072<br>Name: proportion, dtype: float64</pre><p>80.8% of users in the app did not fill their income values hence the missing values represented as -1</p><pre>profile_income_sex = profiles.groupby([&#39;income&#39;,&#39;sex&#39;], dropna = False).size().unstack(fill_value=0)<br>profile_income_sex</pre><p>sexfmincome20000.01031192130000.032072840000.033966650000.031166460000.022151570000.016654180000.0261850100000.02561365150000.075556250000.05144500000.03451000000.0125396NaN2100427438</p><pre>Average_income = profiles.income.mean()<br>print(&#39;Average income: &#39;, Average_income)</pre><pre>Average income:  104394.99304589708</pre><pre>#chart for Income distribution<br>sns.histplot(data=profiles, x=&#39;income&#39;, binwidth=50000, color=&#39;purple&#39;, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.title(&#39;Income Distribution of OKCupid Users&#39;)<br>plt.xlabel(&#39;Income&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.axvline(Average_income, color=&#39;firebrick&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*HZMxXwL2iuE1CO0bwOwwQQ.png" /></figure><pre>sns.histplot(data=profiles, x=&#39;income&#39;, hue=&#39;sex&#39;, binwidth = 50000, color=&#39;blue&#39;, edgecolor=&#39;black&#39;, alpha=0.5, multiple=&#39;stack&#39;)<br>plt.title(&#39;Income Distribution of male and female OKCupid Users&#39;)<br>plt.xlabel(&#39;Income&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*tjMq2VNN_tQXH4CdD7OSqQ.png" /></figure><h4>CATEGORICAL VARIABLES</h4><h4>SEX AND ORIENTATION OF USERS</h4><p>We need to check the proportion of male and female users in the app and their orientation as well.</p><pre>print(profiles.sex.value_counts())</pre><pre>sex<br>m    35829<br>f    24117<br>Name: count, dtype: int64</pre><pre>plt.figure(figsize=(4,4))<br>labels = [&#39;males&#39;, &#39;females&#39;]<br>count = [35829, 24117]<br>plt.pie(count,<br>    labels=labels,<br>    autopct=&#39;%1.1f%%&#39;,<br>    startangle=90)<br>plt.title(&#39;Proportion of male and female users in the App&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*7CgnAj0uATMMTlRpWeOzMw.png" /></figure><p>Male users are more in the app with a percentage of 59.8% (35829) and 40.2% (24117) of female users</p><pre>print(profiles.orientation.value_counts(normalize=True)*100)</pre><pre>orientation<br>straight    86.087479<br>gay          9.296700<br>bisexual     4.615821<br>Name: proportion, dtype: float64</pre><pre>fig = plt.subplots(1,2, figsize=(15,6))<br>plt.subplot(1, 2, 1)<br>sns.countplot(data=profiles, x=&#39;orientation&#39;, order=profiles[&#39;orientation&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.6)<br>plt.xlabel(&#39;Orientation&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.title(&#39;Orientation of OKCupid Users&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)</pre><pre>plt.subplot(1, 2, 2)<br>sns.countplot(data=profiles, x=&#39;orientation&#39;, hue=&#39;sex&#39;, order=profiles[&#39;orientation&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.xlabel(&#39;Orientation&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.title(&#39;Orientation of OKCupid Users for males and females&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*wAc69jcObFOP3c_BoO2hAg.png" /></figure><h4>Status: Availability of Users</h4><pre>print(profiles.status.isna().sum())</pre><pre>0</pre><pre>status_count = profiles.status.value_counts(normalize=True) * 100<br>print(status_count)</pre><pre>status<br>single            92.911954<br>seeing someone     3.443099<br>available          3.111133<br>married            0.517132<br>unknown            0.016682<br>Name: proportion, dtype: float64</pre><pre>profiles.groupby([&#39;status&#39;, &#39;sex&#39;]).size().unstack(fill_value=0)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*da1HCYUOP_4tgnkeHm82QQ.png" /></figure><pre>fig = plt.subplots(1,2, figsize=(15,6))<br>plt.subplot(1, 2, 1)<br>sns.countplot(data=profiles, x=&#39;status&#39;, order=profiles[&#39;status&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.6)<br>plt.xlabel(&#39;Users Status&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.title(&#39;Status of OKCupid Users&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br><br>plt.subplot(1, 2, 2)<br>sns.countplot(data=profiles, x=&#39;status&#39;, hue=&#39;sex&#39;, order=profiles[&#39;status&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.xlabel(&#39;Users Status&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.title(&#39;Status of male and female users in the App&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*bG3gT8u_55THRyrvNOLg0A.png" /></figure><p>As expected for a dating site, most of the users for this app are single which is (96%) of the entire users population where we have more males than female users who are single</p><h4>Signs: Zodaic Signs of OKCupid Users</h4><p>One feature people look out for in dating app is zodiac signs</p><pre>print(profiles.sign.isna().sum())</pre><pre>11056</pre><pre>profiles.sign.value_counts(normalize = True, dropna=False) * 100</pre><pre>sign<br>NaN            18.443266<br>leo             7.296567<br>gemini          7.189804<br>libra           7.017983<br>cancer          7.016315<br>virgo           6.907884<br>taurus          6.906216<br>scorpio         6.896207<br>aries           6.654322<br>pisces          6.582591<br>sagittarius     6.575918<br>aquarius        6.552564<br>capricorn       5.960364<br>Name: proportion, dtype: float64</pre><pre>sign_count = profiles.sign.value_counts(dropna=False)<br>print(sign_count)</pre><pre>sign<br>NaN            11056<br>leo             4374<br>gemini          4310<br>libra           4207<br>cancer          4206<br>virgo           4141<br>taurus          4140<br>scorpio         4134<br>aries           3989<br>pisces          3946<br>sagittarius     3942<br>aquarius        3928<br>capricorn       3573<br>Name: count, dtype: int64</pre><pre>sign_count.plot(kind = &#39;bar&#39;, x = &#39;sign&#39;)<br>plt.xlabel(&#39;Zodaic Signs&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.title(&#39;Zodaic Signs of Users in OKCupid App&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*HDjkcfytOCHVhV27H49feg.png" /></figure><p>Over 18% (11056) of users had missing sign values in the dataset.</p><h4>Ethnicity and Language (Speaks): How diverse is OkCupid and what languages do they speak?</h4><pre>print(profiles.ethnicity.isna().sum())</pre><pre>5680</pre><pre>profiles.ethnicity = profiles.ethnicity.fillna(&#39;no ethnicity&#39;)</pre><pre>ethnicity_count = (profiles.ethnicity.value_counts(normalize=True, dropna=False) * 100)[0:6]<br>print(ethnicity_count)</pre><pre>ethnicity<br>white               54.767624<br>asian               10.232543<br>no ethnicity         9.475194<br>hispanic / latin     4.709238<br>black                3.349681<br>other                2.845895<br>Name: proportion, dtype: float64</pre><pre>ethnicity_count.plot(kind=&#39;barh&#39;, y=&quot;ethnicity_count.index&quot;)<br>plt.xlabel(&#39;Count&#39;)<br>plt.ylabel(&#39;Ethnicity&#39;)<br>plt.title(&#39;Proportion of Top 6 users ethnicity in the Okcupid App&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*LB_OsX4f1NJkzIc7uEzl3Q.png" /></figure><p>About 90% of the users in the app filled their ethnicity data giving missing ethnicity data of about 10%. From the population of users in the app 60% are white. The next highest ethnicity is Asian at 11%. There are enough users who indicated more than one ethnicity that plotting the information resulted in a chart too large to fit on my screen. We will keep this information in mind when we get to the modeling stage.</p><pre>print(profiles.speaks.isna().sum())</pre><pre>50</pre><pre>language_count = profiles.speaks.value_counts(normalize=True) * 100<br>print(language_count)</pre><pre>speaks<br>english                                                                                36.443168<br>english (fluently)                                                                     11.065847<br>english (fluently), spanish (poorly)                                                    3.437625<br>english (fluently), spanish (okay)                                                      3.200548<br>english (fluently), spanish (fluently)                                                  2.150394<br>                                                                                         ...    <br>english (fluently), spanish (poorly), italian (poorly), khmer (poorly)                  0.001670<br>english (fluently), ukrainian (fluently), russian (fluently)                            0.001670<br>english (fluently), other (okay), german (okay), spanish (poorly), tagalog (poorly)     0.001670<br>english (fluently), spanish (poorly), tagalog (okay), french (poorly)                   0.001670<br>english (fluently), spanish (poorly), turkish (okay), persian (fluently)                0.001670<br>Name: proportion, Length: 7647, dtype: float64</pre><pre>english_speakers = profiles[&#39;speaks&#39;].str.contains(&quot;english&quot;)<br>count = english_speakers.sum()<br>print(count)</pre><pre>59896</pre><p>Majority of users are multilingual, however all users included “english” as their main language. This indicates language will not affect whether or not someone is a match?</p><h4>Location of OKCupid Users or where do Users live?</h4><pre>print(profiles.location.isna().sum())</pre><pre>0</pre><pre>print(profiles.location.value_counts())</pre><pre>location<br>san francisco, california    31064<br>oakland, california           7214<br>berkeley, california          4212<br>san mateo, california         1331<br>palo alto, california         1064<br>                             ...  <br>denver, colorado                 1<br>seattle, washington              1<br>cincinnati, ohio                 1<br>phoenix, arizona                 1<br>rochester, michigan              1<br>Name: count, Length: 199, dtype: int64</pre><pre># splitting out the city and state in the location to make an easier to visualize location<br>profiles[[&#39;city&#39;, &#39;state&#39;]] = profiles[&#39;location&#39;].str.split(&#39;,&#39;, expand=True, n=1).fillna(&#39;Unknown&#39;)<br>print(profiles.state.unique())</pre><pre>[&#39; california&#39; &#39; colorado&#39; &#39; new york&#39; &#39; oregon&#39; &#39; arizona&#39; &#39; hawaii&#39;<br> &#39; montana&#39; &#39; wisconsin&#39; &#39; virginia&#39; &#39; spain&#39; &#39; nevada&#39; &#39; illinois&#39;<br> &#39; vietnam&#39; &#39; ireland&#39; &#39; louisiana&#39; &#39; michigan&#39; &#39; texas&#39; &#39; united kingdom&#39;<br> &#39; massachusetts&#39; &#39; north carolina&#39; &#39; idaho&#39; &#39; mississippi&#39; &#39; new jersey&#39;<br> &#39; florida&#39; &#39; minnesota&#39; &#39; georgia&#39; &#39; utah&#39; &#39; washington&#39; &#39; west virginia&#39;<br> &#39; connecticut&#39; &#39; tennessee&#39; &#39; rhode island&#39; &#39; district of columbia&#39;<br> &#39; british columbia, canada&#39; &#39; missouri&#39; &#39; germany&#39; &#39; pennsylvania&#39;<br> &#39; netherlands&#39; &#39; switzerland&#39; &#39; mexico&#39; &#39;</pre><pre>#Top 10 State with highest OKCupid Users<br>state_counts = profiles.state.value_counts()[0:10]<br>print(state_counts)</pre><pre>state<br>california              59855<br>new york                   17<br>illinois                    8<br>massachusetts               5<br>oregon                      4<br>texas                       4<br>michigan                    4<br>arizona                     3<br>florida                     3<br>district of columbia        2<br>Name: count, dtype: int64</pre><pre>#Top 10 City with highest OKCupid Users<br>city_counts = profiles.city.value_counts()[0:10]<br>print(city_counts)</pre><pre>city<br>san francisco    31064<br>oakland           7214<br>berkeley          4212<br>san mateo         1331<br>palo alto         1064<br>alameda            910<br>san rafael         755<br>hayward            747<br>emeryville         738<br>redwood city       693<br>Name: count, dtype: int64</pre><pre>fig, axes = plt.subplots(1, 2, figsize=(15,6))<br># Left plot for States<br>state_counts.plot(kind=&#39;bar&#39;,ax=axes[0])<br>axes[0].set_xlabel(&#39;States&#39;)<br>axes[0].set_ylabel(&#39;Count&#39;)<br>axes[0].set_title(&#39;Top 10 States with Highest OKCupid Users&#39;)<br>axes[0].grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)</pre><pre># Right plot for Cities<br>city_counts.plot(kind=&#39;bar&#39;, ax=axes[1])<br>axes[1].set_xlabel(&#39;Cities&#39;)<br>axes[1].set_ylabel(&#39;Count&#39;)<br>axes[1].set_title(&#39;Top 10 Cities with Highest OKCupid Users&#39;)<br>axes[1].grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*LTnU-J3OP66klORzHoZulA.png" /></figure><p>Almost all (99%) of the users live in California in the US, and among these users, more than half live in the city of San Fransisco.</p><h4>Body-Type of OKCupid Users</h4><pre>fig = plt.subplots(1,2, figsize=(15,6))<br>plt.subplot(1, 2, 1)<br>sns.countplot(data=profiles, x=&#39;body_type&#39;, order=profiles[&#39;body_type&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.6)<br>plt.xlabel(&#39;Body type&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.xticks(rotation=60)<br>plt.title(&#39;Body type of OKCupid Users&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br><br>plt.subplot(1, 2, 2)<br>sns.countplot(data=profiles, x=&#39;body_type&#39;, hue=&#39;sex&#39;, order=profiles[&#39;body_type&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.xlabel(&#39;Body type&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.xticks(rotation=60)<br>plt.title(&#39;Body type of male and female users in the OKCupid App&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*K38jTnnjhQPMdtJMFfS5Lg.png" /></figure><p>From the left chart, most users describe themselves as average, fit, or athletic. The right chart shows the distribution of body type by gender and it seems that most of the “curvy” and “full figured” descriptions are realted to females, while alot of males describes themselves as ‘average’, ‘fit’, ‘athletic’and ‘a little extra’.</p><h4>Offspring of OKCupid Users</h4><pre>print(profiles.offspring.unique())</pre><pre>[&#39;doesn&amp;rsquo;t have kids, but might want them&#39; nan<br> &#39;doesn&amp;rsquo;t want kids&#39; &#39;doesn&amp;rsquo;t have kids, but wants them&#39;<br> &#39;doesn&amp;rsquo;t have kids&#39; &#39;wants kids&#39; &#39;has a kid&#39; &#39;has kids&#39;<br> &#39;doesn&amp;rsquo;t have kids, and doesn&amp;rsquo;t want any&#39;<br> &#39;has kids, but doesn&amp;rsquo;t want more&#39;<br> &#39;has a kid, but doesn&amp;rsquo;t want more&#39; &#39;has a kid, and wants more&#39;<br> &#39;has kids, and might want more&#39; &#39;might want kids&#39;<br> &#39;has a kid, and might want more&#39; &#39;has kids, and wants more&#39;]</pre><pre>profiles.offspring = profiles.offspring.str.replace(r&quot;&amp;rsquo;&quot;, &quot;&#39;&quot;, regex=True)<br>print(profiles.offspring.unique</pre><pre>[&quot;doesn&#39;t have kids, but might want them&quot; nan &quot;doesn&#39;t want kids&quot;<br> &quot;doesn&#39;t have kids, but wants them&quot; &quot;doesn&#39;t have kids&quot; &#39;wants kids&#39;<br> &#39;has a kid&#39; &#39;has kids&#39; &quot;doesn&#39;t have kids, and doesn&#39;t want any&quot;<br> &quot;has kids, but doesn&#39;t want more&quot; &quot;has a kid, but doesn&#39;t want more&quot;<br> &#39;has a kid, and wants more&#39; &#39;has kids, and might want more&#39;<br> &#39;might want kids&#39; &#39;has a kid, and might want more&#39;<br> &#39;has kids, and wants more&#39;]</pre><pre>print(profiles.offspring.value_counts(normalize=True)*100)</pre><pre>offspring<br>doesn&#39;t have kids                          31.002666<br>doesn&#39;t have kids, but might want them     15.890917<br>doesn&#39;t have kids, but wants them          14.619643<br>doesn&#39;t want kids                          12.003281<br>has kids                                    7.721960<br>has a kid                                   7.713758<br>doesn&#39;t have kids, and doesn&#39;t want any     4.642198<br>has kids, but doesn&#39;t want more             1.812590<br>has a kid, but doesn&#39;t want more            1.127742<br>has a kid, and might want more              0.947304<br>wants kids                                  0.922698<br>might want kids                             0.746360<br>has kids, and might want more               0.471601<br>has a kid, and wants more                   0.291163<br>has kids, and wants more                    0.086119<br>Name: proportion, dtype: float64</pre><pre>plt.figure(figsize=(6,7))<br>sns.countplot(data=profiles, y=&quot;offspring&quot;, hue=&#39;sex&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*jN3mBtNAQLF-iiZGk2ZdqQ.png" /></figure><p>Vast majority of users don’t have kids, followed by an indication that they want or might want them. More women want kids or already have them than men.</p><h4>Pets owned by OKCupid Users</h4><pre>print(profiles.pets.value_counts(normalize=True)*100)</pre><pre>pets<br>likes dogs and likes cats          37.011868<br>likes dogs                         18.048720<br>likes dogs and has cats            10.775765<br>has dogs                           10.328545<br>has dogs and likes cats             5.828857<br>likes dogs and dislikes cats        5.069332<br>has dogs and has cats               3.682698<br>has cats                            3.512804<br>likes cats                          2.655840<br>has dogs and dislikes cats          1.379138<br>dislikes dogs and likes cats        0.599625<br>dislikes dogs and dislikes cats     0.489694<br>dislikes cats                       0.304809<br>dislikes dogs and has cats          0.202374<br>dislikes dogs                       0.109931<br>Name: proportion, dtype: float64</pre><pre>plt.figure(figsize=(6,7))<br>sns.countplot(data=profiles, y=&quot;pets&quot;, hue=&#39;sex&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*0Nwev6MsTzPf0O3aYRWjpQ.png" /></figure><p>From the chart, Most people like dogs and cats, with more people liking dogs. Women seem to have cats at a higher rate than men, but also have more range in responses as to whether they like cats or not.</p><h4>Job Roles of Users</h4><pre>plt.figure(figsize=(6,7))<br>sns.countplot(data=profiles, y=&quot;job&quot;, hue=&#39;sex&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Uck347XJpLQR9aASAez_-g.png" /></figure><p>From the chart, we can see that there is a variety of jobs and careers, the most amount of people list their occupation as “other”. It is interesting to note the “science/tech/engineering”, “computer/hardware/software”, and “construction/craftsmanship” work is attributed to more males, and the “medicine/health”, “education/academia”, and “clerical/administrative” work is attributed to more females. There is a close to equal distribution between males and females in the “law/legal services” sector.</p><h4>Education</h4><pre>print(profiles.education.value_counts(normalize=True)*100)</pre><pre>education<br>graduated from college/university    44.936044<br>graduated from masters program       16.806707<br>working on college/university        10.713080<br>working on masters program            3.156533<br>graduated from two-year college       2.871451<br>graduated from high school            2.678270<br>graduated from ph.d program           2.385686<br>graduated from law school             2.104355<br>working on two-year college           2.014329<br>dropped out of college/university     1.866162<br>working on ph.d program               1.843655<br>college/university                    1.502307<br>graduated from space camp             1.232229<br>dropped out of space camp             0.980907<br>graduated from med school             0.836490<br>working on space camp                 0.834615<br>working on law school                 0.504520<br>two-year college                      0.416370<br>working on med school                 0.397614<br>dropped out of two-year college       0.358228<br>dropped out of masters program        0.262575<br>masters program                       0.255073<br>dropped out of ph.d program           0.238193<br>dropped out of high school            0.191305<br>high school                           0.180052<br>working on high school                0.163172<br>space camp                            0.108781<br>ph.d program                          0.048764<br>law school                            0.035635<br>dropped out of law school             0.033760<br>dropped out of med school             0.022506<br>med school                            0.020631<br>Name: proportion, dtype: float64</pre><pre>plt.figure(figsize=(6,7))<br>sns.countplot(data=profiles, y=&quot;education&quot;, hue=&#39;sex&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*RgRsxgOHaVFfajGNLecgLg.png" /></figure><p>From the chart, we can see that the majority of users are graduate from college/university, followed by masters programs and those working on college/university.</p><h4>Religion</h4><pre>profiles[&#39;religionCleaned&#39;] = profiles.religion.str.split().str.get(0)<br>profiles[&#39;religionCleaned&#39;].unique()</pre><pre>array([&#39;agnosticism&#39;, nan, &#39;atheism&#39;, &#39;christianity&#39;, &#39;other&#39;,<br>       &#39;catholicism&#39;, &#39;buddhism&#39;, &#39;judaism&#39;, &#39;hinduism&#39;, &#39;islam&#39;],<br>      dtype=object)</pre><pre>plt.figure(figsize=(6,7))<br>sns.countplot(data=profiles, y=&quot;religionCleaned&quot;, hue=&#39;sex&#39;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*fvK_pD2cNN-4atTsn2uGdg.png" /></figure><p>The religion column was cleaned to take the first word and reduce the many groups of data to a group of 9 datas. The majority of users identify as agnosticism, other, or atheists. Only a few users identify as islams.</p><h4>Lifestyle: Diet, Drinks, Drugs and Smoking Status</h4><p>We want to look at the lifestyle of both male and female users in the App</p><pre>fig = plt.subplots(2,2, figsize=(20,12))<br>plt.subplot(2, 2, 1)<br>sns.countplot(data=profiles, x=&#39;drugs&#39;, hue=&#39;sex&#39;, order=profiles[&#39;drugs&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.6)<br>plt.xlabel(&#39;Drugs Status&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>#plt.xticks(rotation=60)<br>plt.title(&#39;Drugs Status of OKCupid Users&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br><br>plt.subplot(2, 2, 2)<br>sns.countplot(data=profiles, x=&#39;smokes&#39;, hue=&#39;sex&#39;, order=profiles[&#39;smokes&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.xlabel(&#39;Smoking Status&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>#plt.xticks(rotation=60)<br>plt.title(&#39;Smoking Status of male and female users in the OKCupid App&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.subplot(2, 2, 3)<br>sns.countplot(data=profiles, x=&#39;diet&#39;, hue=&#39;sex&#39;, order=profiles[&#39;diet&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.6)<br>plt.xlabel(&#39;Diet&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>plt.xticks(rotation=90)<br>plt.title(&#39;Diet of male and female users in the OKCupid App&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.subplot(2, 2, 4)<br>sns.countplot(data=profiles, x=&#39;drinks&#39;, hue=&#39;sex&#39;, order=profiles[&#39;drinks&#39;].value_counts().index, edgecolor=&#39;black&#39;, alpha=0.5)<br>plt.xlabel(&#39;Drinking Status&#39;)<br>plt.ylabel(&#39;Count&#39;)<br>#plt.xticks(rotation=60)<br>plt.title(&#39;Drinking Status of male and female users in the OKCupid App&#39;)<br>plt.grid(axis=&#39;y&#39;, linestyle=&#39;:&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*SJMp14SY53x137poV3iiVA.png" /></figure><p>Above are charts of the lifestyle information (diet, drinks, drugs and smokes) for users. The dietary plot shows that most users eat “mostly anything”, followed by “anything”, and “strictly anything”. The drinks plot shows that the majority of the users drink “socially”, then “rarely” and “often”. For the drugs plot, the vast majority of users “never” use drugs and few users sometimes use drugs with males having the highest proportion compared to females. Similarly for smoking status the majority of users chose “no” for smoking. In all lifestyle plots, the males dominated most categories of each plot</p><h3>MACHINE LEARNING</h3><h4>DATA PREPARATION</h4><h4>Missing Data</h4><p>We will be work data imputation or removal in some missing values and getting the data ready to works with Machine Learning as Machine Learning does not handle missing data properly.</p><pre>profiles.isna().sum()</pre><pre>age                    0<br>body_type           5296<br>diet               24395<br>drinks              2985<br>drugs              14080<br>education           6628<br>essay0              5488<br>essay1              7572<br>essay2              9638<br>essay3             11476<br>essay4             10537<br>essay5             10850<br>essay6             13771<br>essay7             12451<br>essay8             19225<br>essay9             12603<br>ethnicity              0<br>height                 3<br>income             48442<br>job                 8198<br>last_online            0<br>location               0<br>offspring          35561<br>orientation            0<br>pets               19921<br>religion           20226<br>sex                    0<br>sign               11056<br>smokes              5512<br>speaks                50<br>status                 0<br>city                   0<br>state                  0<br>religionCleaned    20226<br>dtype: int64</pre><h4>PREPROCESSING</h4><p>We now choose the data to use to classify Zodiac signs and also predict a user’s zodiac signs so we can guess the missing zodiacs when we make matches.</p><p>We will keep the following variables:</p><ul><li>sign (Zodiac signs): The target variable we will be working with!</li><li>users’ statistics: sex, age</li><li>lifestyle categories: body_type, diet, drinks, drugs, smokes, job, religion.</li><li>essays: essay0, essay1, essay2, essay3, essay4, essay5, essay6, essay7, essay8, essay9</li></ul><p>We will be dropping the following variables:</p><ul><li>location: the makeup of this data is Californian</li><li>ethnicity: 90% of the users population are white</li><li>speaks: all users speak english</li><li>status: about 93% of the users are single people</li><li>education: majority of the users are graduates, so education is not a key predictor</li><li>income: 80% of the users did not fill in their income and keeping this variable in, would get rid of 20% of our data.</li><li>pets: majority of the users likes either dog or cats, so it will not be a good predictor for our target variable</li><li>height: height is not a good predictor for zodiac sign and will introduce noise to our model</li><li>offspring: majority of the users population doesn’t have kids and doesn’t want kids.</li><li>orientation: 86% of the users are straight</li></ul><p>These variables were selected because they might be a good predictor for zodiac signs. Due to the large numbers of missing datas, we will not go through any imputation method but rather we will drop the na (missing) values to create a clean and complete dataset suitable for machine learning models.</p><pre>#Define the essay columns<br>essay_cols = [&#39;essay0&#39;, &#39;essay1&#39;, &#39;essay2&#39;, &#39;essay3&#39;, &#39;essay4&#39;, &#39;essay5&#39;, &#39;essay6&#39;, &#39;essay7&#39;, &#39;essay8&#39;, &#39;essay9&#39;]<br>print(profiles[essay_cols].shape)<br>profiles[essay_cols] = profiles[essay_cols].apply(lambda col: col.str.replace(r&quot;\n&lt;br\s*/?&gt;&quot;, &quot; &quot;, regex=True))<br>profiles[essay_cols].head()</pre><pre>(59946, 10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*0S5uCBvlHM-n9zFOyXIe9Q.png" /></figure><pre>#Missing essays is not missing profile so we Keeps all rows and Empty string is safe for TF-IDF<br>profiles[essay_cols] = profiles[essay_cols].fillna(&#39;&#39;)<br>#Concatenates all essays, Preserves word order, Creates one NLP-ready text field<br>profiles[&#39;combined_essay&#39;] = profiles[essay_cols].agg(&#39; &#39;.join, axis=1)<br>#clean extra whitespace<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;\s&#39;, &#39; &#39;, regex=True).str.strip())<br>#check all list of columns<br>profiles[[&#39;essay0&#39;, &#39;essay1&#39;, &#39;essay2&#39;, &#39;essay3&#39;, &#39;essay4&#39;, &#39;essay5&#39;, &#39;essay6&#39;, &#39;essay7&#39;, &#39;essay8&#39;, &#39;essay9&#39;, &#39;combined_essay&#39;]].head()</pre><pre>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;strong&gt;&lt;em&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;/strong&gt;&lt;/em&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;em&gt;&lt;strong&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;/em&gt;&lt;/strong&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;/em&gt;&lt;/strong&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;em&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;strong&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;&lt;[^&lt;&gt;]*\&gt;&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&#39;https?://&#39;, &#39; &#39;, regex=True).str.strip())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&quot;\n&quot;, &quot;&#39;&quot;))<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.replace(r&quot;    &quot;, &quot;&quot;))<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.lower())<br>profiles[&#39;combined_essay&#39;] = (profiles[&#39;combined_essay&#39;].str.strip())<br>  <br>print(profiles[&#39;combined_essay&#39;].isna().sum())</pre><pre>0</pre><pre>cols = [&#39;sex&#39;, &#39;body_type&#39;, &#39;diet&#39;, &#39;drinks&#39;, &#39;drugs&#39;, &#39;smokes&#39;, &#39;job&#39;,&#39;religionCleaned&#39;, &#39;combined_essay&#39;, &#39;sign&#39;]<br>profiles[cols].head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*xLla5yUme4h-r8uCwSNjcA.png" /></figure><pre>cols = [&#39;age&#39;,&#39;sex&#39;, &#39;body_type&#39;, &#39;diet&#39;, &#39;drinks&#39;, &#39;drugs&#39;, &#39;smokes&#39;, &#39;job&#39;,&#39;religionCleaned&#39;, &#39;combined_essay&#39;, &#39;sign&#39;]<br>profiles_cols = profiles[cols].isna().sum()<br>print(profiles_cols)</pre><pre>age                    0<br>sex                    0<br>body_type           5296<br>diet               24395<br>drinks              2985<br>drugs              14080<br>smokes              5512<br>job                 8198<br>religionCleaned    20226<br>combined_essay         0<br>sign               11056<br>dtype: int64</pre><pre>#create a copy of the raw dataset (profiles)<br>#profiles_clean = profiles.copy()<br>df_model = profiles[cols].dropna(subset=[&#39;sign&#39;]).copy()<br>#fill all our missing features with unknown<br>df_model = df_model.fillna(&#39;unknown&#39;)<br>df_model.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*mdCGuOOqpuro5w0y8WC9QA.png" /></figure><pre>print(df_model.shape)<br>print(df_model.isna().sum())</pre><pre>(48890, 11)<br>age                0<br>sex                0<br>body_type          0<br>diet               0<br>drinks             0<br>drugs              0<br>smokes             0<br>job                0<br>religionCleaned    0<br>combined_essay     0<br>sign               0<br>dtype: int64</pre><pre>print(df_model[&#39;sign&#39;].shape)<br>print(df_model[&#39;sign&#39;].isna().sum())</pre><pre>(48890,)<br>0</pre><pre>print(df_model[&#39;sign&#39;].unique())</pre><pre>[&#39;gemini&#39; &#39;cancer&#39; &#39;pisces&#39; &#39;aquarius&#39; &#39;taurus&#39; &#39;virgo&#39; &#39;sagittarius&#39;<br> &#39;leo&#39; &#39;aries&#39; &#39;libra&#39; &#39;scorpio&#39; &#39;capricorn&#39;]</pre><pre>signCleaned = df_model[&#39;sign&#39;].dropna()<br>print(signCleaned.shape)</pre><pre>(48890,)</pre><pre>print(signCleaned.isna().sum())<br>print(signCleaned.unique())</pre><pre>0<br>[&#39;gemini&#39; &#39;cancer&#39; &#39;pisces&#39; &#39;aquarius&#39; &#39;taurus&#39; &#39;virgo&#39; &#39;sagittarius&#39;<br> &#39;leo&#39; &#39;aries&#39; &#39;libra&#39; &#39;scorpio&#39; &#39;capricorn&#39;]</pre><h4>Label Imbalance</h4><pre>df_model.sign.value_counts()</pre><pre>sign<br>leo            4374<br>gemini         4310<br>libra          4207<br>cancer         4206<br>virgo          4141<br>taurus         4140<br>scorpio        4134<br>aries          3989<br>pisces         3946<br>sagittarius    3942<br>aquarius       3928<br>capricorn      3573<br>Name: count, dtype: int64</pre><p>In the given dataset, we observe that the counts of all the zodiac signs has less difference (i.e., without large deviations). Hence, we do not have to worry about imbalances and trying to address this problem as imbalance in a response variable is bad since it means that some labels only occur a few times. This is an issue for machine learning algorithms if there are not enough data to train with which will give bad predictions.</p><h4>Feature groups</h4><pre>#Defining text, categorical, and numeric features.<br>    <br>text_feature = &#39;combined_essay&#39;</pre><pre>cat_features = [&#39;sex&#39;, &#39;body_type&#39;, &#39;diet&#39;, &#39;drinks&#39;, &#39;drugs&#39;, &#39;smokes&#39;, &#39;job&#39;,&#39;religionCleaned&#39;] #categorical features</pre><pre>num_features = [&#39;age&#39;] #numerical features</pre><h4>Train–test split</h4><p>The data is split into train and validation sets where 20% of the data is reserved for the final validation, while 80% is kept for training the model.</p><pre>X = df_model.drop(columns=[&#39;sign&#39;])<br>y = signCleaned</pre><pre>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0, stratify=y)</pre><h4>One-hot encode categorical columns</h4><pre># one hot encoding on the categorical features<br># X_cat = pd.get_dummies(X[cat_features], drop_first=False, dtype=&#39;int&#39;)</pre><pre># X_cat.head()</pre><pre>X_train_cat = pd.get_dummies(X_train[cat_features], drop_first=False, dtype=&#39;int&#39;)</pre><pre>X_test_cat = pd.get_dummies(X_test[cat_features], drop_first=False, dtype=&#39;int&#39;)</pre><pre>X_train_cat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*5Ew98IfvKjK5Mm5YVY3ZQg.png" /></figure><p>39112 rows × 83 columns</p><pre>X_test_cat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*c45Qa4VRPJg8Vce1GKBOnQ.png" /></figure><pre>print(X_train.columns.tolist())<br>print(num_features)</pre><pre>[&#39;age&#39;, &#39;sex&#39;, &#39;body_type&#39;, &#39;diet&#39;, &#39;drinks&#39;, &#39;drugs&#39;, &#39;smokes&#39;, &#39;job&#39;, &#39;religionCleaned&#39;, &#39;combined_essay&#39;]<br>[&#39;age&#39;]</pre><pre>scaler = StandardScaler()</pre><pre>X_train_num = scaler.fit_transform(X_train[num_features])<br>X_test_num  = scaler.transform(X_test[num_features])</pre><pre>tfidf = TfidfVectorizer(<br>    max_features=5000,<br>    stop_words=&#39;english&#39;<br>)</pre><pre>X_train_text = tfidf.fit_transform(X_train[text_feature])<br>X_test_text  = tfidf.transform(X_test[text_feature])</pre><pre>#Stack features<br>from scipy.sparse import hstack<br>#train final matrix<br>X_train_final = hstack([<br>    X_train_text,           # TF-IDF (sparse)<br>    X_train_cat,     # one-hot categorical<br>    X_train_num      # scaled numeric<br>])</pre><pre>#Test matrix<br>X_test_final = hstack([ X_test_text, X_test_cat, X_test_num])</pre><pre>#Check if rows must match.<br>print(X_train_final.shape, y_train.shape)<br>print(X_test_final.shape, y_test.shape)</pre><pre>(39112, 5084) (39112,)<br>(9778, 5084) (9778,)</pre><h4>Models</h4><p>For this project three common algorithms will be used to make predictions.</p><ul><li>Logistic Regression</li><li>Linear Support Vector Machine (SVM)</li><li>K-Nearest Neighbors (KNN)</li><li>Decision Tree</li><li>Random Forest</li></ul><h4>Logistic Regression</h4><p>Logistic Regression The first model is using logistic regression with multi_class=’auto’, solver=’liblinear’ as default. Using lr_model predictions are created from the training dataset which is used to figure out how well the model preformed.</p><pre>model = LogisticRegression(max_iter=1000)  # defaults: multi_class=&#39;auto&#39;, solver=&#39;liblinear&#39;</pre><pre>model.fit(X_train_final, y_train)<br>lr_predictions = model.predict(X_train_final)</pre><pre>from sklearn.metrics import accuracy_score, classification_report</pre><pre>y_pred = model.predict(X_test_final)</pre><pre>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))</pre><pre>Accuracy: 0.08488443444467171</pre><pre>print(classification_report(y_test, y_pred))</pre><pre>precision    recall  f1-score   support</pre><pre>    aquarius       0.08      0.07      0.08       786<br>       aries       0.06      0.05      0.06       798<br>      cancer       0.09      0.10      0.10       841<br>   capricorn       0.09      0.06      0.07       715<br>      gemini       0.09      0.10      0.09       862<br>         leo       0.09      0.11      0.10       875<br>       libra       0.08      0.09      0.08       841<br>      pisces       0.09      0.09      0.09       789<br> sagittarius       0.10      0.09      0.09       788<br>     scorpio       0.08      0.08      0.08       827<br>      taurus       0.09      0.08      0.09       828<br>       virgo       0.08      0.08      0.08       828</pre><pre>    accuracy                           0.08      9778<br>   macro avg       0.08      0.08      0.08      9778<br>weighted avg       0.08      0.08      0.08      9778</pre><h4>K Nearest Neighbor</h4><p>The next models is the KNeighborsClassifier.</p><pre>#metric=&#39;cosine&#39; → better for sparse TF-IDF data<br>#weights=&#39;distance&#39; → closer neighbors matter more<br>#n_neighbors=15 → reduces noise</pre><pre># Initialize KNN<br>knn = KNeighborsClassifier(<br>    n_neighbors=15,<br>    metric=&#39;cosine&#39;,<br>    weights=&#39;distance&#39;<br>)</pre><pre># Fit on TRAIN data only<br>knn.fit(X_train_final, y_train)</pre><pre># Predict on TEST data only<br>y_pred_knn = knn.predict(X_test_final)</pre><pre># Evaluate<br>knn_accuracy = accuracy_score(y_test, y_pred_knn)<br>print(&quot;KNN Accuracy:&quot;, knn_accuracy)</pre><pre>print(&quot;\nKNN Classification Report:&quot;)<br>print(classification_report(y_test, y_pred_knn))</pre><pre>KNN Accuracy: 0.0859071384741256</pre><pre>KNN Classification Report:<br>              precision    recall  f1-score   support</pre><pre>    aquarius       0.08      0.08      0.08       786<br>       aries       0.10      0.09      0.10       798<br>      cancer       0.09      0.09      0.09       841<br>   capricorn       0.07      0.06      0.07       715<br>      gemini       0.07      0.08      0.08       862<br>         leo       0.10      0.10      0.10       875<br>       libra       0.10      0.10      0.10       841<br>      pisces       0.09      0.08      0.08       789<br> sagittarius       0.08      0.07      0.07       788<br>     scorpio       0.08      0.09      0.08       827<br>      taurus       0.08      0.08      0.08       828<br>       virgo       0.09      0.10      0.10       828</pre><pre>    accuracy                           0.09      9778<br>   macro avg       0.09      0.09      0.09      9778<br>weighted avg       0.09      0.09      0.09      9778</pre><p>The knn_model had a 9% accuracy.</p><p>Below is a confusion matrix of the results with the true values on the y axis and predicted values along the x axis,</p><pre>cm = confusion_matrix(y_test, y_pred_knn)<br>knn_labels = knn.classes_</pre><pre>plt.figure(figsize=(10,7))</pre><pre>ax= plt.subplot()<br>sns.heatmap(cm, annot=True, ax = ax,fmt=&quot;d&quot;);</pre><pre># labels, title and ticks<br>ax.set_xlabel(&#39;Predicted labels&#39;);<br>ax.set_ylabel(&#39;True labels&#39;); <br>ax.set_title(&#39;Confusion Matrix&#39;);<br>ax.yaxis.set_tick_params(rotation=360)<br>ax.xaxis.set_tick_params(rotation=90)</pre><pre>ax.xaxis.set_ticklabels(knn_labels); <br>ax.yaxis.set_ticklabels(knn_labels);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*5BLatBXmcRRbXs4auI0H6Q.png" /></figure><p>In the confusion matrix, we have a very weak diagonal.These values are not dominant compared to the rest of the row.</p><p>The confusion matrix shows no dominant diagonal structure, indicating the model is unable to learn discriminative patterns for zodiac signs. Predictions are nearly uniformly distributed across classes, suggesting zodiac signs are not predictable from user profile features. Multiple models confirmed this outcome, reinforcing the conclusion that the target variable lacks a meaningful relationship with the predictors.</p><h4>Decision Trees</h4><p>The last model is the decision tree, Decision Trees do very poorly with high-dimensional sparse data unless constrained. So we must limit depth.</p><pre># Initialize Decision Tree<br>dt = DecisionTreeClassifier(<br>    max_depth=10,          # VERY IMPORTANT<br>    min_samples_split=20,<br>    min_samples_leaf=10,<br>    random_state=42<br>)</pre><pre># Fit<br>dt.fit(X_train_final, y_train)</pre><pre># Predict<br>y_pred_dt = dt.predict(X_test_final)</pre><pre># Evaluate<br>dt_accuracy = accuracy_score(y_test, y_pred_dt)<br>print(&quot;Decision Tree Accuracy:&quot;, dt_accuracy)</pre><pre>print(&quot;\nDecision Tree Classification Report:&quot;)<br>print(classification_report(y_test, y_pred_dt))</pre><pre>Decision Tree Accuracy: 0.09040703620372265</pre><pre>Decision Tree Classification Report:<br>              precision    recall  f1-score   support</pre><pre>    aquarius       0.00      0.00      0.00       786<br>       aries       0.00      0.00      0.00       798<br>      cancer       0.07      0.00      0.00       841<br>   capricorn       0.00      0.00      0.00       715<br>      gemini       0.09      0.87      0.16       862<br>         leo       0.10      0.13      0.11       875<br>       libra       0.00      0.00      0.00       841<br>      pisces       0.00      0.00      0.00       789<br> sagittarius       0.14      0.01      0.02       788<br>     scorpio       0.33      0.00      0.00       827<br>      taurus       0.06      0.00      0.00       828<br>       virgo       0.04      0.00      0.00       828</pre><pre>    accuracy                           0.09      9778<br>   macro avg       0.07      0.09      0.03      9778<br>weighted avg       0.07      0.09      0.03      9778</pre><p>Below is a confusion matrix of the results with the true values on the y axis and predicted values along the x axis, the accuracy is going to be high since those are the True Positives.</p><pre>cm = confusion_matrix(y_test, y_pred_dt)<br>dt_labels = dt.classes_</pre><pre>plt.figure(figsize=(10,7))</pre><pre>ax= plt.subplot()<br>sns.heatmap(cm, annot=True, ax = ax,fmt=&quot;d&quot;);</pre><pre># labels, title and ticks<br>ax.set_xlabel(&#39;Predicted labels&#39;);<br>ax.set_ylabel(&#39;True labels&#39;); <br>ax.set_title(&#39;Confusion Matrix&#39;);<br>ax.yaxis.set_tick_params(rotation=360)<br>ax.xaxis.set_tick_params(rotation=90)</pre><pre>ax.xaxis.set_ticklabels(dt_labels); <br>ax.yaxis.set_ticklabels(dt_labels);</pre><h4>Random Forest Model</h4><p>The next model is Random Forest model.</p><pre>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.metrics import accuracy_score, classification_report</pre><pre>#Random Forest does NOT accept sparse matrices. So we convert to dense after combining.<br># Convert final sparse matrices to dense<br>X_train_dense = X_train_final.toarray()<br>X_test_dense  = X_test_final.toarray()<br>#Train Random Forest model<br>rf_model = RandomForestClassifier(<br>    n_estimators=200,<br>    max_depth=20,<br>    min_samples_split=5,<br>    min_samples_leaf=3,<br>    random_state=42,<br>    n_jobs=-1<br>)</pre><pre>rf_model.fit(X_train_dense, y_train)</pre><pre>#Make predictions<br>rf_predictions = rf_model.predict(X_test_dense)</pre><pre>rf_accuracy = accuracy_score(y_test, rf_predictions)<br>print(f&quot;Random Forest Accuracy: {rf_accuracy:.4f}&quot;)</pre><pre>print(&quot;\nClassification Report:&quot;)<br>print(classification_report(y_test, rf_predictions))</pre><pre>Random Forest Accuracy: 0.0870</pre><pre>Classification Report:<br>              precision    recall  f1-score   support</pre><pre>    aquarius       0.08      0.01      0.01       786<br>       aries       0.03      0.00      0.01       798<br>      cancer       0.08      0.08      0.08       841<br>   capricorn       0.31      0.01      0.01       715<br>      gemini       0.09      0.27      0.13       862<br>         leo       0.09      0.42      0.15       875<br>       libra       0.08      0.08      0.08       841<br>      pisces       0.05      0.01      0.01       789<br> sagittarius       0.04      0.00      0.00       788<br>     scorpio       0.07      0.03      0.04       827<br>      taurus       0.06      0.04      0.04       828<br>       virgo       0.10      0.05      0.07       828</pre><pre>    accuracy                           0.09      9778<br>   macro avg       0.09      0.08      0.05      9778<br>weighted avg       0.09      0.09      0.06      9778</pre><p>Also got accuracy of 9% for the random forest. This shows that zodiac signs are not predictable from profile data.</p><h4>Linear SVM Model</h4><p>Finally we use the linear svm model as it (works with sparse matrices):</p><pre>from sklearn.svm import LinearSVC</pre><pre>svm_model = LinearSVC()<br>svm_model.fit(X_train_final, y_train)</pre><pre>svm_preds = svm_model.predict(X_test_final)<br>print(&quot;SVM Accuracy:&quot;, accuracy_score(y_test, svm_preds))</pre><pre>SVM Accuracy: 0.07905502147678461</pre><pre>print(&quot;\nClassification Report:&quot;)<br>print(classification_report(y_test, svm_preds))</pre><pre>Classification Report:<br>              precision    recall  f1-score   support</pre><pre>    aquarius       0.07      0.08      0.07       786<br>       aries       0.07      0.06      0.06       798<br>      cancer       0.08      0.08      0.08       841<br>   capricorn       0.07      0.06      0.07       715<br>      gemini       0.08      0.09      0.09       862<br>         leo       0.08      0.09      0.08       875<br>       libra       0.07      0.07      0.07       841<br>      pisces       0.08      0.08      0.08       789<br> sagittarius       0.08      0.08      0.08       788<br>     scorpio       0.09      0.09      0.09       827<br>      taurus       0.09      0.08      0.08       828<br>       virgo       0.08      0.08      0.08       828</pre><pre>    accuracy                           0.08      9778<br>   macro avg       0.08      0.08      0.08      9778<br>weighted avg       0.08      0.08      0.08      9778</pre><p>A Linear Support Vector Machine was trained on combined categorical, numerical, and TF-IDF text features. The model achieved approximately 8% accuracy, equivalent to random baseline performance. This further confirms the absence of a linear relationship between user profile features and zodiac signs.</p><h3>RESULTS/KEY FINDINGS</h3><p>This project investigated whether machine learning models could predict users’ zodiac signs based on lifestyle, demographic, and textual profile data from a dating app. The features included diet, age, sex, body_type, drinking habits, smoking and drug use, education, job, religion, and self-written essays processed using TF-IDF.</p><p>Multiple supervised learning models were trained and evaluated, including:</p><ul><li>Logistic Regression</li><li>K-Nearest Neighbors (KNN)</li><li>Decision Tree</li><li>Random Forest</li><li>Linear Support Vector Machine (SVM)</li></ul><p>Across all models, predictive performance consistently remained at or near random baseline accuracy (~8–9%), which corresponds to the expected accuracy when randomly guessing among 12 zodiac classes. Confusion matrices further revealed that predictions were largely scattered across classes or, in some cases, collapsed toward a single dominant class, indicating a lack of discriminative signal.</p><p>Class imbalance analysis confirmed that zodiac signs were relatively evenly distributed, ruling out imbalance as a cause of poor performance. The consistent failure of diverse model families — including linear, distance-based, tree-based, ensemble, and text-aware models — provides strong evidence that zodiac signs are not learnable from the available features.</p><h3>CONCLUSION</h3><p>User lifestyle behaviors, demographic attributes, and self-described personality text do not contain sufficient predictive information to infer zodiac signs. This result suggests that zodiac signs function as arbitrary labels rather than outcomes of observable behavioral patterns.</p><p>This negative result is scientifically valid and demonstrates rigorous application of machine learning methodology.</p><h3>NEXT STEP/ RECOMMENDATION</h3><ul><li>Reframe the Task</li></ul><p>Rather than treating this as a failed prediction problem, the project should be framed as a hypothesis-testing study:</p><p>Can lifestyle and self-described personality data predict zodiac signs? Answer: No.</p><p>This framing strengthens the analytical value of the work.</p><ul><li>Add a Baseline Model</li></ul><p>Include a DummyClassifier (most-frequent strategy) to explicitly show that all trained models perform no better than chance.</p><ul><li>Pivot to a Learnable Target</li></ul><p>Reuse the same preprocessing and modeling pipeline to predict variables that are more strongly tied to user behavior, such as: drinks, smokes, drugs, education, religionCleaned. This demonstrates that the pipeline is effective when predictive signal exists.</p><ul><li>Business Insight Application</li></ul><p>For real-world dating applications: Zodiac signs should be treated as user-declared metadata. They should not be inferred algorithmically and Matching systems should prioritize behavioral and preference-based features</p><p><a href="https://github.com/isiakpereaghogho/MACHINE_LEARNING_PORTFOLIO_PROJECT---OK_Cupid_Date_A_Scientist.git">Here</a> is the link to the github repository of this project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d77ecd90d3ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Codecademy Walkthrough Project: Life Expectancy and GDP]]></title>
            <link>https://medium.com/@aghososafe/codecademy-walkthrough-project-life-expectancy-and-gdp-b53fda32f264?source=rss-934d6da55eaa------2</link>
            <guid isPermaLink="false">https://medium.com/p/b53fda32f264</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[gdp]]></category>
            <category><![CDATA[life-expectancy]]></category>
            <category><![CDATA[codecademy]]></category>
            <category><![CDATA[data-visualization-python]]></category>
            <dc:creator><![CDATA[Aghogho ]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 16:54:21 GMT</pubDate>
            <atom:updated>2026-01-24T16:54:21.888Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a walkthrough project for the Codecademy Data Visualization portfolio project.</p><p><strong>Life expectancy</strong> and <strong>GDP</strong> (Gross Domestic Product) are two primary metrics used to assess the development and well-being of a country’s population.</p><p>By Definitions:</p><ul><li><strong>Life Expectancy:</strong> A statistical estimate of the average number of years a person is expected to live, typically measured at birth. It serves as a key indicator of overall public health, nutrition, and the quality of a country’s healthcare system.</li><li><strong>GDP (Gross Domestic Product):</strong> The total monetary value of all goods and services produced within a country’s borders over a specific period.</li><li><strong>GDP per Capita:</strong> Often used alongside life expectancy, this is the total GDP divided by the population, serving as a proxy for the average income and standard of living.</li></ul><p>This project explores the relationship between total GDP and the average life expectancy at birth for people in 6 countries — Chile (South America), China (Asia), Germany (Europe), Mexico (North America), USA (North America), and Zimbabwe (Africa). This project will analyze data on GDP and life expectancy from the World Health Organization and the World Bank to identify the relationship between the GDP and life expectancy in six countries.</p><p>There is a positive correlation between a country’s GDP per capita and its citizens’ life expectancy at birth. This means that as a country’s GDP per capita increases, life expectancy tends to increase as well.</p><p>The project will analyze, prepare, and plot data in order to answer these following questions:</p><p>Has life expectancy increased over time in the six nations? Has GDP increased over time in the six nations? Is there a correlation between GDP and life expectancy of a country? What is the average life expectancy in these nations? What is the distribution of that life expectancy?</p><p>The data given for developing the project are life expectancy at birth (years) and gross domestic product (GDP, in dollars) for some countries, taken from the World Health Organization (WHO) records.</p><p>GDP and Life expectancy Data Source: World Bank national accounts data, OECD National Accounts data files and World Health Organization</p><ul><li>The data is stored in an CSV file (all_data.csv)</li><li>The dataset provided has the following columns of data: Country — nation Year — the year for the observation Life expectancy at birth (years) — life expectancy value in years GDP — Gross Domestic Product in U.S. dollars.</li><li>There are 6 countries — Chile (South America), China (Asia), Germany (Europe), Mexico (North America), USA (North America), and Zimbabwe (Africa).</li><li>For each country, the average life expectancy at birth and total GDP is quoted for each year from 2000 to 2015 (16 entries for each country).</li><li>There are no missing data for any country.</li><li>There are 96 entries in total.</li></ul><p>The given data was analyzed and solved the following questions:</p><ul><li>Has life expectancy increased over time in the six nations?</li><li>Has GDP increased over time in the six nations?</li><li>Is there a correlation between GDP and life expectancy of a country?</li><li>What is the average life expectancy in these nations?</li><li>What is the distribution of that life expectancy?</li></ul><p>IMPORT PYTHON MODULES</p><pre>#importing python modules<br>import pandas as pd<br>import numpy as np<br>from matplotlib import pyplot as plt<br>import seaborn as sns<br>from scipy.stats import pearsonr</pre><p>LOADING THE DATA</p><pre>#loading the data(csv file)<br>WHO_data_df = pd.read_csv(&#39;all_data.csv&#39;)<br>WHO_data_df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*-QUV_KijUbGyW3KdOaR5Cg.png" /></figure><p>Checking the numbers of rows and columns<br>WHO_data_df.shape</p><pre>(96, 4)</pre><p>ANALYSIS</p><p>Descriptive Statistics</p><pre>#checking the data statistics<br>WHO_data_df.describe()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*NSPFoLUvv_QpUjwM26nqGg.png" /></figure><p>WHO_data_df.dtypes</p><pre>Country                              object<br>Year                                  int64<br>Life expectancy at birth (years)    float64<br>GDP                                 float64<br>dtype: object</pre><pre>#Checking data info and count<br>WHO_data_df.info()</pre><pre>&lt;class &#39;pandas.core.frame.DataFrame&#39;&gt;<br>RangeIndex: 96 entries, 0 to 95<br>Data columns (total 4 columns):<br> #   Column                            Non-Null Count  Dtype  <br>---  ------                            --------------  -----  <br> 0   Country                           96 non-null     object <br> 1   Year                              96 non-null     int64  <br> 2   Life expectancy at birth (years)  96 non-null     float64<br> 3   GDP                               96 non-null     float64<br>dtypes: float64(2), int64(1), object(1)<br>memory usage: 3.1+ KB</pre><pre>#Data tidying process (Renaming the Life expectany column name)<br>WHO_data_df = WHO_data_df.rename({&#39;Life expectancy at birth (years)&#39; : &#39;Life_exp&#39;}, axis = 1)<br>WHO_data_df.columns</pre><pre>Index([&#39;Country&#39;, &#39;Year&#39;, &#39;Life_exp&#39;, &#39;GDP&#39;], dtype=&#39;object&#39;)</pre><pre>#checking for unique values of the countries<br>print(WHO_data_df[&#39;Country&#39;].unique())</pre><pre>[&#39;Chile&#39; &#39;China&#39; &#39;Germany&#39; &#39;Mexico&#39; &#39;United States of America&#39; &#39;Zimbabwe&#39;]</pre><pre>#checking for unique value of year column<br>print(WHO_data_df[&#39;Year&#39;].unique())</pre><pre>[2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013<br> 2014 2015]</pre><pre>WHO_data_df.groupby(&#39;Country&#39;).size()</pre><pre>Country<br>Chile                       16<br>China                       16<br>Germany                     16<br>Mexico                      16<br>United States of America    16<br>Zimbabwe                    16<br>dtype: int64</pre><pre>WHO_data_df.groupby(&#39;Year&#39;).size()</pre><pre>Year<br>2000    6<br>2001    6<br>2002    6<br>2003    6<br>2004    6<br>2005    6<br>2006    6<br>2007    6<br>2008    6<br>2009    6<br>2010    6<br>2011    6<br>2012    6<br>2013    6<br>2014    6<br>2015    6<br>dtype: int64</pre><p>DATA VISUALIZATION</p><pre>#Pairplot to visualize pairwise relationship between variables<br>sns.pairplot(WHO_data_df, hue=&#39;Country&#39;, corner=True)<br>plt.show()<br></pre><pre>#A second pairplot without Zimbabwe shows differences between other nations.<br>sns.pairplot(WHO_data_df[WHO_data_df.Country != &#39;Zimbabwe&#39;], hue=&#39;Country&#39;, corner=True)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*MZGSdQZUX96ApiX8ahyjwA.png" /><figcaption>Pairplot to show relationship between variables (For all the countries)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*GfU-W-amqVgvHQRiuqwATA.png" /><figcaption>Pairplot for all variables excluding zimbabwe from the countries</figcaption></figure><p>AVERAGE LIFE EXPECTANCY</p><p>What is the average life expectancy in these nations?</p><pre>#Calculating the average of Life expectancy and GDP by grouping by country<br>average_data = WHO_data_df.groupby(&#39;Country&#39;)[[&#39;Life_exp&#39;,&#39;GDP&#39;]].mean().reset_index()<br>average_data</pre><p>CountryLife_expGDP0Chile78.943751.697888e+111China74.262504.957714e+122Germany79.656253.094776e+123Mexico75.718759.766506e+114United States of America78.062501.407500e+135Zimbabwe50.093759.062580e+09</p><pre>#Plotting a bar chart to show the average life expectancy for the six countries<br>plt.figure(figsize=[12,6])<br>plt.bar(average_data.Country, average_data.Life_exp)<br>plt.xlabel(&#39;Country&#39;)<br>plt.ylabel(&#39;Life Expectancy at Birth&#39;)<br>plt.title(&#39;Average Life Expectancy at Birth for the Six Countries&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*4TOzblEBlHfthc3Iq2f6Fw.png" /></figure><pre>#Barchart to show the average GDP <br>plt.figure(figsize=[12,6])<br>plt.bar(average_data.Country, average_data.GDP)<br>plt.xlabel(&#39;Country&#39;)<br>plt.ylabel(&#39;GDP&#39;)<br>plt.title(&#39;Average GDP for the Six Countries&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*NtPLUz-Y323OLTfxxB0YyA.png" /></figure><p>DISTRIBUTION OF LIFE EXPECTANCY AT BIRTH</p><p>What is the distribution of that life expectancy?</p><pre>#plotting histogram to show the distribution of the life expectancy<br>plt.figure(figsize=(8,6))<br>plt.hist(WHO_data_df.Life_exp)<br>plt.xlabel(&quot;Life Expectancy at Birth&quot;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*r7kHIl9LY8zxH8PwEb9sJQ.png" /></figure><p>The distribution of Life Expectancy at birth in the data is left skewed as most of the values are on the right-hand side. This is almost the opposite of what was observed in the GDP column.</p><p>DISTRIBUTION OF GDP</p><pre>#Plotting histogram to show the distribution of GDP<br>plt.figure(figsize=(8,6))<br>plt.hist(WHO_data_df.GDP)<br>plt.xlabel(&quot;GDP in Trillions of U.S. Dollars&quot;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*4A6b-VeVaYB1yYwF0567yg.png" /></figure><p>Above is the distribution of GDP. The distribution of GDP in the data is right skewed where most of the values are on the left-hand side.</p><p>GDP OVER TIME</p><p>Has GDP increased over time in the six nations?</p><pre>#format the GDP values to show in trillion as tn<br>WHO_data_df[&#39;GDP in trillions&#39;] = [&#39;${:.3f}tn&#39;.format(x/10**12) for x in WHO_data_df[&#39;GDP&#39;]]<br>#A table to show the GDP values of a particular country at each year<br>gdp_over_time = WHO_data_df.pivot_table(index=&quot;Country&quot;, columns=&quot;Year&quot;, values=&quot;GDP in trillions&quot;, aggfunc=&quot;sum&quot;)<br>gdp_over_time</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*zGuPSokFYUsitoLVLjqVGQ.png" /></figure><p>e plot to show the GDP of countries over time<br>plt.figure(figsize=[10, 7])<br>sns.lineplot(data=WHO_data_df, y=&#39;GDP&#39;, x=&#39;Year&#39;, hue=&#39;Country&#39;)<br><br>plt.title(&#39;GDP of Six Countries Over Time (2000–2015)&#39;)<br>plt.xlabel(&#39;Year&#39;)<br>plt.ylabel(&#39;GDP [trillion USD]&#39;)<br>plt.grid(True)<br>plt.legend(loc=&#39;upper left&#39;)<br><br>plt.show()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*QyKs1UdqRyrI_g2GlUk7zw.png" /></figure><pre>#A facetgrid chart to show each country GDP movement<br>GDP_graph = sns.FacetGrid(WHO_data_df, col=&quot;Country&quot;, col_wrap=3,<br>                      hue = &quot;Country&quot;, sharey = False)<br>GDP_graph  = (GDP_graph.map(sns.lineplot,&quot;Year&quot;,&quot;GDP&quot;)<br>         .add_legend()<br>         .set_axis_labels(&quot;Year&quot;,&quot;GDP (trillion USD)&quot;))<br>GDP_graph;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*96JoFD6qdYwaww5oaJgieQ.png" /></figure><p>LIFE EXPECTANCY OVER TIME</p><p>Has life expectancy increased over time in the six nations?</p><pre>#A pivot table to show the life expectancy value for each country at a particular year. <br>life_expectancy_over_time = WHO_data_df.pivot_table(index=&quot;Country&quot;, columns=&quot;Year&quot;, values=&quot;Life_exp&quot;, aggfunc=&quot;sum&quot;)<br>life_expectancy_over_time</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*SxfLt62PPTuSmqi1GKvQKg.png" /></figure><pre># Plot the line chart for life expectancy over time<br>plt.figure(figsize=[10, 7])<br>sns.lineplot(data=WHO_data_df, y=&#39;Life_exp&#39;, x=&#39;Year&#39;, hue=&#39;Country&#39;)<br>plt.title(&#39;Life Expectancy at Birth of Six Countries Over Time (2000–2015)&#39;)<br>plt.xlabel(&#39;Year&#39;)<br>plt.ylabel(&#39;Life Expectancy at Birth&#39;)<br>plt.grid(True)<br>plt.legend(loc=&#39;upper left&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*NllIofY7aqELOAS5ujNKXA.png" /></figure><pre>Life_exp_graph = sns.FacetGrid(WHO_data_df, col=&quot;Country&quot;, col_wrap=3,<br>                      hue = &quot;Country&quot;, sharey = False)<br>Life_exp_graph  = (Life_exp_graph.map(sns.lineplot,&quot;Year&quot;,&quot;Life_exp&quot;)<br>         .add_legend()<br>         .set_axis_labels(&quot;Year&quot;,&quot;Life expectancy at birth (years)&quot;))<br>Life_exp_graph;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*l_CXrPJXbGKpdJ1GZKPxEA.png" /></figure><p>Is there a correlation between GDP and life expectancy of a country?</p><p>CORRELATION BETWEEN GDP AND LIFE EXPECTANCY PER COUNTRY</p><pre>#Method 1: Using Pandas .corr() correlation method<br># Compute correlation for each country<br>correlations = (WHO_data_df.groupby(&quot;Country&quot;)[[&quot;GDP&quot;, &quot;Life_exp&quot;]].corr().unstack()<br>.iloc[:, 1]   # extract correlation between GDP and Life Expectancy<br>)<br>print(&quot;Correlation between GDP and Life Expectancy for each country:&quot;)<br>print(correlations)</pre><pre>Correlation between GDP and Life Expectancy for each country:<br>Country<br>Chile                       0.949877<br>China                       0.908526<br>Germany                     0.932699<br>Mexico                      0.932238<br>United States of America    0.981709<br>Zimbabwe                    0.966200<br>Name: (GDP, Life_exp), dtype: float64</pre><pre>#Method 2: Using scipy pearson correlation<br># pearsonr returns (correlation, p-value)<br>correlations = (<br>    WHO_data_df.groupby(&quot;Country&quot;).apply(lambda x: pearsonr(x[&quot;GDP&quot;], x[&quot;Life_exp&quot;]),include_groups=False)<br>)</pre><pre>print(correlations)</pre><pre>Country<br>Chile                       (0.9498766659254416, 1.8659139746585315e-08)<br>China                        (0.9085255408648358, 1.125098572070064e-06)<br>Germany                     (0.9326988982561268, 1.4018815534045922e-07)<br>Mexico                      (0.9322377167847081, 1.4686960248304982e-07)<br>United States of America     (0.9817092382430257, 1.749970926909946e-11)<br>Zimbabwe                    (0.9661998955858777, 1.2358516366846197e-09)<br>dtype: object</pre><p>SCATTERPLOT</p><pre># Scatter plot to show relationship between GDP and Life Expectancy<br>plt.figure(figsize=[8, 6])<br>sns.scatterplot(data=WHO_data_df, y=&#39;GDP&#39;, x=&#39;Life_exp&#39;, hue=&#39;Country&#39;)<br>#plt.yscale(&#39;log&#39;)<br>plt.title(&#39;Life Expectancy vs GDP&#39;)<br>plt.xlabel(&#39;Life Expectancy [years]&#39;)<br>plt.ylabel(&#39;GDP [US $]&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*URcXunKUvYXjPDeIcIhP3w.png" /></figure><pre>#Facetgrid chart to show each individual country&#39;s scatterplot<br>Life_exp_vs_GDP_graph = sns.FacetGrid(WHO_data_df, col=&quot;Country&quot;, col_wrap=3,<br>                      hue = &quot;Country&quot;, sharey = False, sharex = False)<br>Life_exp_vs_GDP_graph = (Life_exp_vs_GDP_graph.map(sns.scatterplot,&quot;Life_exp&quot;, &quot;GDP&quot;)<br>         .add_legend()<br>         .set_axis_labels(&quot;Life expectancy at birth (years)&quot;, &quot;GDP in Trillions U.S. Dollars&quot;));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*1biXB2Ux8KBatLCAJmZA8w.png" /></figure><p>RESULTS</p><ul><li>PAIRPLOTS</li></ul><p>The data visualization started by using a pairplots to visualize the relationship between the variables, it is possible to notice that:</p><p>The GDP and life expectancy values of Zimbabwe is varied in a unqiue way compared to the other countries. The downward movement between 2000–2006 for the life expectancy and downward movement between 2000–2009 for their GDP, followed by an upward movement for both GDP and life expectancy.</p><p>America and China show the same positive movement between 2000–2015. China went from less than a quarter trillion dollars to one trillion dollars in the time span.</p><p>Even if Germany has a lower GDP, its life expectancy is better than America and China GDP.</p><p>Chile is another country with a low GDP but a relatively high life expectancy. It is impressive that Chile records a better life expectancy than USA.</p><p>Mexico shows intermediate values both in term of GDP and life expectancy.</p><ul><li>HISTOGRAM</li></ul><p>Histogram is another data visualization method that was used to visualize the distribution of the GDP and also the distribution of the life expectancy. The distribution of GDP in the data is right skewed where most of the values are on the left-hand side. The distribution of Life Expectancy at birth in the data is left skewed as most of the values are on the right hand side. This is almost the opposite of what was observed in the GDP column.</p><ul><li>BAR CHART</li></ul><p>This is another visualization method that was used to visualize the average Life expectancy and the average GDP. Average life expectancy was between mid to high 70s for all countries except for Zimbabwe which was 50.</p><ul><li>FACET LINE CHARTS</li></ul><p>Another aspect of visualization looked into was the faceted line charts by Country. In the individual plots, each country has their own y axis, which makes it easier to compare the shape of their GDP over the years.</p><p>This method makes it easier to see how all countries experience growth in their life expectancy and GDP over the years. In the chart above, all of the countries did experience growth from the year 2000, the other countries had a GDP modest growth compared to China and the US. The charts also shows life expectancy over the years. The chart shows that every country has been increasing their life expectancy, but Zimbabwe has seen the greatest increase after a bit of a dip around 2004.</p><ul><li>SCATTER PLOTS</li></ul><p>The next two charts will explore the relationship between GDP and the life expectancy. In the scatterplot chart above, there seems to be a relationship between the GDP and life expectancy for all the countries through the years. The other countries seems to experience an upward movement in its life expectancy as GDP goes up. The US and China seem to have very similar slopes in their relationship between GDP and life expectancy.</p><p>-PEARSON CORRELATION</p><p>Two correlation method was used to confirm accuracy of correlation check method. The pandas .corr() correlation method and the scipy pearson correlation methods. Both methods highlights a stron and positive correlation between the two variables. GDP and life expectancy. Values of correlation close to 1 mean strong relationship, while values close to -1 indicate strong disagreement. The correlation result gave a value of 0.9 for all variables showing that there is a good relationship found between GDP and Life_Expectancy although they may be influenced by other economic factors.</p><p>CONCLUSION</p><p>This project was able to make quite a few data visualizations with the data even though there were only 96 rows and 4 columns.</p><p>No missing values</p><p>The project was also able to answer some of the questions stated in the project goals:</p><ul><li>Has life expectancy increased over time in the six nations?</li></ul><p>Yes. Zimbabwe having the greatest increase rate while other countries had modest increase rate.</p><ul><li>Has GDP increased over time in the six nations?</li></ul><p>Yes. GDP also increased for all countries in our data list.</p><ul><li>Is there a correlation between GDP and life expectancy of a country?</li></ul><p>Yes there is a strong positive correlation between GDP and life expectancy for countries listed in the data.This was tested using two correlation methods.</p><ul><li>What is the average life expectancy in these nations?</li></ul><p>Average life expectancy was between mid to high 70s for the countries except for Zimbabwe which was 50.</p><ul><li>What is the distribution of that life expectancy?</li></ul><p>The distribution of Life Expectancy at birth in the data is left skewed as most of the values are on the right hand side..</p><p>FURTHER RECOMMENDATION</p><p>The project covers 6 countries — Chile (South America), China (Asia), Germany (Europe), Mexico (North America), USA (North America), and Zimbabwe (Africa). I will recommend that, inorder to obtain more significative results we should broaden the analysis by including a wider variety of countries covering the seven continents(South America, North America, Africa, Asia, Europe, Australia and Antartica). Increasing the number of countries will really help.</p><p>Also countries should be selected from each continents according to equal size of population and other economic criteria.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b53fda32f264" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>