<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chris</title>
    <description>The latest articles on DEV Community by Chris (@chris22ozor).</description>
    <link>https://dev.to/chris22ozor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F800929%2F8c4214d3-de58-4fea-9602-8d5d666f1985.png</url>
      <title>DEV Community: Chris</title>
      <link>https://dev.to/chris22ozor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/chris22ozor"/>
    <language>en</language>
    <item>
      <title>Evaluating A Machine Learning Classification Model</title>
      <dc:creator>Chris</dc:creator>
      <pubDate>Sun, 15 Sep 2024 19:44:00 +0000</pubDate>
      <link>https://dev.to/chris22ozor/evaluating-a-machine-learning-classification-model-7m1</link>
      <guid>https://dev.to/chris22ozor/evaluating-a-machine-learning-classification-model-7m1</guid>
      <description>&lt;p&gt;In machine learning (ml), model evaluation is a crucial step to understand how well your model performs on unseen data. This is essential because, while a model might perform well on the training dataset, its ability to generalize to new data determines its true value. Evaluating classification models involves several methods and metrics, each designed to give insights into different aspects of the model's performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Purpose of Model Evaluation
&lt;/h2&gt;

&lt;p&gt;The main goal of model evaluation is to assess the quality of machine learning predictions and ensure that the model performs well on data it has not seen before (generalization). By evaluating ml models, we can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Determine the effectiveness of the model in making accurate predictions.&lt;/li&gt;
&lt;li&gt;Compare different models to choose the best one for a particular problem.&lt;/li&gt;
&lt;li&gt;Fine-tune models to improve their performance by adjusting parameters or features.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Evaluation Procedures
&lt;/h2&gt;

&lt;p&gt;There are several procedures for evaluating machine learning models:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Training and testing on the same data&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rewards overly complex models that "overfit" the training data and won't necessarily generalize.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Train/test split&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Split the dataset into two pieces, so that the model can be trained and tested on different data&lt;/li&gt;
&lt;li&gt;Better estimate of out-of-sample performance, but still a "high variance" estimate&lt;/li&gt;
&lt;li&gt;Useful due to its speed, simplicity, and flexibility&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;K-fold cross-validation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Systematically create "K" train/test splits and average the results together&lt;/li&gt;
&lt;li&gt;Even better estimate of out-of-sample performance&lt;/li&gt;
&lt;li&gt;Runs "K" times slower than train/test split&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can deduce from the above evaluation procedures that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Training and testing on the same data is a classic cause of overfitting in which you build an overly complex model that won't generalize to new data and that is not actually useful.&lt;/li&gt;
&lt;li&gt;Train_Test_Split provides a much better estimate of out-of-sample performance.&lt;/li&gt;
&lt;li&gt;K-fold cross-validation does better by systematically creating “K” train test splits and averaging the results together.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Choice of A Model Evaluation Metric.
&lt;/h2&gt;

&lt;p&gt;The choice of a model evaluation metric depends on the specific machine learning problem you are solving. For classification problems, you can use the classification accuracy; but this has its own limitations. However, we will discuss the limitations of the classification accuracy and also focus on other important classification evaluation metrics in this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Classification Accuracy and Its Limitations.
&lt;/h2&gt;

&lt;p&gt;Accuracy is one of the simplest and most commonly used evaluation metrics, represented by the percentage of correct predictions made by the model. However, accuracy has its limitations, especially when dealing with imbalanced datasets, where one class is significantly more frequent than others. In such cases, a model might achieve high accuracy simply by always predicting the majority class, without actually learning meaningful patterns.&lt;/p&gt;

&lt;p&gt;We've chosen the  &lt;a href="https://www.kaggle.com/datasets/uciml/pima-indians-diabetes-database" rel="noopener noreferrer"&gt;Pima Indians Diabetes&lt;/a&gt; dataset for this tutorial, which includes the health data and diabetes status of 768 patients. Let's read the data and print the first 5 rows of the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhjjyp9v1u7f3rwmf422r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhjjyp9v1u7f3rwmf422r.jpg" alt="Image description" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The label column indicates 1, if the patients has diabetes and 0, if the patients doesn't have diabetes. Albeit, we intend to answer the question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Question: Can we predict the diabetes status of a patient given their health measurements?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With this in mind, let's define our features metrics X and response vector Y. We use train_test_split to split X and Y into training and testing set.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faht2mi7o6upa89d1chlz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faht2mi7o6upa89d1chlz.jpg" alt="Image description" width="681" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1b67wxmz27ssgwp3ysu1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1b67wxmz27ssgwp3ysu1.jpg" alt="Image description" width="800" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we train a logistic regression model on training set. During the fit step, the logreg model object is learning the relationship between the X_train and Y_train. Finally we make a class predictions for the testing sets&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpapun68y5keeurc7vli.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmpapun68y5keeurc7vli.jpg" alt="Image description" width="678" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgi23tclswuqouojhbc4c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgi23tclswuqouojhbc4c.jpg" alt="Image description" width="562" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now , we've made prediction for the testing set, we can calculate the classification accuracy, which is simply the percentage of correct predictions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtlvibaf2pwigu4140ld.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxtlvibaf2pwigu4140ld.jpg" alt="Image description" width="624" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, anytime you use a classification accuracy as your evaluation metric, it is important to compare it with &lt;em&gt;&lt;strong&gt;Null accuracy&lt;/strong&gt;&lt;/em&gt;, which is the accuracy that could be achieved by always predicting the most frequent class&lt;/p&gt;

&lt;h2&gt;
  
  
  Null Accuracy
&lt;/h2&gt;

&lt;p&gt;The Null accuracy answers the question; &lt;strong&gt;&lt;em&gt;if my model was to predict the predominant class 100 percent of the time, how often will it be correct?&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;In the scenario above, 32% of the y_test are 1 (ones). In other words, a dumb model that predicts that the patients has diabetes, would be right 68% of the time(which is the zeros).This provides a baseline against which we might want to measure our logistic regression model.&lt;/p&gt;

&lt;p&gt;When we compare the Null accuracy of 68% and the model accuracy of 69%, our model doesn't look very good. This demonstrates one weakness of &lt;em&gt;classification accuracy&lt;/em&gt; as a model evaluation metric. The classification accuracy doesn't tell us anything about the underlying distribution of the testing test.&lt;/p&gt;

&lt;p&gt;Let's look at the calculation of the null accuracy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26yh8lwu8anqhbhts3lk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26yh8lwu8anqhbhts3lk.jpg" alt="Image description" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In summary:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The classification accuracy is the easiest classification metric to understand.&lt;/li&gt;
&lt;li&gt;But, it does not tell you the underlying distribution of response values or predictions&lt;/li&gt;
&lt;li&gt;And, it does not tell you what "types" of errors your classifier is making, this is why it is good to evaluate your models using the &lt;strong&gt;&lt;em&gt;Confusion Matrix&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Understanding Confusion Matrix And Its Advantage.
&lt;/h2&gt;

&lt;p&gt;The confusion matrix is a table that describes the performance of a classification model. It provides a more detailed breakdown of a model’s performance, showing how often predictions fall into each category. It consists of four outcomes: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;True Positives (TP):&lt;/strong&gt; we &lt;em&gt;correctly&lt;/em&gt; predicted that they &lt;em&gt;do&lt;/em&gt; have diabetes; when both the actual and predicted values are 1&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;True Negatives (TN):&lt;/strong&gt; we &lt;em&gt;correctly&lt;/em&gt; predicted that they &lt;em&gt;don't&lt;/em&gt; have diabetes; when both the actual and predicted values are 0&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;False Positives (FP):&lt;/strong&gt; we &lt;em&gt;incorrectly&lt;/em&gt; predicted that they &lt;em&gt;do&lt;/em&gt; have diabetes; when the actual value is 0 but the predicted value is 1 (a "Type I error")&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;False Negatives (FN):&lt;/strong&gt; we &lt;em&gt;incorrectly&lt;/em&gt; predicted that they &lt;em&gt;don't&lt;/em&gt; have diabetes; when the actual value is 1 but the predicted value is 0 (a "Type II error")&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using a confusion matrix, you can compute more nuanced metrics like precision, recall, and F1-score, which provide a clearer picture of a model’s performance in the presence of class imbalances.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyko2z8j8ov39wd5uw04z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyko2z8j8ov39wd5uw04z.jpg" alt="Image description" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By using a confusion matrix, you can compute more nuanced metrics like precision, recall, and F1-score, which provide a clearer picture of a model’s performance in the presence of class imbalances.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metrics Computed from a Confusion Matrix
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Recall (Sensitivity):&lt;/strong&gt; The proportion of correctly predicted positive cases out of all actual positives. It measures the model’s ability to identify positive cases. It means when the actual value is positive, how often is the prediction correct?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How "sensitive" is the classifier to detecting positive instances?&lt;/li&gt;
&lt;li&gt;Also known as "True Positive Rate" or "Recall"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Specificity:&lt;/strong&gt; The proportion of correctly predicted negative cases out of all actual negatives. This means when the actual value is negative, how often is the prediction correct?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How "specific" (or "selective") is the classifier in predicting positive instances?
&lt;strong&gt;False Positive Rate:&lt;/strong&gt; When the actual value is negative, how often is the prediction incorrect?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Precision:&lt;/strong&gt; The proportion of correctly predicted positive cases out of all predicted positives. It indicates the accuracy of positive predictions. This means when a positive value is predicted, how often is the prediction correct?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How "precise" is the classifier when predicting positive instances?
Many other metrics can be computed: F1 score, Matthews correlation coefficient, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, The choice of metric depends on your specific business objective, however,  the confusion matrix gives you a more complete picture of how your classifier is performing. It also allows you to compute various classification metrics, and these metrics can guide your model selection.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>ai</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>SQL Window Functions</title>
      <dc:creator>Chris</dc:creator>
      <pubDate>Thu, 28 Sep 2023 10:38:58 +0000</pubDate>
      <link>https://dev.to/chris22ozor/sql-window-functions-c98</link>
      <guid>https://dev.to/chris22ozor/sql-window-functions-c98</guid>
      <description>&lt;p&gt;In this article, we discuss what window functions are and how they help you do your job as a data analyst or specialist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Outline:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What Are Window Functions?&lt;/li&gt;
&lt;li&gt;Types Of Window Functions&lt;/li&gt;
&lt;li&gt;Case study example&lt;/li&gt;
&lt;li&gt;How are Window Functions Useful and who should use them?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What Are Window Functions?&lt;/strong&gt;&lt;br&gt;
Window Functions are types of  SQL function that allows you to perform calculations based on data in different groups of rows. The term window describes the set of rows on which the function operates.  This window is defined using the OVER clause and can be based on various criteria, such as partitioning and ordering.&lt;/p&gt;

&lt;p&gt;Here’s what the window_function syntax looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sun19uR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3tkhcu4t0m2m09x9ey2.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sun19uR1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w3tkhcu4t0m2m09x9ey2.PNG" alt="Image description" width="464" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;image credit: database star&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The OVER Keyword:&lt;/strong&gt; indicates that this is to be used as a window function.&lt;br&gt;
&lt;strong&gt;The PARTITION BY clause:&lt;/strong&gt;  will let you define the window of data to look at&lt;br&gt;
&lt;strong&gt;The ORDER BY clause:&lt;/strong&gt; defines the order in which the function will run on the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Window Functions.&lt;/strong&gt;      &lt;/p&gt;

&lt;p&gt;The window functions are divided into four main groups:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Ranking Functions – Assign a rank to each row in the dataset. E.g ROW_NUMBER(), RANK(), DENSE_RANK(), NTILE(), PERCENT_RANK() etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Analytic Functions – This allows you to access the values of the previous or following rows (in relation to the current row). They can also return the first or last value and divide rows into (close to) equal groups. E.g LEAD(), LAG(), FIRST_VALUE(), LAST_VALUE(), etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Aggregate Functions – Regular aggregate functions can be used as window functions. Most commonly, you can count the values in the window, sum them, or find their average, minimum, and maximum values. Since these are window functions, you can do this using one or several grouping criteria. MAX(), MIN(), AVG(), SUM(), COUNT(), etc. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Distribution Functions – Calculate the cumulative or relative rank of a value within the dataset. E.g CUME_DIST().&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The Data for the Examples&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
                                                                                       Let’s say we want to calculate the ranking of employees based on their salaries within different departments.&lt;br&gt;
Consider the following sample database table named "Employee":&lt;br&gt;
employee_id – The ID of the employees and the primary key (PK) of the table.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Employee_Name&lt;/strong&gt; – The name of the employee&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Department&lt;/strong&gt; – The department of the employees in the organization.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Salary&lt;/strong&gt; – The amount the employees earn in a month.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--23z_CEUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ikgibe13pin0rm3za59d.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--23z_CEUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ikgibe13pin0rm3za59d.PNG" alt="Image description" width="558" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's calculate the rank of employees within each department based on their salaries. We'll use the RANK() function for this example: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AqaQw7wt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oevaezwiao7je3ezj0qd.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AqaQw7wt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oevaezwiao7je3ezj0qd.PNG" alt="Image description" width="606" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this SQL query:&lt;br&gt;
                                            We select the employee's name, department, and salary, and calculate the rank of employees within each department based on their salary.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The PARTITION BY&lt;/strong&gt; clause divides the result set into partitions by the "Department" column. This means that ranking will restart for each department.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The ORDER BY&lt;/strong&gt; clause sorts the employees within each department by salary in descending order.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The RANK()&lt;/strong&gt; function assigns a rank to each employee based on their salary within their respective department.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result of this query would look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BbZRNxAo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnuof0ql9hs38md7z58q.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BbZRNxAo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnuof0ql9hs38md7z58q.PNG" alt="Image description" width="357" height="173"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this result, you can see that within each department, employees are ranked based on their salaries, with the highest salary receiving a lower rank. The RANK() function handles ties by assigning the same rank to employees with equal salaries (as seen with Alice and Bob in the IT department or Cathy and John in the HR department).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Are SQL Window Functions Helpful?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Knowing SQL Window Functions makes writing complex reports easier. In business cases, they can help you rank data, analyze time series data, and make time period comparisons (i.e. year-to-year, quarter-to-quarter, month-to-month. They are perfect for all data analysts who work with SQL. If you want to SQL expert and take your reporting to a new level, then window functions are for you.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>sql</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>PRESENTING TO A NON-TECHNICAL AUDIENCE AS DATA EXPERTS</title>
      <dc:creator>Chris</dc:creator>
      <pubDate>Mon, 31 Jan 2022 10:36:21 +0000</pubDate>
      <link>https://dev.to/chris22ozor/presenting-to-a-non-technical-audience-1p84</link>
      <guid>https://dev.to/chris22ozor/presenting-to-a-non-technical-audience-1p84</guid>
      <description>&lt;p&gt;Communicating with non-technical stakeholders can present a challenge when discussing a proposed business solution or the application and deployment of a new technology model for a business problem. This is a common struggle for everyone from the CDO (Chief Data Officer) to junior data professionals when it comes to clearly communicating complex technical concepts to executive leadership, internal and external clients, and customers alike. It may even feel like you’re speaking two completely different languages as you get into more in-depth discussions.&lt;/p&gt;

&lt;p&gt;The data science workflow and project lifecycle is a daunting process filled with many technical comments, language, and constructs in the build-up process, leaving the non-technical stakeholders with no clear understanding of the impact of the project. It is clear to note that the essence and priority of the entire journey is the communication of the impact of the findings and solutions to management executives, internal or external customers, and stakeholders.&lt;/p&gt;

&lt;p&gt;By experience, I noticed most data scientists work and focus only on developing and deploying Models and Machine Learning solutions, giving little to no attention to strategies to communicate their results to a non-technical audience. This creates a wide gap in the minds of the audience as to what the impact of the solution is all about.&lt;/p&gt;

&lt;p&gt;No management executive or stakeholder cares about the fancifulness or technicality of your model or codes. What they are interested in, is how you’re proposed model or solution communicates and translates to business impact or value.&lt;/p&gt;

&lt;p&gt;As technical experts and data leaders, we should endeavor to simplify complex comments and concepts into understandable components for the non-technical audience to comprehend. By this, we make it easier for the non-technical stakeholders to understand tech on a high level. This exerts a degree of leadership and influence within the context and domain.&lt;/p&gt;

&lt;p&gt;When communicating your findings, it’s got to do a lot more with your target audience. A few approaches to guide us to communicate our results properly can be found below.&lt;/p&gt;

&lt;p&gt;1) Know your audience:  This is the first of many steps to communicating effectively. Learning who your audience is will ensure you come up with a structure and choose an appropriate approach to driving your message home as Data Leaders. Some notable points here could include:&lt;br&gt;
i) Finding out the audience backgrounds and expertise&lt;br&gt;
ii) Gauging their level of knowledge on the subject matter beforehand&lt;br&gt;
iii) What does the audience need to know?&lt;br&gt;
iv) How will the audience use the information?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4oilob8kyfxx9y393upz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4oilob8kyfxx9y393upz.PNG" alt="Image description" width="522" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2) Use Visual Aids ( visualizations software): &lt;br&gt;
As the saying goes, a picture is worth a thousand words. Human beings generally can grasp concepts in pictures much faster than they can digest words. Using visuals to communicate thoughts and processes facilitates engagements and can make it easier for a non-technical audience to understand concepts at a very high level. Create an illusion of data flow in form of directional arrows. Connect the box to visualize integrated systems. Some visual software out there includes Plotly, PowerBI, Tableau, Powerpoint, etc. as the case may be depending on your need. &lt;/p&gt;

&lt;p&gt;Also, using visual storytelling helps to effectively communicate technical results to non-technical audiences.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1i10fdewfawv06rh4a6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1i10fdewfawv06rh4a6.PNG" alt="Image description" width="641" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3)  Choose your communication channel:&lt;/p&gt;

&lt;p&gt;Effective engagement with non-technical stakeholders entails choosing the right platform to communicate technical results and findings. Meeting rooms should be serene and conducive and it’s advisable to have a smaller group for proper engagement and interactions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fss5pgggh8r7v3gr653lo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fss5pgggh8r7v3gr653lo.PNG" alt="Image description" width="495" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Communication is a two-way path. Listening and giving feedback. It’s not always about articulating your personal views and ideas. Listening and receiving feedback are as important. Clear communication is the key to both understanding and explaining thoughts and processes to a non-technical audience. By maintaining simple language, and following a straightforward explanation strategy, it becomes easier for the non-technical stakeholders to understand technical concepts at a high level.&lt;/p&gt;

&lt;p&gt;In conclusion, clear communication leads to clear business impacts and better Data and Technical Leaders.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>ai</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
