<?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 Carla Cotas on Medium]]></title>
        <description><![CDATA[Stories by Carla Cotas on Medium]]></description>
        <link>https://medium.com/@carlacotas?source=rss-91f8bfe0facd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fO4Txm-E6PE6FaQ8eOdztQ.jpeg</url>
            <title>Stories by Carla Cotas on Medium</title>
            <link>https://medium.com/@carlacotas?source=rss-91f8bfe0facd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:15:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carlacotas/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[How was my first Kaggle competition: from zero to submission]]></title>
            <link>https://medium.com/@carlacotas/how-was-my-first-kaggle-competition-from-zero-to-submission-be32c6abb6e3?source=rss-91f8bfe0facd------2</link>
            <guid isPermaLink="false">https://medium.com/p/be32c6abb6e3</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Carla Cotas]]></dc:creator>
            <pubDate>Thu, 06 Mar 2025 08:53:27 GMT</pubDate>
            <atom:updated>2025-03-06T08:53:27.530Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*73vFhix_S92BYK0HdPT62g.jpeg" /><figcaption>Foto de <a href="https://unsplash.com/pt-br/@anniespratt?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Annie Spratt</a> na <a href="https://unsplash.com/pt-br/fotografias/mulher-na-camisa-preta-de-manga-comprida-sentada-na-frente-do-macbook-prateado-4-4WPFLVhAY?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p><em>You know that feeling… of starting something new and spending a lot of time trying to figure out how it works.<br>Well, I recently experienced this feeling when I started using the Kaggle platform. Therefore, I leave here my experience in a Kaggle competition that can help those who are starting their journey on this platform.</em></p><h3>1. Introduction</h3><p>A few months ago, I decided to participate in Kaggle competitions to improve my data science skills and gain hands-on experience. At first, it was a challenge to start with so many competitions, datasets and discussions. But little by little I began to understand how the platform worked and I started taking small steps, setting myself a challenge — solve a competition on kaggle in 10 weeks.</p><p>In this article, I will explain the approach I used to complete my first Kaggle competition, from selecting the challenge to submitting my final model.</p><h3>2. Choosing the Right Competition</h3><p>Since I was new to Kaggle, when choosing the competition, my goal was to get hands-on with a data science problem, not to compete for leaderboard. I found some information on kaggle Discussions forum about how to choose the first competition to guide me. So, I chose the <a href="https://www.kaggle.com/competitions/llm-classification-finetuning">LLM Classification Finetuning - Finetune LLMs to Predict Human Preference using Chatbot Arena conversations</a> competition:</p><ul><li>a beginner-friendly competition</li><li>with no deadline</li><li>on a topic that interests me</li><li>it is easy to understand and well-documented</li><li>has active discussions and current notebook sharing by the community</li></ul><p><em>What helped me: filter competitions with label “Getting Started”, looking for competitions with longer deadlines, and checking the discussion forums to find important tips and information.</em></p><h3>3. Understanding the Problem Overview</h3><p>Every competition on kaggle has an <strong>Overview</strong> section with the description of the challenge, the objective and the evaluation criteria. For the competition I chose, LLM Classification Finetuning, the objective was to predict which responses users will prefer in a head-to-head battle between chatbots powered by Large Language Models, LLMs. By developing machine learning models that predict user preferences, I aimed to contribute to the challenge how chatbots interact with humans and ensure they better align with human preferences.</p><p><em>Understanding the problem overview was important because it helped me to understand whether the competition is aligned with my objectives, whether it has all the information and resources described, and what the submission and evaluation criteria are like.</em></p><h3>4. Dataset Overview</h3><p>Before starting and working on a solution in a kaggle notebook, the most important thing after understanding the challenge is to know more about the data. Also, every competition on kaggle has a <strong>Data</strong> section. For the LLM Classification Finetuning competition, the dataset was from user interactions from the <a href="https://chat.lmsys.org/">ChatBot Arena</a>. It was divided into two datasets: train and test. The train dataset included information about the prompt and the two LLMs what was given, the responses from the two LLMs, and identification of the judge’s selection which was the target. And, the test dataset included information about the prompt and the responses from two LLMs which were used to predict the target and submit to the competition.</p><p><em>Looking at the </em><strong><em>Data</em></strong><em> section in more detail than described in the </em><strong><em>Overview</em></strong><em> section was an opportunity to better understand the data I would have for this challenge and start thinking about strategies I could test, and some ideas I could consider but wouldn’t be used later given the test dataset and the challenge objective.</em></p><h3>5. Understand the Original Data</h3><p>This competition was an opportunity to start working on kaggle notebooks. As a beginner, I needed my time to find how to work on a kaggle notebook. After learning how to start a kaggle notebook for this competition, I started by understanding the original data. Getting familiar with some information about the data types, data consistency, and NaN and null counts.</p><p><em>This helped me understand the data better by completing the information given in the </em><strong><em>Data</em></strong><em> section from the challenge description. This competition provided a train dataset with 10 features, 57477 observations, text and integer data, and at a first observation without NaN and null counts.</em></p><h3>6. Data Cleaning</h3><p>After understanding the original data, I checked in detail the data consistency and if there are null or empty cells to manage this data and information. Fortunately, the data had not null or empty cells. Furthermore, there was consistency on LLMs with 64 unique LLMs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*Pzh58daJqgOgQX3UU1F9sQ.png" /><figcaption>Total number and list of unique LLMs.</figcaption></figure><p>But 5743 prompt duplicates were found. However, these duplicate prompts without having verified duplicate ids indicate that the same prompt may have been given to more than two different pair of LLMs. Therefore, I followed to the step of clean cells with text data. I converted text to lower case, removed digits and special characters using regular expressions and removed stopwords.</p><p><em>When working on this step, a rookie mistake happened: I couldn’t save my kaggle notebook, and refreshing the page didn’t save all the work. I started implementing a new work routine: download the kaggle notebook frequently because we never know when the kaggle page crashes.</em></p><h3>7. Data Exploration</h3><p>Exploratory data analysis with visualizations using matplotlib library guided me to know in more detail the data and examining it to find initial patterns and interesting points. Using bar charts, I got vizualizations about LLMs counts on ‘model a’ and ‘model b’ pairs of LLMs, and model winners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cZa_Y7hDL3BFzo0z_rcLg.png" /><figcaption>model a: LLMs value count</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dkmBcdaFPHnhD51W9BWiEQ.png" /><figcaption>model b: LLMs value count</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*mgAbZFjxFj5pqGrJeJH8Mw.png" /><figcaption>model winner counts</figcaption></figure><p>While both vizualizations of LLMs counts on ‘model a’ and ‘model b’ are similar, the data categories (x-axis) ordered in descending way of values causes some inconsistency between the two visualizations in the categories axis, without having LLMs arranged side-by-side.</p><p><em>I spent too much time on this step because I wanted to visualize the LLMs counts on ‘model a’ and ‘model b’ using subplots. However, interpreting the initial bar chart subplot carefully with additional information from the data avoided making mistakes when using subplots that impact the conclusions. At the end, just doing each bar chart separately improved reliability in presenting the work.</em></p><h3>8. Feature Engineering</h3><p>Once I had a good understanding about the data, I moved to one of the most important and critical part where text data is transformed into numerical form so it can be used in ML algorithms. So after some research and study, I used scikit-learn library in python for TF-IDF vector representation to represent text data in numerical form. Therefore, I finished by selecting the target variable, which model winner, and choosing features by combining numerical feature representations of prompt and two possible responses into a feature matrix.</p><p><em>Downloading kaggle notebook several times during the work process, avoid me from losing work due to reaching the memory limit because without indicating max_features parameter in TfidfVectorizer module, the number of features created were many and the notebook crashed!</em></p><h3>9. Model Selection, Training and Evaluation</h3><p>Based on the data and problem, and request for the Submission File, I started with a simple <strong>Logistic Regression ML model</strong>. Here, my first goal was to test a simple model and then investigate, create and test more complex models to improve performance. I used datetime library in python to calculate the execution time of some cells because I felt that some cells were taking some time to run. Thus, I got a real idea of ​​the duration of some steps. In the end, the Logistic Regression model trained was evaluated to check how it performs to estimate the winner model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*Ax2OHj3oqKYh-qUoJEtpfg.png" /><figcaption>Model evaluation - Log loss</figcaption></figure><p>Also, I spent some time looking to other metrics for model evaluation to learn and develop more critical thinking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*UN7Z7tGqVDYyDiAaxs881w.png" /><figcaption>Model evaluation additional metrics</figcaption></figure><p><em>I started using the prediction accuracy first which was always been less than 50%. This value led me to search for more information, do more tests with different parameters, and seek help on the discussion forum. Start by identifying the actual metric for the submissions evaluation can save time ensuring that no time is wasted on frustrating tests. On the other hand, starting with prediction accuracy led me to learn more and gave me valuable lessons.</em></p><h3>10. Submission</h3><p>For this LLM Classification Finetuning competition, I followed the format indicated for the submission file &#39;submission.csv’:</p><ul><li>for each id in the test set, the file should have the predicted probability for each target class</li><li>should contain a header following the format</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*_0OnQApDxF3Xltbwb4BGwA.png" /><figcaption>Submission file format</figcaption></figure><p>My first submission got a score of 1.11623 with my work starting to be on the rank on learderboard. After having the notebook submitted, I decided to review and study some concepts. I also took the opportunity to document my experience and solution in my medium article <a href="https://medium.com/@carlacotas/my-first-kaggle-competition-llm-classification-finetuning-476db368b389">My First Kaggle Competition — LLM Classification Finetuning</a>. Moreover, I decided to continue working on this challenge since the objective I set for myself in this challenge of solving a competition on kaggle in 10 weeks was achieved in fewer weeks. So, I started working on the next steps and studies indicated in my <a href="https://medium.com/@carlacotas/my-first-kaggle-competition-llm-classification-finetuning-476db368b389">medium article</a>.</p><p><em>This last step was not as linear as I expected. The first submission failed several times because it was necessary turned Internet off! Also, at the same time I was doing some kaggle courses which helped me to get used and understand the submission steps.</em></p><h3>11. Conclusion</h3><p>Kaggle competitions are a great way to improve data science skills while working with real-world datasets. Participating in kaggle competitions is an interesting learning opportunity and way to grow by gaining practical experience.</p><p>Starting my first Kaggle competition was challenging at first, but with patience, research, seeking help, and searching on Discussion forums were simple steps that helped me.</p><p>I think that if you haven’t participated in a kaggle competition yet, I highly recommend you give it a try! What helped me was to start with small steps, explore the data, and don’t be afraid to learn from community.</p><p><strong>Thank you for reading! Feel free to share your feedback, suggestions and recommendations.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be32c6abb6e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First Kaggle Competition - LLM Classification Finetuning]]></title>
            <link>https://medium.com/@carlacotas/my-first-kaggle-competition-llm-classification-finetuning-476db368b389?source=rss-91f8bfe0facd------2</link>
            <guid isPermaLink="false">https://medium.com/p/476db368b389</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[classification]]></category>
            <dc:creator><![CDATA[Carla Cotas]]></dc:creator>
            <pubDate>Mon, 06 Jan 2025 14:25:14 GMT</pubDate>
            <atom:updated>2025-01-06T14:25:14.579Z</atom:updated>
            <content:encoded><![CDATA[<p>Finetune LLMs to Predict Human Preference using Chatbot Arena conversations</p><figure><img alt="LLM Classification Finetuning" src="https://cdn-images-1.medium.com/max/1024/1*s_XJTr7Reb_cGI-IUnRgUQ.png" /></figure><p><em>Over the past month, I’ve been working on a data science challenge and completed my first Kaggle competition. I completed this Kaggle competition on a challenge I set myself, within 10 week solve a competition on Kaggle. In this article, I will share my experience while intended to develop my solution and machine learning model.</em></p><h3>Introduction</h3><p>In this competition, the challenge was to predict which responses users will prefer in a head-to-head battle between chatbots powered by large language models (LLMs). Using a dataset of conversations from the <a href="https://lmarena.ai/">Chatbot Arena</a>, where different LLMs generated answers to user prompts, I developed a winning machine learning model.</p><p><em>I thought about analyzing this competition to gain experience and knowledge in LLMs by applying it to a case with real data and to practice on a data science project.</em></p><h3>Description</h3><p>LLMs are transforming the way we interact with technology, but making sure their responses align with user expectations is crucial. This competition gave me a unique opportunity to tackle this challenge using real-world data from the Chatbot Arena — a large dataset collected from Chatbot Arena, where users chatted with two anonymous LLMs and chose the answer they prefer.</p><p>This challenge dives into concepts like “reward models” and “preference models” from reinforcement learning with human feedback (RLHF). Existing LLMs face issues such as favoring responses presented first (position bias), being overly verbose (verbosity bias), or exhibiting self-promotion (self-enhancement bias). My task was to use machine learning (ML) techniques to build a model that could effectively predict user preferences, helping creating AI systems that are more user-friendly and widely accepted AI-powered conversation systems.</p><p>My task in this competition: <strong><em>predict which response a user will prefer in these head-to-head battles.</em></strong></p><h3>Understand the original data</h3><h4>Data source</h4><p>Before getting familiar with the competition dataset, I first tried to understand the purpose of the competition and the data description provided in the Kaggle competition since we have 2 data files: ‘train.csv’, ‘test.csv’ and 1 submission file: ‘sample_submission.csv’.</p><ul><li><strong>‘train.csv’</strong> the train data includes id, model_[a/b], prompt, response from model_[a/b], and the ground truth target column winner_model_[a/b/tie]</li><li><strong>‘test.csv’</strong> the test data includes id, prompt and response from model_[a/b]</li><li><strong>‘sample_submission.csv’</strong> the submission data should include id and the ground truth target column winner_model_[a/b/tie]</li></ul><p>License: <a href="https://creativecommons.org/licenses/by-nc/4.0/">Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)</a></p><h4>Data Preparation</h4><p>The train and test dataset are available as .CSV data files. The first analysis was made working with the train datset. And, only after this first analysis I moved on to the final step which was to make predictions based on the test set.</p><p><em>Please note that I will describe a summary of my work building the ML model. You can check out the full script and results on my </em><a href="https://www.kaggle.com/code/carlacotas/llm-classification-finetuning"><em>Kaggle notebook</em></a><em> (Python 3 environment). Moreover, this is my first ML model for this competition before checking out the discussion forum to find insights from other competitors to improve Score.</em></p><p>The following libraries were used:<br>- ‘numpy’ for working with arrays<br>- ‘pandas’ for data processing<br>- ‘matplotlib’ for data visualizations<br>- ‘re’ for regular expression operations<br>- ‘string’ for simplifies working with strings<br>- ‘nltk’ for Natural Language Toolkit<br>- ‘sklearn’ for feature emgineering and ML modeling<br>- ‘datetime’ for date manipulation</p><p>The first thing I did was to import the raw data.</p><pre># import the data<br>training = pd.read_csv(&#39;/kaggle/input/llm-classification-finetuning/train.csv&#39;)<br>test = pd.read_csv(&#39;/kaggle/input/llm-classification-finetuning/test.csv&#39;)<br><br>training[&#39;train_test&#39;] = 1<br>test[&#39;train_test&#39;] = 0<br>all_data = pd.concat([training,test])<br><br>print(&quot;Import Data Complete&quot;)</pre><p>Then I looked at the dataset to get familiar very quickly with data and understand the data types, data consistency, null counts and the next steps needed to ensure data free of errors:</p><ul><li>There are consistency on data, proper data types and no null counts</li></ul><p>Next, I tried to understand a little more about the data:</p><pre>training.head(10)<br>training.tail(10)</pre><p>Even if no data inconsistency and null values ​​were observed in this step, looking at the data from the first ten and last observations, it should be ensured that we do not have duplicate data and that we deal with text data properly.</p><p><em>I completed this step during my first week working on this 10 week challenge. Even if it is an initial and simple step, it took me some time to complete it due to unfamiliarity with the platform. So, it initially took me some time to understand how the platform worked and how to start working on the competition. A great initial help was using the Kaggle discussion forums to learn from the community!</em></p><h3>Data Cleaning</h3><p>In this step, after I get familiar with data and understand the data types, I looked deeper at data consistency, null counts or empty cells to think about how to manage that data/information.</p><ul><li>There are no <em>id </em>duplicates</li><li>There are no NaN values and null values</li><li>There are consistency on the number of LLMs in model a and model b: total of 64 LLMs</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*apL6tO1LdhzyYDx3GTXJBw.png" /><figcaption>LLMs identification</figcaption></figure><ul><li>There are 5 743 prompt duplicates in 57 477 observations. There is no need for additional cleaning because there are no id duplicates, and the same promt can be given to different combinations of model a and model b</li></ul><p>Now, the data was ready to move to the next clean step, clean raw text data in columns <em>prompt</em>, response <em>a</em> and response <em>b</em>. After some research about cleaning text data and looking to some learning materials from previous courses, I managed to convert text to lower case, remove digits and special characters using regular expressions and remove stopwords.</p><pre>#clean cells with text data<br>def preprocess_text(text):<br>    #convert text to lower case<br>    text = text.lower()<br>    #remove digits and special characters using regular expressions<br>    text = re.sub(r&#39;\d+&#39;, &#39;&#39;, text)<br>    text = re.sub(r&#39;[^\w\s]&#39;, &#39;&#39;, text)<br>    #tokenize the text<br>    text = nltk.word_tokenize(text)<br>    <br>    return text<br><br>def remove_stopwords(text):<br>    #remove stopwords<br>    stop_words = set(stopwords.words(&#39;english&#39;))<br>    text_no_stopwords = [word for word in text if word not in stop_words]<br><br>    return text_no_stopwords<br><br><br>def lemmatization(text):<br>    lemmatizer = nltk.WordNetLemmatizer()<br>    lemmatizer_text = [lemmatizer.lemmatize(text) for text in text]<br><br>    return lemmatizer_text<br><br><br>def clean_text(text):<br>    #convert text to lower case, remove digits and special characters using regular expressions and remove stopwords combined together<br>    text = preprocess_text(text)<br>    filtered_text = remove_stopwords(text)<br>    lemmatizer_text = lemmatization(filtered_text)<br>    clean_text = &#39; &#39;.join(lemmatizer_text)<br><br>    return clean_text<br><br>training[&quot;prompt&quot;] = training[&quot;prompt&quot;].apply(clean_text)<br>training[&quot;response_a&quot;] = training[&quot;response_a&quot;].apply(clean_text)<br>training[&quot;response_b&quot;] = training[&quot;response_b&quot;].apply(clean_text)<br><br><br>print(&quot;Clean Cells with Text Data Complete&quot;)</pre><p>And, now the data can move on to the next steps.</p><h3>Data Exploration</h3><p>The next thing I did was to get to know data more detailed and examining it to find initial patterns and interesting points.</p><ul><li>Total number of LLMs — model a</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cZa_Y7hDL3BFzo0z_rcLg.png" /><figcaption>LLMs — model a</figcaption></figure><ul><li>Total number of LLMs — model b</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dkmBcdaFPHnhD51W9BWiEQ.png" /><figcaption>LLMs — model b</figcaption></figure><ul><li>Total number of model winner</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*mgAbZFjxFj5pqGrJeJH8Mw.png" /><figcaption>LLMs — model winner</figcaption></figure><p><strong>Key findings:</strong></p><ul><li>Looks like that there are some LLMs that are most recurrent and some that are less recurrent</li><li>There are no special pattern on the model winner</li></ul><p><em>The LLMs are not included on the test data, and I decided to not follow further on interpreting and investigating the LLMs in more detail.</em></p><p>After Data Cleaning and Data Exploration, I did some research about the next step when dealing with text data and ML models. And, I found that ML models can’t work with text directly and it is essential to ensure that the text data is in a proper format for ML.</p><p><em>I completed Data Cleaning and Data Exploration steps during my second and third week working on this 10 week challenge. During second week, I had to redo some work because I couldn’t save my kaggle notebook and refreshing the page didn’t save all the work. I learned that a good strategy on kaggle is to download kaggle notebook frequently because we never know when the kaggle page crashes. Furthermore, it was two weeks with some time dedicated to carried out several experiments to visualize the data using Matplotlib library in python. I tried to plot two bar chart in the same figure, but interpreting the result carefully with additional information from the data avoided making mistakes when using subplots that impact the conclusions and, in the end, I finished doing each bar chart separately.</em></p><h3>Feature Engineering</h3><p>After cleaning the raw data and understanding it more cleary, the next step was extracting meaningful information from the text data to make it usable for ML models. I used the text representation approach, basic vectorization - TF-IDF, to convert the text data to a matrix of TF-IDF features. This approach seemed appropriate because it measures the number of times a term occurs, takes into account that very frequent terms (e.g. “the”, “a”, “is”) would obscure the frequencies of rarer but more interesting terms, and convert the text data into numerical format.</p><pre>#transform text data into numerical form<br>from sklearn.feature_extraction.text import TfidfVectorizer<br><br>vectorizer = TfidfVectorizer(max_features = 150) #without max_features it crashes due to memory limit<br>vectorizer_prompt = vectorizer.fit_transform(training[&quot;prompt&quot;])<br>print(vectorizer.idf_)<br>print(vectorizer.get_feature_names_out())<br>vectorizer_response_a = vectorizer.fit_transform(training[&quot;response_a&quot;])<br>print(vectorizer.idf_)<br>print(vectorizer.get_feature_names_out())<br>vectorizer_response_b = vectorizer.fit_transform(training[&quot;response_b&quot;])<br>print(vectorizer.idf_)<br>print(vectorizer.get_feature_names_out())<br><br><br><br>temp_prompt = vectorizer.transform(training[&quot;prompt&quot;])<br>temp_response_a = vectorizer.fit_transform(training[&quot;response_a&quot;])<br>temp_response_b = vectorizer.fit_transform(training[&quot;response_b&quot;])<br><br>print(&quot;vectorizer representation for &#39;prompt&#39;:\n&quot;, temp_prompt.toarray())<br>print(&quot;vectorizer representation for &#39;response a&#39;:\n&quot;, temp_response_a.toarray())<br>print(&quot;vectorizer representation for &#39;response b&#39;:\n&quot;, temp_response_b.toarray())<br><br>print(&quot;Number of elements for the vectorizer representation for &#39;prompt&#39;:\n&quot;, temp_prompt.shape)<br>print(&quot;Number of elements for the vectorizer representation for &#39;response a&#39;:\n&quot;, temp_response_a.shape)<br>print(&quot;Number of elements for the vectorizer representation for &#39;response b&#39;:\n&quot;, temp_response_b.shape)</pre><p>Next, I selected the prediction target and features.</p><pre>#selecting the prediction target<br>train_y = training[&quot;winner&quot;].values<br><br>#choosing &quot;features&quot;<br>train_X = np.concatenate((temp_prompt.toarray(), temp_response_a.toarray(), temp_response_b.toarray()), axis=1)<br><br>print(&quot;Selecting The Prediction Target and Choosing Features Complete&quot;)</pre><p>Now, the prediction target and features were selected and could be used for the ML model.</p><p><em>I completed this step during my fourth week working on this 10 week challenge. It was a challenging week as I was dealing with text data and a lot of learning. Furthermore, downloading kaggle notebook several times during the work process, avoid me from losing work due to reaching the memory limit because without indicating max_features parameter in TfidfVectorizer module, the number of features created were many and the notebook crashed.</em></p><h3>Model Selection and Training</h3><p>The next step was the model selection and predictions. I used <strong>Logistic Regression</strong> to predict the outcome of the winner model having as input features - <em>temp_prompt</em>, <em>temp_response_a</em> and <em>temp_response_b - </em>concatenated and, corresponding labels - <em>winner</em> (0 for winner model a, 1 for winner model b, and 2 for winner tie). Moreover, Logistic Regression predicts the probability for each target class as requested for the Submission File.</p><pre>#use Logistic Regression<br>from sklearn.linear_model import LogisticRegression<br>from datetime import datetime<br><br>#record start time to calculate the execution time<br>start = datetime.now()<br><br>#Logistic Regression<br>model = LogisticRegression(max_iter=500, multi_class=&#39;multinomial&#39;, solver=&#39;saga&#39;) #For large datasets the “saga” solver is usually faster [scikit-learn documentation]<br>model.fit(train_X, train_y)<br><br>#record end time<br>end = datetime.now()<br> <br>#calculate the execution time<br>execution_time = (end - start).total_seconds() / 60<br>print(f&quot;The time of execution is: {execution_time} minutes&quot;)<br><br><br>print(&quot;Model Training Complete&quot;)</pre><p>Now, that the model was trained it could be evaluated.</p><h3>Model Evaluation</h3><p>In this step, the Logistic Regression model trained was evaluated to check how it performed to estimate the winner model (model a, model b or winner tie).</p><pre>from sklearn.model_selection import train_test_split<br>from sklearn.metrics import confusion_matrix, precision_score, recall_score<br><br>#split into validation and training data<br>train_X_train, train_X_val, train_y_train, train_y_val = train_test_split(train_X, train_y, test_size=0.2, random_state=42)<br><br>#record start time to calculate the execution time<br>start = datetime.now()<br><br>#think about results - comparing predictions (value_y_predict) to the actual winner model (train_y_val)<br>value_y_predict = model.predict(train_X_val)<br>print(&#39;Model winner prediction&#39;, value_y_predict)<br>print(&#39;Model winner real value&#39;, train_y_val)<br><br>value_y_probabilities = model.predict_proba(train_X_val)<br>print(&#39;Model winner prediction, probability&#39;, value_y_probabilities) #winner model a | winner model b | winner tie<br><br>#confusion matrix<br>cm = confusion_matrix(train_y_val, value_y_predict)<br>print(&quot;Confusion Matrix:\n&quot;, cm)<br><br>#model accuracy<br>score = model.score(train_X_val, train_y_val)<br>print(&#39;Model Accuracy Score&#39;, score)<br><br>#macro and micro averaged Precision and Recall<br>macro_precision = precision_score(train_y_val, value_y_predict, average=&#39;macro&#39;) #calculate precision for all classes individually and then average them<br>macro_recall = recall_score(train_y_val, value_y_predict, average=&#39;macro&#39;)<br>micro_precision = precision_score(train_y_val, value_y_predict, average=&#39;micro&#39;) #calculate class wise true positive and false positive and then use that to calculate overall precision<br>micro_recall = recall_score(train_y_val, value_y_predict, average=&#39;micro&#39;)<br>print(&quot;Macro Precision:&quot;, macro_precision)<br>print(&quot;Macro Recall:&quot;, macro_recall)<br>print(&quot;Micro Precision:&quot;, micro_precision)<br>print(&quot;Micro Recall:&quot;, micro_recall)<br><br>#record end time<br>end = datetime.now()<br> <br>#calculate the execution time<br>execution_time = (end - start).total_seconds()<br>print(f&quot;The time of execution is: {execution_time} seconds&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*tfK88ZWyVj2Qrezf75RUrg.png" /></figure><pre>#model log loss - https://www.kaggle.com/competitions/llm-classification-finetuning/discussion/552103<br>from sklearn.metrics import log_loss<br><br>model_log_loss = log_loss(train_y_val, value_y_probabilities)<br><br>print(&#39;Model Log loss:&#39;, model_log_loss) <br><br># Number of classes = 3 : Logloss = - log(1/3) = 1.10<br># Model Log loss: 1.05, model prediction is considered good for this project</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*X6HfcR1n5Fw_UY2wnUik3Q.png" /></figure><p>Now, that the ML model was created, the submission could be prepared.</p><h3>Submission File</h3><p>The last step was to generate a .CSV file with model predictions on test data to submit to the competition.</p><pre>#model prediction<br>test_X = np.concatenate((temp_test_prompt.toarray(), temp_test_response_a.toarray(), temp_test_response_b.toarray()), axis=1)<br>value_test_y_probabilities = model.predict_proba(test_X)<br>print(&#39;Model winner prediction, probability&#39;, value_test_y_probabilities) #winner model a | winner model b | winner tie</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*iBNsy-btmIk8MWwL_lOYDA.png" /></figure><pre>output = pd.DataFrame({&#39;id&#39;: test.id,<br>                        &#39;winner_model_a&#39;: value_test_y_probabilities[:, 0],<br>                        &#39;winner_model_b&#39;: value_test_y_probabilities[:, 1],<br>                        &#39;winner_tie&#39;: value_test_y_probabilities[:, 2]})<br>output.to_csv(&#39;submission.csv&#39;, index=False)</pre><p>Even though my first submission didn’t have a very interesting score ( submission scored 1.11623), the whole process from choosing the contest to submission taught me a lot and led me to work on concrete objectives towards the big goal: solve a competition on kaggle in 10 weeks.</p><p><em>I completed Model Selection and Training, Model Evaluation and Submisison File steps during my fifth and sixth week working on this 10 week challenge. Some cells were taking some time to run, and to have an idea about the duration of some steps, I used ‘datetime’ library in python to calculate the execution time of cells. Also, for the evaluation of the Logistic Regression model, I used the prediction accuracy which was always been less than 50%. This value led me to search for more information, do more tests with different parameters, and seek help on the competition discussion forum. I ended-up focusing on the log loss metric.</em></p><h3><strong>Key findings</strong></h3><p>From this study:</p><ul><li>Working with text data requires pre-processing and feature engineering to extract features from clean data and have data ready for ML models</li><li>Python library ‘sklearn’ is very useful when dealing with text data</li><li>When the prediction target has more than two labels, Multiclass Logistic Regression model is a good option for the ML model</li></ul><p>From the challenges encountered:</p><ul><li>Seeking help on the competition discussion forum is important and valuable</li><li>Downloading the notebook from time to time can save a lot of time in case of notebook crashes</li><li>There are good visualizations that can be made with the data, but more advanced visualizations may not be simple to obtain</li><li>Understanding the parameters in the TF-IDF and Logistic Regression model gives us an idea of ​​how to change them to achieve solver convergence and solve error messages</li><li>Submitting the notebook may not be as linear a task as initially thought</li></ul><p>Further tests and studies:</p><ul><li>Learning more about other ML models that can be referenced in the competition discussion forum</li><li>Looking for similar Kaggle competitions to get ideas to try next</li><li>Understanding if small changes on the pre-processing and feature engineering steps can have a significant impact on ML model predictions</li></ul><p><em>Even if my first submission to this Kaggle competition entered the leaderboard at a much lower rank number, working on the first version of this notebook was very rewarding for everything I learned and tested.</em></p><p><strong>Thank you for reading! Feel free to share your feedback, suggestions and recommendations.</strong></p><h4>Links to code:</h4><p>Kaggle Code:<strong> </strong><a href="https://www.kaggle.com/code/carlacotas/llm-classification-finetuning">Kaggle</a></p><p>GitHub repo: <a href="https://github.com/carlacotas/llm-classification-finetuning">GitHub</a></p><h4>Resources:</h4><p><strong>Introduction</strong> and <strong>Descrition</strong> was inspired by the competition description provided on <a href="https://www.kaggle.com/competitions/llm-classification-finetuning">Kaggle</a>:</p><p>Wei-lin Chiang, Lianmin Zheng, Lisa Dunlap, Joseph E. Gonzalez, Ion Stoica, Paul Mooney, Sohier Dane, Addison Howard, and Nate Keating. LLM Classification Finetuning. <a href="https://kaggle.com/competitions/llm-classification-finetuning">https://kaggle.com/competitions/llm-classification-finetuning</a>, 2024. Kaggle</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=476db368b389" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Data Analytics Course - Capstone Project]]></title>
            <link>https://medium.com/@carlacotas/google-data-analytics-course-capstone-project-63908a154087?source=rss-91f8bfe0facd------2</link>
            <guid isPermaLink="false">https://medium.com/p/63908a154087</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[r-programming]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Carla Cotas]]></dc:creator>
            <pubDate>Mon, 23 Dec 2024 11:23:12 GMT</pubDate>
            <atom:updated>2024-12-23T11:23:12.424Z</atom:updated>
            <content:encoded><![CDATA[<h3>Case study: How does a bike-share navigate speedy success?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iCsNbUpsU8XZXXzD" /><figcaption>Photo by <a href="https://unsplash.com/@myers2021?utm_source=medium&amp;utm_medium=referral">Michael Myers</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Over the past few months, I have studied data analytics through the Google Data Analytics Professional Certificate program offered by Google on Coursera. I completed this Google Career Certificate working on a capstone project. In this article, I will share my work while intended to perform real-world tasks as a junior data analyst for a fictional company, Cyclistic.</em></p><h3>Introduction</h3><p>In this case study, I performed real-world tasks as a junior data analyst for a fictional company, Cyclistic, working in the marketing analytics team. In order to answer the business questions, I followed the steps of the data analysis process: Ask, Prepare, Process, Analyse, Share and Act.</p><h3>Background and Business Question</h3><h4><strong>Cyclistic</strong></h4><p>Cyclistic, a leading bike-share company in Chicago, has been transforming urban mobility since its launch in 2016. With a fleet of 5,824 bicycles and 692 stations across the city, Cyclistic offers the riders the convenience of unlocking a bike at one station and returning it to any other station in the system anytime. Beyond traditional bikes, the program stands out for its inclusivity, offering reclining bikes, hand tricycles, and cargo bikes, making bike-share more inclusive to people with disabilities and riders who can’t use a standard two-wheeled bike. While most users choose standard bikes, about 8% rely on these assistive models, making Cyclistic a versatile solution for diverse mobility needs.</p><p>Cyclistic attracts a wide range of customers through its flexible pricing plans, offering single-ride passes, full-day passes, and annual memberships. Casual riders, those who opt for single-ride or day passes, are more likely to ride for leisure, while approximately 30% of all rides are to commute to work each day. However, finance analysts have found that annual members are significantly more profitable than casual riders. Rather than creating a campaign to attract entirely new customers, the marketing director sees a strong opportunity to convert casual riders, who are already aware of the Cyclistic program and have chosen Cyclistic for their mobility needs, into loyal annual members. Recognizing this, Cyclistic’s marketing team is focusing toward converting casual riders into annual members.</p><h4><strong>Characters and teams</strong></h4><ul><li><strong>Cyclistic marketing analytics team: </strong>A team of data analysts who are responsible for collecting, analyzing, and reporting data that helps guide Cyclistic marketing strategy.</li><li><strong>Cyclistic executive team: </strong>The notoriously detail-oriented executive team.</li><li><strong>Lily Moreno:</strong> The director of marketing and the manager of my team. Moreno is responsible for the development of campaigns and initiatives to promote the bike-share program. These may include email, social media, and other channels. She believes the company’s future success depends on maximizing the number of annual memberships.</li><li><strong>Carla Cotas:</strong> A junior data analyst working in the marketing analytics team. My team wants to understand how casual riders and annual members use Cyclistic bikes differently. From these insights, my team will design a new marketing strategy to convert casual riders into annual members. But first, Cyclistic executives must approve the recommendations, so they must be backed up with compelling data insights and professional data visualizations.</li></ul><h4><strong>Scenario</strong></h4><p><strong>Moreno has set a clear goal:</strong> Design marketing strategies aimed at converting casual riders into annual members.</p><p><em>In order to do that, however, my team needs to better understand how annual members and casual riders differ, why casual riders would buy a membership, and how digital media could affect their marketing tactics. Therefore, Moreno and her team are interested in analyzing the Cyclistic historical bike trip data to identify trends.</em></p><h3>Ask</h3><h4>Analysis Questions</h4><p>Three questions will guide the future marketing program:</p><ol><li>How do annual members and casual riders use Cyclistic bikes differently?</li><li>Why would casual riders buy Cyclistic annual memberships?</li><li>How can Cyclistic use digital media to influence casual riders to become members?</li></ol><p>The first question to answer was assigned to me: <strong><em>How do annual members and casual riders use Cyclistic bikes differently?</em></strong></p><h3>Prepare</h3><p>In this step, data is collected and organized from different data sources relevant to the question under analysis and assigned to me.</p><h4>Data source</h4><p>Cyclistic’s historical trip data to analyze and identify trends was available <a href="https://divvy-tripdata.s3.amazonaws.com/index.html">here</a>.</p><p><em>The data has been made available by Motivate International Inc. under this </em><a href="https://divvybikes.com/data-license-agreement"><em>license</em></a><em>. This is public data that can use to explore how different customer types are using Cyclistic bikes. But note that data-privacy issues prohibit from using riders’ personally identifiable information. This means that you won’t be able to connect pass purchases to credit card numbers to determine if casual riders live in the Cyclistic service area or if they have purchased multiple single passes.</em></p><h4>Data Preparation</h4><p>The Cyclistic’s historical trip data are available to download in zip files. After downloaded and stored in a folder, the zip files were unzipped locally giving the original .CSV data files. This study uses <a href="https://posit.co/download/rstudio-desktop/">Posit’s RStudio — free version</a> for the analysis because it is a powerful tool for performing statistical analyses and data visualizations.</p><p><em>Please note that I will describe a summary of my solution. You can check out the full scripts and results on my project repo on </em><a href="https://github.com/carlacotas/google-data-analytics-capstone-case-study-trackA-cyclistic"><em>GitHub</em></a><em>. Due to Posit’s RStudio Memory Usage limit on the free version, there is more than one script on my project repo.</em></p><p>The following libraries were used: <br>- ‘tidyverse’ for data import and tidying<br>- ‘dplyr’ for data cleaning and manipulation<br>- ‘lubridate’ for date manipulation<br>- ‘hms’ for time manipulation<br>- ‘DescTools’ for mode calculation<br>- ‘ggplot2’ for data visualizations</p><p>The original data files, naming convention of Divvy_Trips_YYYY_(Q1/Q4), were loaded into Posit’s RStudio and renamed for simplicity and improve readability.</p><pre>CyclisticTripData_2019_Q4 &lt;- read.csv(&quot;Divvy_Trips_2019_Q4.csv&quot;)<br>CyclisticTripData_2020_Q1 &lt;- read.csv(&quot;Divvy_Trips_2020_Q1.csv&quot;)</pre><p>The variables Divvy_Trips_YYYY_(Q1/Q4) were assigned and were added automatically to the environment which allowed to verify that:</p><ul><li>there is an inconsistency in the column numbers: 2020, Q1 has 13 columns; 2019, Q4 only has 12 columns</li><li>the number of observations/rows is different every Quarter</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*lMZCwLiC7cTziDIcCdcPew.png" /><figcaption>variables listed in the current environment</figcaption></figure><p>A check summary data was performed for exploring the inconsistency in the column numbers to ensure the same number of columns and the same column names before moving to the step of merging them in only one data set.</p><ul><li><strong>CyclisticTripData_2019_Q4</strong> The summary data includes trip id, started and ended time, bike id, trip duration, start and end station — name and id, user type, gender and birthyear.</li><li><strong>CyclisticTripData_2020_Q1</strong> The summary data includes ride id, rideable type, started and ended time, start and end station — name, id, latitude and longitude, and member type.</li><li>And, in a very exploratory analysis, there are some datatype inconsistencies.</li></ul><p>The data can be trusted, it is published in a trustworthiness source and it is aligned with the question that was assigned to me. However, all ride ids are unique and due to data privacy prohibiting using rider’s personally identifiable information, it will not be possible to determine if riders have purchased multiple single passes. Moreover, the problems with data identified lead to the need to process the data and clean it for analysis.</p><p><strong>Note:</strong> <em>I tried to complete this project using the data from previous 12 months (November 2023 to October2024) but I’ve been limited to manage renaming the original data files in Posit’s RStudio and when renaiming 7 files, Posit’s RStudio crashes. So I decided to complete this project focusing the first previous 6 months: November 2023 to April 2024 because Posit’s RStudio does not crashes due to Memory Usage. However, when merging data in the Process, Posit’s RStudio crashes! So, following the tip from the Case Study Roadmap for the Data Process, I use the data from October 2019 to March 2020.</em></p><h3>Process</h3><p>In this step, the two datasets are combined into one dataset, clean it and manipulat it.</p><h4>Data cleaning</h4><p>Before combining the tow datasets (‘CyclisticTripData_2019_Q4’ and ‘CyclisticTripData_2020_Q1’) into one dataset (‘CyclisticTripData’), the inconsistency in column names in each dataframe was addressed by renaming the columns to ensure uniformity. The column names were renamed considering the most recent naming convention -CyclisticTripData_2020_Q1.</p><p>Now that the column names are the same, the data type of the <em>ride_id</em> and <em>rideable_type</em> columns have been corrected to be uniform to match both dataframes. And, the two dataframes can be combined into only one dataframe for analyzing 6 months of data.</p><p>Then the large dataframe was verified to check very quickly uniformities and to get a better data sensitivity.</p><pre>colnames(CyclisticTripData)<br>glimpse(CyclisticTripData)<br>head(CyclisticTripData)<br>tail(CyclisticTripData)</pre><p>From looking at the output information, the columns <em>start_lat</em>, <em>start_lng</em>, <em>end_lat</em> and <em>end_lng</em> could be removed because that data were collected only at ‘CyclisticTripData_2020_Q1’. Also, the columns <em>birthyear</em> and <em>gender</em> can be removed because that data were collected only at ‘CyclisticTripData_2019_Q4’.</p><p>Now, the large dataframe was ready to check if the data was clean, free of errors and check if data modification was needed.</p><h4>Data manipulation</h4><p>A closer look at data was taken to check for duplicates, null values, and inconsistency on values that needed to be cleaned:</p><ul><li>There are no <em>ride_id</em> duplicates</li><li>There are 426 888 missing values (426 887 in ‘tripduration’, 1 in ‘end_station_id’)</li><li>The 426 887 missing values in ‘tripduration’ are due to this column data collected only at ‘CyclisticTripData_2020_Q1’</li><li>The column ‘tripduration’ can be removed. Now the data has 1 missing value</li><li>There are “Subscriber”, ”Customer”, ”member” and “casual” at <em>member_casual</em> column. This fact is due to the different member type values between ‘CyclisticTripData_2019_Q4’ and ‘CyclisticTripData_2020_Q1’. The information that we have is that: Customers are identified as casual riders (“causal”) and Cyclistic members (“members”). So, to ensure consistency on data: “Subscriber” was considered a Cyclistic member and “Customer” was the same as casual rider.</li><li>There are no consistency on values of column <em>rideable_type</em> due to the same fact presented in the previous point, values change between ‘CyclisticTripData_2019_Q4’ and ‘CyclisticTripData_2020_Q1’. However, with the information available and without further information we can’t address this data inconsistency. So, for the purposes of this study, it was decided to remove this column.</li><li>There are consistency on characters length on columns <em>started_at</em>, <em>ended_at</em> and <em>member_casual.</em></li></ul><p>Now, the data was already ready to the transform and calculation steps to know the ride length and day of week.</p><p>New columns <em>ride_length</em> and <em>day_of_week</em> were created to calculate (1) the length of each ride by subtracting the column <em>started_at</em> from the column <em>ended_at</em> and (2) the day of the week that each ride started, respectivelly. Both columns <em>started_at</em> and <em>ended_at</em> have the start and end time in the format YYYY-MM-DD hh:mm:ss. And, a closer look at data in the new columns was taken to check for consistency and meaning on values.</p><ul><li>There are consistency on the the day of the week that each ride started, with unique values corresponding to the names of the days of the week</li><li>There are at least one negative value on ride length. And, at least one value that is higher than one day (circa 109 days) and less than the total number of days corresponding to this analsysis</li><li>There are 222 observations with negative ride length or equal to 00:00:00</li><li>At the end, the data ready for analysis has 1 130 718 observations</li></ul><p><em>For the purposes of this study and to learn objectives, the data was already ready for the Analyze step; however, the original data ‘CyclisticTripData_2020_Q1’ includes columns with latitude and longitude for the start and end stations. An additional step on data manipulation was tried to calculate the ride length if possible with the start and end stations information (latitude and longitude) from the first quarter of 2020 to complete the ‘CyclisticTripData’ dataframe. However,</em></p><ul><li><em>There are no consistency on the start and end station names on both dataframes: fisrt quarter of 2020 — unique start station names: 607, unique end station names: 603 large dataframe — unique start station names: 613, unique end station names: 611</em></li><li><em>Without further information about all the stations latitude and longitude we cannot guarantee consistency on ride length calculations for all observations</em></li><li><em>At the end, the data ready for analysis has 1 130 718 observations and 10 features</em></li></ul><h3>Analyze</h3><p>After the data is prepared, processed, and stored appropriately, it is ready for analyze it. The main objective in this step was to find trends or relationships in the data. And, find how the insights could help answer the question assigned to me. This step included conducting descriptive analysis and identifying trends and relationships.</p><ul><li>The data includes ride id, started and ended time, start and end station -name and id, member type, ride length and day of week</li><li>The ride length was corrected to be on the proper format for descriptive analysis. Also, an additional format transform was done, to guarantee that start and end station — id had the correct format.</li></ul><h4>Descriptive analysis</h4><p>Important metrics such as mean and maximum for the ride length were calculated for each member type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*5gTDq-UX5Nlf_vKmPuGHyA.png" /><figcaption>Mean, median and maximum ride length by member type</figcaption></figure><p>Next, the mode of day of week was also calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*efWhMRg7YJ381nqLT29PWA.png" /><figcaption>Mode of day of week by member type</figcaption></figure><p>The mean ride length by day of week was calculate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*iWcxiTlTwqe4IJ-zAhDJ-A.png" /><figcaption>Mean ride length for member type by day of week</figcaption></figure><p>And, the total number of rides for each member type by day of week were calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*1TB0d_s4LrPEIsCEXwS-XA.png" /><figcaption>Total number of rides for member type by day of week</figcaption></figure><p>Also, the total number of rides for each member type was calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*8T26oL4Gm8_g0zCZAO1y-w.png" /><figcaption>Total number of rides by member type</figcaption></figure><p><strong>Key findings:</strong></p><ul><li>Only circa of 14% total rides are casual members</li><li>There are more rides of casual members on weekends than during week days. At the opposite, there are more rides of members during week days than weekends</li><li>Rides of members during week days range between circa 12 to 16% of the total number of rides. While for the casual members is always less than circa 2% of the total number of rides</li><li>Casual members ride more frequently on Sunday. And, members ride more frequently on Tuesday</li><li>During weekends, members ride for longer lengths (higher mean ride length). Monday is the day with lower mean ride length for casual members</li></ul><p>Important data insights were already obtained and could be translated visually to present data more clearly.</p><h3>Share</h3><p>In this step, after the analysis is performed and some insights are obtained, relevant visualizations are created to share findings.</p><ul><li>% number of rides by member type</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*Bk5nwhq7N7LImSPYCzWh9g.png" /><figcaption>Number os rides by member type (percentage)</figcaption></figure><ul><li>number of rides for member type by day_of_week</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*8lsDeAAIpOCyWGQAtHbi1w.png" /><figcaption>Number of rides for member type by day of week</figcaption></figure><ul><li>mean ride length for member type by day of week</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*GEnlIu-0rsJDG82lbNSf4w.png" /><figcaption>Mean ride length for member type by day of week</figcaption></figure><p>Now that visualizations were created, deliverables could be prepared.</p><h3>Act</h3><p>In this final step, based on my analysis and findings, the deliverables Morena asked me to create, are prepared and presented.</p><p>The question assigned to me: <strong><em>How do annual members and casual riders use Cyclistic bikes differently?</em></strong></p><p>From this study:</p><ul><li>Casual members use Cyclistic bikes for longer ride length than annual members</li><li>Casual members ride more during weekends and more frequently on Sunday</li></ul><p>Based on my analysis, I would recommend the following to increase converting casual riders into annual members:</p><ul><li>It can be created a new offer with benefits during weekends and long rides</li><li>Design marketing campaigns and fun activities to create engagement, strategic activities near bike stations can reach out more potential members from Saturday to Tuesday</li><li>It can be created a special discount for annual members who refer Cyclistic to friends (that are casual members) that become annual members</li></ul><p>Also, further analysis can be done:</p><ul><li>additional data about the Cyclistic stations location can be used to calculate the ride distances</li><li>the data already have features that allow to obtain the day and month, and further analysis can be conducted to explore findings per month, day and hour</li><li>additional data about the bike type can be used to get relevant information about members preference</li></ul><p>A document, <a href="https://github.com/carlacotas/google-data-analytics-capstone-case-study-trackA-cyclistic/blob/main/20241206_CyclisticCaseStudy_Question1_CarlaCotas.pdf">PowerPoint presentation</a>, was prepared to communicate the data insights to Lily Moreno (Director of Marketing).</p><p><strong>Thank you for reading! Feel free to share your feedback, suggestions and recommendations.</strong></p><h4>Links to code:</h4><p>GitHub repo containing my solution for the Capstone Project:<strong> </strong><a href="https://github.com/carlacotas/google-data-analytics-capstone-case-study-trackA-cyclistic">GitHub</a> Kaggle Code:<strong> </strong><a href="https://www.kaggle.com/code/carlacotas/google-data-analytics-course-capstone-project">Kaggle</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63908a154087" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>