<?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 Scarlett Valentin on Medium]]></title>
        <description><![CDATA[Stories by Scarlett Valentin on Medium]]></description>
        <link>https://medium.com/@scarlettmvalentin?source=rss-dd40f7bc7c43------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*azSRRAeL6CEWLltXTb2Rmg.png</url>
            <title>Stories by Scarlett Valentin on Medium</title>
            <link>https://medium.com/@scarlettmvalentin?source=rss-dd40f7bc7c43------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:45:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@scarlettmvalentin/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[One Hot Encoder: Preparing Categorical Data for Machine Learning]]></title>
            <link>https://medium.com/@scarlettmvalentin/one-hot-encoder-preparing-categorical-data-for-machine-learning-15a626d048a7?source=rss-dd40f7bc7c43------2</link>
            <guid isPermaLink="false">https://medium.com/p/15a626d048a7</guid>
            <category><![CDATA[decision-tree-classifier]]></category>
            <category><![CDATA[data-collection]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[one-hot-encoding]]></category>
            <dc:creator><![CDATA[Scarlett Valentin]]></dc:creator>
            <pubDate>Thu, 01 Aug 2024 03:39:45 GMT</pubDate>
            <atom:updated>2024-08-01T03:39:45.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vv0HNvRhU0ihKVaBIpDUww.jpeg" /></figure><h3>Introduction</h3><p>Handling categorical data is a crucial aspect of building effective machine learning models. Categorical data represents discrete values or categories, such as colors, types of products, or geographic locations, which must be converted into a numerical format to be used by machine learning algorithms. This article will explore how to use the One-Hot Encoder from Scikit-Learn to transform categorical data for use in a Decision Tree Classifier. We’ll discuss why one-hot encoding is essential, provide a step-by-step guide, and demonstrate its application with a practical example.</p><h3>Understanding Categorical Data</h3><p>Categorical data comes in two forms: nominal and ordinal. Nominal data, such as movie genre or employment status, does not have an inherent order. Ordinal data, such as a rating scale (e.g., low, medium, high), has a meaningful order but no fixed numerical distance between categories.</p><p>Machine learning algorithms, such as decision trees, typically require numerical input to perform mathematical computations. Therefore, converting categorical data into a numerical format is necessary to ensure the algorithms can process and learn from it effectively.</p><h3>What is One-Hot Encoding?</h3><p>One-hot encoding is a technique that converts categorical data into a binary (0 or 1) format. Each category value is transformed into a separate binary column. For example, a color feature with values “red,” “blue,” and “green” would be transformed into three columns, each representing one of the colors with binary values indicating the presence (1) or absence (0) of the color.</p><p>Compared to label encoding, which assigns a unique integer to each category, one-hot encoding prevents the algorithm from assuming any ordinal relationship between the categories, which can lead to incorrect conclusions in the model.</p><h3>Step-by-Step Guide to Using One-Hot Encoder with a Decision Tree Classifier</h3><p>Let’s look through a real-world, step-by-step example of using One-Hot Encoder to prepare the data for a Decision Tree Classifier. In <a href="https://github.com/scarlettvalentin/hotel_reservations_project/tree/main">this project</a> I preprocessed the <a href="https://www.kaggle.com/datasets/ahsan81/hotel-reservations-classification-dataset">Hotel Reservations Dataset</a> from Kaggle to create a Decision Tree Classifier to predict whether or not a customer will cancel their hotel reservation.</p><h4><strong>1. Importing Necessary Libraries</strong></h4><pre>import pandas as pd<br>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.model_selection import train_test_split<br>from sklearn.preprocessing import OneHotEncoder<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.metrics import accuracy_score, roc_curve, auc, precision_score, confusion_matrix, ConfusionMatrixDisplay<br>from sklearn import tree</pre><h4>2. <strong>Loading and Exploring the Dataset</strong></h4><pre># Import data<br>data = pd.read_csv(&#39;data/hotel_reservations.csv&#39;)<br><br># View the overall shape, dtypes and null counts for each column in train data<br>data.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fdUXebZh5OYsFImA" /></figure><p>Our target variable for this data is `booking_status`. That will have to be converted to numerical values.</p><p>Additionally, the following categorical variables are nominal and will have to be preprocessed using One-Hot Encoder: `type_of_meal_plan`, `required_car_parking_space`, `room_type_reserved`, `market_segment_type`, and `repeated_guest`.</p><h4><strong>3. Preprocessing the Data</strong></h4><p>First, I convert all values for these categorical variables to numeric values to prepare for One-Hot Encoder.</p><pre># Convert values in the target column to 0&#39;s and 1&#39;s<br>data[&#39;booking_status&#39;] = data[&#39;booking_status&#39;].map({&#39;Canceled&#39;: 1,<br>                                                     &#39;Not_Canceled&#39;: 0})<br><br># Convert values in the type_of_meal_plan to numerical values<br>data[&#39;type_of_meal_plan&#39;] = data[&#39;type_of_meal_plan&#39;].map({&#39;Not Selected&#39;: 0,<br>                                                             &#39;Meal Plan 1&#39;: 1,<br>                                                             &#39;Meal Plan 2&#39;: 2,<br>                                                             &#39;Meal Plan 3&#39;: 3})<br><br># Convert values in the room_type_reserved to numerical values<br>data[&#39;room_type_reserved&#39;] = data[&#39;room_type_reserved&#39;].map({&#39;Room_Type 1&#39;: 1,<br>                                                             &#39;Room_Type 2&#39;: 2,<br>                                                             &#39;Room_Type 3&#39;: 3,<br>                                                             &#39;Room_Type 4&#39;: 4,<br>                                                             &#39;Room_Type 5&#39;: 5,<br>                                                             &#39;Room_Type 6&#39;: 6,<br>                                                             &#39;Room_Type 7&#39;: 7})<br><br><br># Convert values in the market_segment_type to numerical values<br>data[&#39;market_segment_type&#39;] = data[&#39;market_segment_type&#39;].map({&#39;Offline&#39;: 0,<br>                                                             &#39;Online&#39;: 1,<br>                                                             &#39;Corporate&#39;: 2,<br>                                                             &#39;Complementary&#39;: 3,<br>                                                             &#39;Aviation&#39;: 4})</pre><p>Then I use `train_test_split` to split my data into a train set and a test set. This is to prevent data leakage.</p><pre># Split dataset into features and target<br>X = data.drop(columns=[&#39;booking_status&#39;, &#39;Booking_ID&#39;], axis = 1)<br>y = data[&#39;booking_status&#39;]<br><br># Split the data into a train set and a test set using default values where 75% of the data is train and the remaining<br># 25% is the test data<br># Random state used for reproducibility<br>X_train, X_test, y_train, y_test = train_test_split(X, y, shuffle=True, random_state=28)</pre><h4><strong>4. Applying One-Hot Encoding</strong></h4><p>Next, I use Scikit-Learn’s <a href="https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html">OneHotEncoder</a> to transform the categorical features that have no ordinal relationship.</p><pre># Create dummy variables for categorical features<br>ohe = OneHotEncoder(drop=&#39;first&#39;, sparse_output=False)<br><br># Create dataframe with only the columns that require One Hot Encoding<br>categorical_train = X_train[[&#39;type_of_meal_plan&#39;, &#39;required_car_parking_space&#39;, &#39;room_type_reserved&#39;, <br>                          &#39;market_segment_type&#39;, &#39;repeated_guest&#39;]].copy()<br><br>categorical_test = X_test[[&#39;type_of_meal_plan&#39;, &#39;required_car_parking_space&#39;, &#39;room_type_reserved&#39;, <br>                          &#39;market_segment_type&#39;, &#39;repeated_guest&#39;]].copy()<br><br># Fit the encoder on the training data and transform it<br>ohe.fit_transform(categorical_train)<br><br># Transform the test data<br>ohe.transform(categorical_test)<br><br># Create new dataframes with One Hot Encoded columns<br>categorical_train_ohe = pd.DataFrame(data=ohe.transform(categorical_train),<br>                                    columns=ohe.get_feature_names_out(),<br>                                    index=categorical_train.index)<br><br>categorical_test_ohe = pd.DataFrame(data=ohe.transform(categorical_test),<br>                                   columns=ohe.get_feature_names_out(),<br>                                   index=categorical_test.index)</pre><h4><strong>5. Building the Decision Tree Classifier</strong></h4><p>In my project, I do scale the quantitative features using `StandardScaler` and include multiple iterations of models, but for the purpose of this blog, I will skip to initializing and training the decision tree classifier.</p><pre># Instantiate DecisionTreeClassifier <br>classifier = DecisionTreeClassifier(max_depth=7, random_state=28)<br><br># Fit the model to training data<br>classifier.fit(X_train_transformed, y_train)<br><br># Make predictions on the test data<br>y_pred = classifier.predict(X_test_transformed)</pre><h4><strong>6. Evaluating the Model</strong></h4><p>Lastly, evaluate the model performance using accuracy, precision, AUC and a confusion matrix.</p><pre># Evaluate performance<br># Calculate accuracy <br>acc = accuracy_score(y_test,y_pred) * 100<br>print(&#39;Accuracy is :{0}&#39;.format(acc))<br><br># Calculate precision <br>prec = precision_score(y_test,y_pred) * 100<br>print(&#39;\nPrecision is :{0}&#39;.format(prec))<br><br># Check the AUC for predictions<br>false_positive_rate, true_positive_rate, thresholds = roc_curve(y_test, y_pred)<br>roc_auc = auc(false_positive_rate, true_positive_rate)<br>print(&#39;\nAUC is :{0}&#39;.format(round(roc_auc, 2)))<br><br># Create and print a confusion matrix <br>print(&#39;\nConfusion Matrix&#39;)<br>print(&#39;----------------&#39;)<br>cm = confusion_matrix(y_test, y_pred)<br><br>cm_disp = ConfusionMatrixDisplay(confusion_matrix=cm,<br>                                      display_labels=classifier.classes_)<br>cm_disp.plot(cmap=plt.cm.Blues);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*9gMSG2SVPhe9uMKl" /></figure><h3><strong>Benefits of Using One-Hot Encoding with Decision Trees</strong></h3><p>One-hot encoding offers several advantages:</p><ul><li><strong>Improved Model Accuracy:</strong> By converting categorical data into numerical format, one-hot encoding helps the model better understand and utilize the data, leading to improved accuracy.</li><li><strong>Avoiding Ordinal Assumptions:</strong> Unlike label encoding, one-hot encoding prevents the algorithm from assuming any ordinal relationships between the categories, which is essential for accurate model predictions.</li><li><strong>Handling Multiple Categories:</strong> One-hot encoding effectively handles multiple categories, ensuring each category is represented distinctly.</li></ul><h3>Conclusion</h3><p>One-hot encoding is a vital preprocessing step for using categorical data in machine learning models. By transforming categorical features into a numerical format, we enable algorithms like decision trees to process and learn from the data effectively. This article demonstrated how to use the One-Hot Encoder in Scikit-Learn, walked through a practical example, and discussed the benefits of one-hot encoding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15a626d048a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hypothesis Testing: A Beginner’s How-To Guide]]></title>
            <link>https://medium.com/@scarlettmvalentin/hypothesis-testing-a-beginners-how-to-guide-de7ffa502ff2?source=rss-dd40f7bc7c43------2</link>
            <guid isPermaLink="false">https://medium.com/p/de7ffa502ff2</guid>
            <category><![CDATA[hypothesis-testing]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[t-test]]></category>
            <dc:creator><![CDATA[Scarlett Valentin]]></dc:creator>
            <pubDate>Thu, 09 May 2024 02:11:06 GMT</pubDate>
            <atom:updated>2024-05-09T02:11:06.807Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T6iWD1kbynjQL6eaaw3_mw.jpeg" /></figure><h3><strong>What is hypothesis testing and what is it used for?</strong></h3><p><strong>Hypothesis testing</strong> is a statistical tool to determine if a hypothesis or inference about a population parameter is true based on sample data. Hypothesis testing is a fundamental tool for data scientists to make inferences, generalizations and decisions based on data. After all, we’re not called data <em>scientists</em> for no reason, right?</p><h3><strong>Example Scenario</strong></h3><p>There are 5 basic steps to hypothesis testing:</p><p>1. Define the null and alternative hypotheses.</p><p>2. Choose a significance level.</p><p>3. Calculate the test statistic.</p><p>4. Decide to reject or fail to reject the null hypothesis.</p><p>5. Interpret the results.</p><p>While I take you through all 5 steps in detail, I will be using an example scenario to illustrate a real world use.</p><p>I will be using a dataset from a 2017–2018 survey conducted by the Center for Disease Control (CDC) used to understand the latest demographic, health, and fitness trends. The responses are limited to respondents from New York, New Jersey, and Connecticut. I will focus on analyzing the relationship between the mean sick days of a population and whether they have ever been diagnosed with a heart attack or not.</p><p>I will be focusing on two columns: `<em>PHYSHLTH</em>` and `<em>CVDINFR4</em>`. `<em>PHYSHLTH</em>` represents the number of sick days a person has had in the past 30 days. This column has been cleaned to convert ‘None’ and ‘88’ to ‘0’ days, records with a value to represent the number of sick days is kept, and all other values are dropped using the following code:</p><pre>def clean_physhlth(label):<br> if label in range(1,31):<br> value = label<br> elif label == 88:<br> value = 0<br> else:<br> value = None<br> return value<br><br>df[&#39;PHYSHLTH&#39;] = df[&#39;PHYSHLTH&#39;].map(lambda x: clean_physhlth(x))<br>df.dropna(subset=&#39;PHYSHLTH&#39;, inplace=True)</pre><p>`<em>CVDINFR4</em>` represents if the respondent has ever been diagnosed with a heart attack. This column has been cleaned to drop those that answered ‘Don’t know/Not sure’, refused, or missing entries. 1’s have been converted to ‘Yes’ and 2’s have been converted to ‘No’. This has been cleaned using the following code:</p><pre># Drop rows for those who answered Don&#39;t know/Not sure, refused, or missing entries<br>df = df[(df[&#39;CVDINFR4&#39;] == 1)| (df[&#39;CVDINFR4&#39;] == 2)]<br><br># Replace values to Yes and No<br>df[&#39;CVDINFR4&#39;].replace({1: &#39;Yes&#39;, 2: &#39;No&#39;}, inplace=True)</pre><p>I then used the following code to group and display the data:</p><pre># Group data based on &#39;Yes&#39; or &#39;No&#39; to heart attack history<br>heart_attack = df.loc[df[&quot;CVDINFR4&quot;] == &quot;Yes&quot;, &quot;PHYSHLTH&quot;]<br>no_hrt_attk = df.loc[df[&quot;CVDINFR4&quot;] == &quot;No&quot;, &quot;PHYSHLTH&quot;]<br><br># Display distribution plots<br>fig, ax = plt.subplots(figsize=(15, 6))<br>ax.hist(<br> x=[heart_attack,no_hrt_attk],<br> label=[&quot;Had Heart Attack&quot;, &quot;Never Had Heart Attack&quot;],<br> bins=range(32),<br> align=&quot;left&quot;,<br> density=True<br>)<br>ax.set_xlabel(&quot;PHYSHLTH&quot;)<br>ax.set_ylabel(&quot;Count&quot;)<br>ax.set_title(&quot;Distribution of PHYSHLTH by Heart Attack History&quot;)<br>ax.legend(title=&quot;Heart Attack History&quot;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a9zKXJFG4IHjuLou" /></figure><h3><strong>Hypothesis Testing Steps</strong></h3><p>Hypothesis testing can be broken down into 5 steps:</p><h4><strong>1. Define the null and alternative hypotheses.</strong></h4><p>The <strong>null hypothesis</strong> is what we would expect if there is no difference between our sample and the comparison group. We represent the null hypothesis with H₀. In this case, the following would be our null hypothesis for our situation.</p><p><strong>H</strong>₀<strong>:</strong> There is no difference in the mean sick days between those who have ever been diagnosed with a heart attack and those who have not.</p><p>The <strong>alternative hypothesis</strong> is the opposite of the null hypothesis. This is the case that the sample differs from the comparison group. We represent the alternative hypothesis with H₁. In this case, the following would be our null hypothesis for our situation.</p><p><strong>H</strong>₁<strong>:</strong> There is a difference in the mean sick days between those who have ever been diagnosed with a heart attack and those who have not.</p><h4><strong>2. Choose a significance level.</strong></h4><p>The <strong>significance level</strong> is the probability of rejecting the null hypothesis when it is true. It is denoted by α (alpha). For our situation, we will choose a significance level of 5%.</p><p>α: 0.05</p><h4><strong>3. Calculate the test statistic.</strong></h4><p>The <strong>test statistic</strong> is a number used to find if your data could have occurred under the null hypothesis. It describes how closely the distribution of your data matches the distribution predicted under the null hypothesis of the statistical test you are using.</p><p>To determine the difference between the two populations, I will be using a t-test. A <strong>t-test</strong> is used for comparing two categories of a numeric feature. It allows one to determine whether their means are the same across categories.</p><p>The t-statistic is calculated by the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/0*LMhsUzw1K7UDV-k8" /></figure><p>Additionally, we calculate the <strong>p-value</strong>, which is the probability that we would observe the sample measurement assuming the null hypothesis is true. This is where our significance level comes into play. If our p-value is less than our significance level, we reject the null hypothesis. If our p-value is greater than our significance level, there is not enough significance in our sample population and we fail to reject the null hypothesis.</p><p>I use the following code to calculate the t-statistic and the p-value:</p><pre>stats.ttest_ind(heart_attack, no_hrt_attk)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*edS1Q-6_WtrZoxJ6oB_hEQ.png" /></figure><p>Here we see our p-value is well below our significance level of 0.05.</p><p><strong>4. Decide to reject or fail to reject the null hypothesis.</strong></p><p>Once you have calculated your p-value, you can determine whether to reject or fail to reject the null hypothesis. We never “accept” the null hypothesis. We begin our experiment by assuming the null hypothesis is true, and we are trying to see if there is evidence to disprove it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CI9_0PfH_-LNgU_6as0J8A.png" /><figcaption>Compare the p-value with the significance level (or alpha value) to determine whether to reject or fail to reject the null hypothesis</figcaption></figure><p>In our example scenario, I reject the null hypothesis at a 0.05 significance level since the p-value is well below 0.05.</p><p><strong>5. Interpret the results.</strong></p><p>What does it mean to reject or to fail to reject the null hypothesis? The last step is to interpret those results to provide real meaning to your analysis.</p><p>I reject the null hypothesis in the example scenario. Therefore, there is a statistically significant difference between the mean number of sick days in the past 30 days for those who have been diagnosed with a heart attack and those who have not.</p><h3>Conclusion</h3><p>Hypothesis testing is an essential tool for data scientists to make an inference, generalization or decision based on a population. In this article, I have introduced the 5 steps to hypothesis testing while providing examples of all 5 steps based on an example scenario. While I used a t-test in this example, there are various other types of hypothesis tests, such as z-test, chi-squared and ANOVA, depending on your data. As data science continues to evolve, mastering hypothesis testing remains a crucial skill for extracting valuable insights and driving impactful outcomes from data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de7ffa502ff2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Teaching to Tech: Top 10 Tips for Nailing Data Science Presentations]]></title>
            <link>https://medium.com/@scarlettmvalentin/from-teaching-to-tech-top-10-tips-for-nailing-data-science-presentations-5d395430545f?source=rss-dd40f7bc7c43------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d395430545f</guid>
            <category><![CDATA[former-teacher]]></category>
            <category><![CDATA[data-scientist-skills]]></category>
            <category><![CDATA[presentation-skills]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[career-change]]></category>
            <dc:creator><![CDATA[Scarlett Valentin]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 04:30:46 GMT</pubDate>
            <atom:updated>2024-03-03T02:29:37.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euguZXcr0DKFS5oZMqGu_A.jpeg" /></figure><p><em>This article is for educators looking for a career change, former educators turned data scientists, and anyone interested in learning how a former educator has any business in the data science world.</em></p><p>I find myself repeatedly thinking “If I only knew about data science earlier!” And by earlier, I don’t just mean 13 years earlier when I was in college. I mean <em>a Master’s</em> + <em>15 credits </em>earlier. I mean <em>tens and tens of thousands of dollars</em> earlier. I mean <em>I could’ve been a Principal Data Scientist right now</em> earlier.</p><p>But then I quickly stop myself. I reframe my thoughts and I remember how lucky I am to find a career path that ignites the fire of passion beneath me at an age that is younger than the number of years I have left before retirement.</p><p>I also remind myself of all the lessons I’ve learned, all of the skills I’ve acquired, and all of my experience that has led me to this very place. None of it has been a waste. In fact, it’s been quite the opposite. I’ve held a number of potential careers, but my largest investment (time <em>and</em> money-wise) has been towards my middle school math educator career. What’s the best part of that? That former career has prepared me to be the ultimate data science presenter.</p><p>In this blog I am going to share my top 10 tips for nailing your next data science presentation through lessons learned as a former math educator.</p><p><strong>1. Know Your Audience/Stakeholders (Class of Middle Schoolers vs. Company Executives)</strong></p><p>You are presenting for your audience, not for yourself. You must tailor your presentation for those that this information is for. What is their prior knowledge? What is their attention span? What do they care about?</p><p><strong>Education: </strong>I never had a student tell me “Wow, Ms. Valentin, your vocabulary is astounding!” Middle schoolers aren’t impressed with your sophisticated vocabulary or acronyms if they don’t understand it. As an educator, I had to break information down to the level of my students to make it relevant, digestible, and understandable all during a short class period.</p><p><strong>Data Science:</strong> Your stakeholders probably won’t have the technical knowledge that you have — that’s why you have different jobs. If you use your presentation to show off how smart you are, they’ll likely be turned off by that. But more importantly, they will not understand the point you are trying to get across.</p><p><strong>DO:</strong></p><ul><li>Use vocabulary you know will be familiar to your audience.</li><li>Explain your visualizations and processes with the expectation that this is the first time they have seen something like this.</li><li>Make it short and concise. Even if your audience has a long attention span, chances are they don’t care about every detail of your research. And those who do can contact you after for more details.</li></ul><p><strong>2. Define Clear Objectives (Learning Goals vs. Presentation Goals)</strong></p><p>You must define clear objectives to refer to while you are planning your presentation to ensure everything you include has a purpose. You must then share these objectives when you are presenting so that your audience <em>understands</em> the purpose. What do you want to accomplish with this presentation? What does success at the end of the presentation look like? How will you help your audience walk away differently than when they came in?</p><p><strong>Education: </strong>Things can take a wild turn in the classroom if the teacher or students do not stay on track. I always posted the lesson objectives in the front of the classroom, explicitly introduced them, and recapped them at the end of each lesson. This not only helped me stay on track, but also helped the students monitor their own learning so that they understood the purpose of the lesson.</p><p><strong>Data Science:</strong> The last thing you want is to leave your audience wondering what was the whole point of your presentation. Every piece of your presentation should be intentionally crafted to support your objective, and your stakeholders should clearly see that picture. Don’t leave it up to them to connect the dots.</p><p><strong>DO:</strong></p><ul><li>Define your objectives at the <em>beginning</em> of the presentation.</li><li>Tie your points back to your objectives <em>during</em> the presentation</li><li>Summarize your objectives at the <em>end</em> of the presentation.</li></ul><p><strong>3. Structure Your Presentation (Lesson Plan vs. Presentation Outline)</strong></p><p>Preparation is key! You know those clear objectives you defined oh so explicitly in the previous bullet point? Now is the time to build a conspicuous, detailed roadmap on how you will get there. How will you hook your audience? What does the flow of your presentation look like? What actionable steps will you leave your stakeholders with at the end of your presentation?</p><p><strong>Education:</strong> I spent hours upon hours upon hours planning my lessons. Every one of my lessons followed the same format: Warm Up, Problem of the Day, Mini Lesson, Guided Practice, Independent Practice, Wrap Up, Exit Ticket. Each piece was essential to the student learning process, and I was able to fill in each section for each new topic. I knew where we were starting and where we were going, which kept my focus on my students and our objectives.</p><p><strong>Data Science:</strong> Without an outline, you can guarantee your presentation will not lead you to your objectives. Every presentation will need an introduction, main points, and a conclusion at a bare minimum. This will support your stakeholders’ understanding of your presentation.</p><p><strong>DO:</strong></p><ul><li>Prepare your outline before putting together your presentation.</li><li>Tie each piece of your outline back to your objectives.</li><li>Make your outline clear to your audience.</li></ul><p><strong>4. Tell a Compelling Story (Mathematical Narratives vs. Data Science Insights)</strong></p><p>This is the part that reminds us we’re working with other humans. Telling a story is a chance to wrap your audience in and show them why they care about the information you’re bringing them. How do you captivate the audience’s interest? Why is this important to your audience? What happens now that the stakeholders have new information?</p><p><strong>Education:</strong> Every Problem of the Day included a fun story for my students, usually putting them in the scenario to give them some stakes in the problem. Middle schoolers rarely care about doing math. But when the math had to do with them, all of a sudden I had a lot of buy-in.</p><p><strong>Data Science:</strong> Convey to your audience the context of the situation, the problem, and the resolution to that problem. Take them on an enticing journey as you unveil the thrilling data insights you’ve uncovered.</p><p><strong>DO:</strong></p><ul><li>Include a <em>relevant</em> story.</li><li>Relate the story to your stakeholders.</li><li>Use your data to tell this story.</li></ul><p><strong>5. Keep It Visual (Visual Aids in Math vs. Data Visualizations)</strong></p><p>If you’re anything like me, you know true satisfaction is creating an aesthetically pleasing graph with easy-to-read fonts and colors that make you feel as cozy as a warm blanket and a cup of hot chocolate. These visuals aren’t stand alone items in your presentation. Do your visuals help you tell your story? Are they pleasing to look at? Can your stakeholders understand the visuals?</p><p><strong>Education:</strong> My classroom decor wasn’t just for looks, but it was all fully functional. I had beautiful anchor charts that were crisp, color-coded, and simple to remind students of important steps for mathematical procedures. The word wall was incrementally added to as new vocabulary was introduced, each word with a definition and apprehensible example. Manipulatives were regularly used to support student understanding.</p><p><strong>Data Science:</strong> Don’t just talk your way through complex data concepts. <em>Showing</em> your audience will make your message much more powerful. But you must be intentional about your visualizations. Your stakeholders don’t need 4 different graphs to illustrate the same point if they can’t read the axes labels and the visuals are all cluttered.</p><p><strong>DO:</strong></p><ul><li>Label <strong>all</strong> visualizations.</li><li>Keep your visuals clean and easy to read.</li><li>Use visuals to <em>support</em> your objectives.</li></ul><p><strong>6. Engage Your Audience (Interactive Math Activities vs. Data Interpretation)</strong></p><p>You should be able to easily differentiate your performance to your audience from your practice in front of the wall. The energy should be different and you should be tailoring your presentation in real-time in response to your audience. Can you ask a rhetorical question to provoke thought? Are you connecting with your audience? Can they feel your excitement at the right parts?</p><p><strong>Education:</strong> After all those long hours of planning, I could finally see my lessons come alive when my students would engage in the learning. My students would regularly speak in the front of the classroom, ask and answer each other’s questions, and <em>create</em> things in the math classroom. When they moved from passive listening to hands-on activities is when the lesson objectives were truly being mastered.</p><p><strong>Data Science:</strong> To reemphasize point #1, you are presenting for your stakeholders. They should feel involved in your presentation. You want your stakeholders feeling comfortable, understood, and valued.</p><p><strong>DO:</strong></p><ul><li>Encourage questions and participation from your audience.</li><li>Use interactive data elements.</li><li>Tie in humor (if you know it will land with your audience).</li></ul><p><strong>7. Practice, Practice, Practice (Teacher Prep Time vs. Presentation Rehearsal)</strong></p><p>The first time you deliver your presentation shouldn’t be in front of your audience. You are the master at your craft. If you show up unprepared, you will not look like the knowledgeable professional that you are. Practice your presentation many times before you deliver it. Where should you position an effective pause? When will you be excited? When will you take a more serious tone?</p><p><strong>Education:</strong> “The first time you complete a math problem shouldn’t be in front of your students.” I was a huge advocate of that as a teacher. I’d complete all math problems in the lesson prior to the class period and I would know the general flow of my lesson. I knew how I wanted to teach each skill and how I would connect it to real world examples.</p><p><strong>Data Science:</strong> It sounds like at one point or another, we’re all going to find ourselves knee-deep into a killer presentation when we’re going to look up at our slide and realize the numbers are off. Now the question is: Will this be a one-time mortifying experience or will you be known as the data scientist that makes mistakes every few meetings? You’ll bounce back if you’ve practiced enough, but that mistake will destroy the rest of your flow if you’re not even sure what it’s supposed to convey.</p><p><strong>DO:</strong></p><ul><li>Rehearse your presentation to the point that you can present it without any notes.</li><li>Practice pauses, voice inflection and emphasis you will use during your delivery.</li><li>Be mindful and intentional about your body language while presenting.</li></ul><p><strong>8. Handle Q&amp;A Like a Pro (Answering Student Queries vs. Addressing Data Science Questions)</strong></p><p>Be sure to leave time for questions at the end of your presentation. At this point, you must be an intentional and active listener. It is all about your stakeholders (recurring theme here), therefore, you want to make sure you are answering the question that is being asked, and not going off on an unrelated tangent. What are some questions you anticipate your stakeholders asking you? Are your answers clear and concise? Do your stakeholders know how to contact you if they come up with more questions at a later time?</p><p><strong>Education:</strong> Anticipating questions and misconceptions ahead of time was one of the most valuable uses of my planning time. I was a huge proponent for the<em> 5 Practices for Orchestrating Productive Mathematics Discussions</em> (shoutout to any teachers who used this) and that’s when I began to consistently receive <em>Highly Effective</em> on my observations, including <em>Questioning and Discussion</em>, which seemed to be the most difficult category to excel in.</p><p><strong>Data Science:</strong> Since your presentation is probably much shorter than you want it to be (see point #1), this is a great opportunity to expand on the important things. Your stakeholders will determine what’s important and you’ll know you’re elaborating on the right things. However, you don’t want to be caught like a deer in headlights to an unexpected question, so you’ll have to prepare for the Q&amp;A like you did your presentation.</p><p><strong>DO:</strong></p><ul><li>Prepare answers to potential questions you expect from your stakeholders.</li><li>Leave ample time to answer questions.</li><li>Share your contact information for those interested to reach out with more information.</li></ul><p><strong>9. Embrace Feedback (Student Assessments vs. Stakeholder Input)</strong></p><p>This goes back to the clear objectives you’ve defined. They should have been created with your stakeholders in mind. Therefore, your feedback will be directly related to whether or not your objectives are being accomplished. Don’t take feedback personally, but look at it as an opportunity for growth. What does this feedback tell you about your presentation objectives? What feedback would you give someone who just delivered your presentation? What can you do to incorporate the feedback to become more effective?</p><p><strong>Education:</strong> As an educator, I had to know when to scrap a whole lesson because the kids were just not getting it, and reteach a prerequisite skill instead. I had to know when to repeat myself, when to ask an assessing question to determine student understanding, and when to regroup a class of drifting minds. I had to read into the 32 pairs of middle school eyes to determine what was going on in those brains so that I could adjust my lesson in the middle of executing it.</p><p><strong>Data Science:</strong> Feedback can come in the form of a raised eyebrow, an unhinged comment, or a compliment, just to name a few. Be on the lookout for it. Notice body language and attention spans. Objectively listen to comments. It’s easy to put the blame elsewhere, but if your objectives are not reaching your stakeholders, something has to change, no matter the reason.</p><p><strong>DO:</strong></p><ul><li>Welcome feedback as an opportunity to grow as a data scientist.</li><li>Adjust your roadmap as you are absorbing feedback.</li><li>Ask for elaboration and specificity when receiving feedback.</li></ul><p><strong>10. Be Prepared for Technical Glitches (Classroom Technology vs. Presentation Tech)</strong></p><p>Glitch happens. You see what I did there? These are the issues that are beyond your control. But what’s not beyond your control is your response. What will you do if the format of your presentation does not load correctly? What will you do if your presentation doesn’t load at all? How will you make sure you still hit all of your objectives before time is up?</p><p><strong>Education:</strong> Wifi down. Smartboard not connecting. An entire 3 ½ years of curriculum wiped from a USB drive right before class (true story). I was never going to give my students a free class period (yes, I was <em>that</em> teacher. But we had a lot to learn and no time to waste. And letting middle schoolers run wild for just 1 class period will haunt you for the rest of your life). I always had a plan B. And plan C, D, E, and sometimes F.</p><p><strong>Data Science:</strong> You don’t want to waste everyone’s time trying to fix the tech problem, just to find out everyone has another meeting to go to and you haven’t even previewed your objectives. <em>The show must go on</em>. Objectives still have to be hit and data stores still have to be told.</p><p><strong>DO:</strong></p><ul><li>Anticipate all the things that can go wrong by creating a plan B (plans C — F are optional).</li><li>Test run your equipment before your audience arrives.</li><li>Remain cool, calm, and collective if you run into a tech glitch.</li></ul><p>These 10 tips will help you take your next data science presentation to the next level. If you are a former educator, you probably have experience in most, if not all, of these skills. However, if these skills are new to you, just pick one to start. We get better by making small improvements each day.</p><p>What other data science skills have you acquired from <em>your</em> education career? What education skills do you have that you wonder if they apply to data science?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d395430545f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clean Your Data, You Better Clean Your Data: 8 Useful Tips for Data Cleaning in Pandas]]></title>
            <link>https://medium.com/@scarlettmvalentin/clean-your-data-you-better-clean-your-data-8-useful-tips-for-data-cleaning-in-pandas-8fac46bc3b12?source=rss-dd40f7bc7c43------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fac46bc3b12</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[beginner-data-science]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[Scarlett Valentin]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 04:12:27 GMT</pubDate>
            <atom:updated>2024-02-13T04:12:27.050Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, you will learn how to clean your data using Pandas, all sprinkled with a bit of Scarlett’s sensational sparkles.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FsnkhAqCos6k%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DsnkhAqCos6k&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FsnkhAqCos6k%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbe261aaabcd10270b759e78d812025b/href">https://medium.com/media/cbe261aaabcd10270b759e78d812025b/href</a></iframe><p>If you don’t you’ll be eaten in your sleep. Or your model won’t be accurate. Either one.</p><p>They say 80% of Data Science is cleaning data. Or 70%, depending on who you talk to. Either way, we’re doing a ton of cleaning and not nearly as much science-ing.</p><p>Cleaning your data is such a critical step of any data science project. It ensures that the data is accurate, it is consistent, and there are no major gaps.</p><p>In this article I will share some crucial steps for cleaning data using Pandas, including:</p><p>1. Set Index</p><p>2. Fill in Missing Values</p><p>3. Drop Rows</p><p>4. Drop Columns</p><p>5. Erroneous Values</p><p>6. Remove Duplicates</p><p>7. Clean Text</p><p>8. Format Data</p><p><strong>1. Set Index</strong></p><p>If you’re index column is not helpful, you can set your index to a different column in your dataset using the following:</p><pre>dataframe.set_index(index_column, inplace=True)</pre><p>(‘<em>inplace=True</em>’ is to permanently change the data frame. You can set this to False to preview the change before committing to it.)</p><p><strong>2. Fill in Missing Values</strong></p><p>You run <em>dataframe.info()</em> and find that some columns have missing values.</p><p>What do we do when we find missing values in our data? One option is to fill them in with our best guess. For continuous data, we can fill in missing values using the median or the mean.</p><pre>dataframe[&#39;column_name&#39;].fillna(dataframe[&#39;column_name&#39;].median(), inplace=True)<br>dataframe[&#39;column_name&#39;].fillna(dataframe[&#39;column_name&#39;].mean(), inplace=True)</pre><p>For categorical data, we can fill in missing values using the most common category.</p><pre>dataframe[&#39;column_name&#39;].fillna(dataframe[&#39;column_name&#39;].mode()[0], inplace=True)</pre><p>If you choose to fill in your missing values it will skew your distribution. So make sure this method is supporting your data to answer the business question accurately.</p><p><strong>3. Drop Rows</strong></p><p>We also have the choice to drop missing values from our data. This is a good choice if there aren’t many missing values and dropping this data will not lose crucial information in the dataset.</p><p>To detect the number of missing values in each column, we can run</p><pre>dataframe.isna().sum()</pre><p>Now let’s drop those bad boys:</p><pre>dataframe[&#39;column_name&#39;].dropna(inplace=True)</pre><p>Remember, set inplace to True only if you are truly sure of this change.</p><p><strong>4. Drop Columns</strong></p><p>We can also drop columns, albeit you are going to want to ensure those columns will not help you answer your business question.</p><pre>dataframe[&#39;column_name&#39;].dropna(axis=1, inplace=True)</pre><p>(<em>axis=0</em> represents rows and <em>axis=1</em> represents columns.)</p><p><strong>5. Erroneous Values</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*vQYxOjvv3q3DVsCQeioEKw.gif" /></figure><p>Now that you’ve taken care of any missing values, you run a nice little <em>for loop</em> to look into the top 5 values of every column.</p><pre>for col in dataframe.columns:<br>  print(col, &#39;\n&#39;, dataframe[col].value_counts(normalize=True).head()</pre><p>This will print out the 5 most frequent values in each of your columns. Think about these values in context: Do they make sense? If not, they may be a placeholder chosen by the person gathering the data. Here are some placeholders to look out for:</p><p>• “?’’ or a ‘-’ when there should be numerical values</p><p>• ‘9999’ or ‘0’ for weight</p><p>• ‘NA’ as a string</p><p>You will have to decide what you want to do with these values —</p><p>• <strong>Keep them:</strong> If the placeholders provide valuable information, keep them.</p><p>• <strong>Replace them: </strong>As described in #1, replacing these values will influence the distribution of this variable. Here is how you can replace them:</p><pre>dataframe[&#39;column_name&#39;].replace(&#39;?&#39;, &#39;0&#39;)</pre><p>• <strong>Delete them:</strong> If there are few erroneous values, you may delete those rows, as described in #2.</p><p><strong>6. Remove Duplicates</strong></p><p>Duplicates happen so let’s check for them.</p><pre>dataframe[dataframe.duplicated()]</pre><p>If you have a column that can be used to identify duplicates, such as customer ID, you can pass that as a subset in duplicated()”</p><pre>dataframe[dataframe.duplicated(subset=&#39;customer_id&#39;)]</pre><p>If you’ve identified duplicates in your data, be sure to drop them.</p><pre>dataframe.drop_duplicates(subset=&#39;customer_id&#39;, inplace=True)</pre><p><strong>7. Clean Text</strong></p><p>It’s not uncommon to find data entry issues such that there is whitespace or a difference in text that makes what should be the same value appear differently. For example, if your data includes a column for Tesla models, you may see ‘Model Y’ and ‘Model Y SUV’ when they mean the same thing.</p><pre>dataframe[&#39;column_name&#39;].replace(&#39;Model Y SUV&#39;, &#39;Model Y&#39;, inplace=True)</pre><p>We can clean up whitespace using the following:</p><pre>dataframe[&#39;column_name&#39;] = [datum.strip() for datum in dataframe[&#39;column_name&#39;]]</pre><p><strong>8. Format Data</strong></p><p>There are some cool built-in functions for working with datetimes that won’t work if your dates are stored as strings, so let’s fix that! If you have a column of entries that represent dates, convert them to datetime objects as such:</p><pre>pd.to_datetime(dataframe[column_name], format=&#39;%m/%d/%Y&#39;)</pre><p>where you insert the format your dates are originally in. Check out this Python<strong> </strong><a href="https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior"><strong>documentation</strong></a> to find a list of possible formats.</p><p>You can also format your data using int(), str(), float() depending on what type you want your data to be.</p><p>And voila! Your data is clean and ready to be analyzed in the blink of an eye. That is, if your data science project will be 1.25 times the time it takes you to blink your eye.</p><p>What are some of your go-to data cleaning tips and tricks? Leave them in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fac46bc3b12" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>