<?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 Yousef Alghofaili on Medium]]></title>
        <description><![CDATA[Stories by Yousef Alghofaili on Medium]]></description>
        <link>https://medium.com/@yousefgh?source=rss-f3cfbe3f803------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YN9fdKIggwWlGH7pHA0JPA.png</url>
            <title>Stories by Yousef Alghofaili on Medium</title>
            <link>https://medium.com/@yousefgh?source=rss-f3cfbe3f803------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:24:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yousefgh/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[Interpretable K-Means: Clusters Feature Importances]]></title>
            <link>https://medium.com/data-science/interpretable-k-means-clusters-feature-importances-7e516eeb8d3c?source=rss-f3cfbe3f803------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e516eeb8d3c</guid>
            <category><![CDATA[keyword-extraction]]></category>
            <category><![CDATA[feature-importance]]></category>
            <category><![CDATA[model-interpretability]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[k-means]]></category>
            <dc:creator><![CDATA[Yousef Alghofaili]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 22:30:16 GMT</pubDate>
            <atom:updated>2021-07-29T15:38:00.497Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsdatascience.com/tagged/model-interpretability">Model Interpretability</a></h4><h4>Understand your K-Means clusters by extracting each cluster’s most important features.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ig8K3Iab5E7ahJQpn_pzdA.png" /><figcaption>[Image made by author] Clusters’ feature importance approaches</figcaption></figure><p>Machine learning models go through many stages for them to be considered production-ready. One critical stage is that moment of truth where the model is given a scientific green light; Model Evaluation. Many evaluation metrics are designated for different purposes and problem specifications, but none of them is flawless. Hence, data scientists have a huge burden to carry when choosing which evaluation metric to use that best fits the problem at hand and serves as a functional decision-inducing value for a machine learning project.</p><p>However, some evaluation metric values could seem unintuitive and cannot be explained in laymen’s terms, especially when evaluating unsupervised clustering algorithms using internal indexes (No external information is present such as true labels). Although these measurements serve a considerable benefit for comparative benchmarking, combining them with an interpretation is crucial for independent, intuitive validation and easier results communication with stakeholders.</p><h3>Intuition vs. Internal Validation Indexes</h3><p>Data scientists tend to lose a focal point in the evaluation process when it comes to internal validation indexes, which is the intuitive “Human” understanding of the model’s performance and its explanation. To elaborate by a counterexample, supervised classification evaluation metrics such as <a href="https://en.wikipedia.org/wiki/Accuracy_and_precision">Accuracy</a>, <a href="https://en.wikipedia.org/wiki/Precision_and_recall">Precision</a>, or <a href="https://en.wikipedia.org/wiki/Precision_and_recall">Recall</a> have very intuitive explanations for both laymen and experts. For instance:</p><ul><li><strong>Accuracy</strong>: <em>“We have correctly classified this percentage of samples out of all samples we have.”</em></li><li><strong>Precision</strong>: <em>“We have correctly classified this percentage of Positives out of all predicted positives.”</em></li><li><strong>Recall</strong>: <em>“We have correctly classified this percentage of Positives out of all actual positives.”</em></li></ul><p>On the other hand, internal validation indexes such as the widely used <a href="https://scikit-learn.org/stable/modules/clustering.html#silhouette-coefficient">Silhouette Coefficient</a>, <a href="https://scikit-learn.org/stable/modules/clustering.html#calinski-harabasz-index">Calinski-Harabasz Index</a>, <a href="https://scikit-learn.org/stable/modules/clustering.html#davies-bouldin-index">Davies-Bouldin Index</a>, and many others are, more often than not, used comparatively rather than an inherent and independent performance evaluation. The values of these measurements can be broken down to how compact each cluster is (How similar the cluster data points are to each other), how well-separated the clusters are (How dissimilar each cluster’s data points are from other clusters’ data points), or both. But, these measurements are not as easy to explain and connect to the clustering problem you are solving.</p><p>Notwithstanding how valuable these measures are, obtaining an interpretation for a model along with an internal evaluation index is crucial when trying to understand how good your model is as a data scientist or attempting to deeply communicate your results to stakeholders where most internal validation indexes do not pass the ELI5 (Explain it Like I’m 5) Test :). This article will focus on one of the most popular unsupervised clustering algorithms; The K-Means, and presents two possible techniques to extract the most important features for each cluster. The article’s outline is as follows:</p><ol><li><a href="#1db8"><strong>K-Means Business Value</strong></a></li><li><a href="#cae9"><strong>How K-Means Works</strong></a></li><li><a href="#7e14"><strong>Interpretation Techniques</strong></a></li><li><a href="#bf5c"><strong>Real-Life Application</strong></a></li></ol><p>If you already know how K-Means works, jump to the <a href="#7e14"><strong>Interpretation Techniques</strong></a><strong> </strong>section, or would like to visit the repository for this article and use the code directly, visit <a href="https://github.com/YousefGh/kmeans-feature-importance">kmeans-feature-importance</a>.</p><h3>K-Means Business Value</h3><p>Say that you are running a business with thousands of customers, and you would want to know more about your customers, albeit how many you have. You cannot study each customer and cater a marketing campaign specifically for them, for example. Yet, you know that each customer will probably have different demographic (e.g., Age), Geographic (e.g., Region), Psychographic (e.g., Spending Habits), and Behavioral (e.g., Engagement) properties. Segmenting them into multiple similar groups will simplify understanding who they are from the most prevalent properties of each group. The most popular algorithm to solve this problem, I am sure you guessed it! Is K-Means; “K” will refer to the number of possible customer segments/groups/clusters, and “Means” can be thought of as imaginary persons who are the center (Most similar to their group members) of each group in the K groups.</p><h3>How K-Means Works</h3><p>K-Means is an unsupervised clustering algorithm that groups similar data samples in one group away from dissimilar data samples. Precisely, it aims to minimize the Within-Cluster Sum of Squares (WCSS) and consequently maximize the Between-Cluster Sum of Squares (BCSS). K-Means algorithm has different implementations and conceptual variations, but for the sake of this article, We will focus on the most common method, namely Lloyd’s algorithm (Naive K-Means), which follows an iterative approach to find a sub-optimal solution. Before starting, we will prepare a simple dataset for explanation and see how it looks like.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d34897c6da46881228a6984ec2ae6cd/href">https://medium.com/media/7d34897c6da46881228a6984ec2ae6cd/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*eyUmdfj8GQ-x-BCEnvEkgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWhzKTTcuFCy9IfJrp-0uA.png" /><figcaption>‘df’ DataFrame view</figcaption></figure><p>The steps we need to do to cluster the data points above into K groups using K-Means are:</p><h4>Step 1<strong> — Choosing Initial Number of Groups/Clusters (K)</strong></h4><p>A centroid represents each cluster; The mean of all data points assigned to that cluster. Choosing an initial number of groups is synonymous with choosing an initial number of centroids K. We can decide on K = 3 and choose 3 distinct data points randomly from the dataset as our initial centroids (There are better methods to choose the initial coordinates of each centroid).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1u4QqeZvAta4vCyOzcOkg.png" /><figcaption>[Image made by author] First clusters’ centroids initialization</figcaption></figure><h4>Step 2 — Assigning Data Points to Clusters Centroids</h4><p>We have to assign each data point in our dataset to the closest centroid. We will use the most common distance metric as our definition of “close” through the following steps:</p><p>1. Calculate the Euclidean distance between each centroid and all data points using the equation below for each j-th cluster centroid C_j, and one point pfor a dataset that has d-Dimensions. <em>(My usage of </em><em>C_j = u_c_j (u = average) = Cluster Centroid is only a simplification since the equations I will list are in a single cluster level).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySEur9bMOnk77zbXru-__w.png" /></figure><p>2. To minimize the WCSS, we assign each data point to its closest centroid (Most similar / Least Distant). The reason why this will be a WCSS minimization step is from the equation for one cluster’s WCSS with p_m number of points assigned to the cluster centroid C_jwhere the shorter the distance for the points assigned to the cluster centroid, the lower its WCSS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGAe231pgSuMQiJ1q7l-zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r51w60kO8mRKBqBJKq8kkg.png" /><figcaption>[Image made by author] Data points assignments to clusters’ centroids</figcaption></figure><h4>Step 3 — Updating Clusters Centroids’ Positions</h4><p>The last step is to update the cluster centroids&#39; positions since different data points were assigned to each cluster. We have to move each centroid to the mean of all data points assigned to it by:</p><ol><li>Calculating the mean of each cluster’s data points</li><li>Setting the new cluster centroid to the new mean for each cluster</li><li>Repeating <a href="#6df7"><strong>Step 2</strong></a> and <a href="#0c6e"><strong>Step 3</strong></a> until the cluster centroids (the new means) do not change</li></ol><p>Using sklearn.cluster.KMean ; We will end up with the following where you can take, for example, Sample 0 and Sample 1features, calculate their mean and then check if it equals to Cluster Centroid D1 and Cluster Centroid D2:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25f5b99b4fcaab3d07dadec4409acf47/href">https://medium.com/media/25f5b99b4fcaab3d07dadec4409acf47/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*Q2y1A2uBWfh09kE4EMxWXA.png" /></figure><p>The plot below shows how K-Means clustered the dataset where each centroid is positioned at the mean of the points assigned to it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b7f0aa52aa6d3473049b428a75f88ff/href">https://medium.com/media/8b7f0aa52aa6d3473049b428a75f88ff/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0mw4Nw3i0LOGhjLqhTEdQ.png" /><figcaption>[Image made by author] K-Means clustering applied on ‘df’ data frame features 1 and 2</figcaption></figure><h3>Interpretation Techniques</h3><h4>Approach 1: WCSS Minimizers</h4><p><em>Disclaimer: The author has developed this method. Please do not hesitate to cite any references if found or criticize the methodology.</em></p><p>This approach is a direct analysis of each centroid’s sub-optimal position. Since K-Means aim is to minimize the Within-Cluster Sum of Squares and assuming that the distance metric used is the euclidean distance: We can find the dimensions that were responsible for the highest amount of WCSS (The sum of squares of each data point distance to its cluster centroid) minimization for each cluster through finding the maximum absolute centroid dimensional movement.</p><p>Using the same explanation example above, we can access cluster_centers_ from sklearn.cluster.KMeanfitted model; The final cluster centroids’ positions. Then show the feature names (Dimensions d):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52156391efcaa8d5910b86ea60fc684b/href">https://medium.com/media/52156391efcaa8d5910b86ea60fc684b/href</a></iframe><p>Plotting the clusters along with their positions would yield the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rxIK_134nGuuW88y4_z5Q.png" /><figcaption>[Image made by author] K-Means clusters for ‘df’ data frame along with centroid positions</figcaption></figure><p>Now let’s take each centroid and sort it by the dimensions axis, and remember to take the absolute value if you have features that have negative values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15d58595150a5377994258e23c0442ce/href">https://medium.com/media/15d58595150a5377994258e23c0442ce/href</a></iframe><p>After that, we can get the first centroid’s dimensions with sorted weights (Centroid distance traveled on features plane) and map that to feature names which will give us the hypothetical features importances below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a001b0d7f9f2328db08540b4a61bb489/href">https://medium.com/media/a001b0d7f9f2328db08540b4a61bb489/href</a></iframe><p>Since the centroid has moved with equal distances through both dimensions, the features will be of equal importance. Let’s give the last two samples (Belonging to cluster 0) a nudge on the first dimension and repeat the same process, then plot the new centroids</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a281be52a6ec472418e10134a2294b4c/href">https://medium.com/media/a281be52a6ec472418e10134a2294b4c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_NceWQge5DNiVAH9yZQzQ.png" /><figcaption>[Image made by author] K-Means clustering after a nudge on the first dimension (Feature 1) for cluster 0</figcaption></figure><p>We will now apply the same approach again and extract the feature importances. Notice that cluster 0 has moved on feature one much more than feature 2 and thus has had a higher impact on WCSS minimization.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbe9d437eb87e3f6c1a25a0ed4e12708/href">https://medium.com/media/bbe9d437eb87e3f6c1a25a0ed4e12708/href</a></iframe><h4>Approach 2: Unsupervised to Supervised</h4><p>This approach is model-agnostic; Not exclusive to K-Means, in which we convert the unsupervised clustering problem into a One-vs-All supervised classification problem using an easily interpretable classifier such as tree-based models. The steps to do this are as follows:</p><ol><li>Change the cluster labels into One-vs-All binary labels for each</li><li>Train a classifier to discriminate between each cluster and all other clusters</li><li>Extract the feature importances from the model (We will be using sklearn.ensemble.RandomForestClassifier)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*usaNAD229_lQrdIBu1QOGQ.png" /><figcaption>[Image made by author] Unsupervised clustering problem into a one-vs-all supervised classification problem conversion</figcaption></figure><p>Following from step 1, let us set cluster 0 label as 1 and set all other cluster labels to 0:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce214fd364cbdc97d9524512001b0ad8/href">https://medium.com/media/ce214fd364cbdc97d9524512001b0ad8/href</a></iframe><p>We have converted the problem into a binary classification problem. What is left is to train a classifier and use its feature_importances_ method implemented in scikit-learn to get the features that have the most discriminatory power between all clusters and the targeted cluster. We also need to map them to their feature names sorted by the weights.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54220346bfb59cb24044d88da7ba7ffc/href">https://medium.com/media/54220346bfb59cb24044d88da7ba7ffc/href</a></iframe><p>One important note is that this approach finds what discriminates between two clusters and is not at all inherent to the targeted cluster. Furthermore, there are many other sophisticated methods to extract the most important features from tree-based models and model-agnostic approaches which you can try.</p><h3>Real-Life Application</h3><p>I have chosen to apply the interpretation technique on an NLP problem since we can easily relate to the feature importances (English words), which could be considered as a group-based keyword extraction technique where we aim to cluster similar documents together using K-Means and then apply the techniques above. The dataset I will be using can be found here <a href="https://www.kaggle.com/c/learn-ai-bbc/data?select=BBC+News+Train.csv">Kaggle BBC-News</a>, which presents a classification problem. We will exclude the category column at first (Sport, Business, Politics, Entertainment, and Technology News articles) and use it later as a proof-of-concept.</p><p>The distribution of news categories in the dataset is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4abcf0f1124e1950e059ef4fd733d212/href">https://medium.com/media/4abcf0f1124e1950e059ef4fd733d212/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bs8P2JQ-quc_BU7P_OuIoA.png" /><figcaption>[Image made by author] BBC News train.csv dataset categories distribution</figcaption></figure><p>Since this article is not NLP-Specific (Natural Language Processing), I won’t intensively go through any NLP-related tasks. So, quickly moving towards preprocessing the text to prepare the features. The code below normalizes the words and filtering tokens (words and digits) that do not present a discriminatory power and are thus redundant. Then calculates the highest mentioned words in the whole dataset and plots them (<em>You can skip the code</em>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0579956cba55b6addfa66e64613c4322/href">https://medium.com/media/0579956cba55b6addfa66e64613c4322/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x03WIW5ySIar-mTBQml1EA.png" /><figcaption>[Image made by author] Highest mentioned words in BBC News dataset</figcaption></figure><p>Using TF-IDF (Text Representation Technique), we can convert the categorical variables (Words) into numeric representations. We do not need to scale the features here as TF-IDF normalizes features within its equation, and its output should be used in its raw form. Remember to scale the features if you apply K-Means on a dataset with features of different units or ranges where this difference is not relevant to the problem.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6847183ac671a74ff76df2f86b4481e2/href">https://medium.com/media/6847183ac671a74ff76df2f86b4481e2/href</a></iframe><p>Finally, now is the step we care about the most; I have wrapped up the method above in a class that inherits from sklearn.cluster.KMean and can be used in the same way with the difference of having feature_importances_ property added. You will have to provide the features ordered in the same way as X parameter in the fit method to ordered_feature_namesparameter for the modified class when initializing.</p><p>You can find the code here <a href="https://github.com/YousefGh/kmeans-feature-importance">kmeans-feature-importance</a> and simply clone it like this in your favorite CLI or simply follow through by accessing the Colab example in the repository:</p><pre>git clone <a href="https://github.com/YousefGh/kmeans-feature-importance.git">https://github.com/YousefGh/kmeans-feature-importance.git</a></pre><p>And then run the modified KMeans class with k= number of news dataset categories so that we can compare the results later with the actual categories.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/83eb535594ccbf9e0bca8bf5f5cd22ed/href">https://medium.com/media/83eb535594ccbf9e0bca8bf5f5cd22ed/href</a></iframe><p>Let’s check if K-Means has produced a cluster distribution similar to the category distribution in the news dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b45fa551ee2085e48611cda2d84230e1/href">https://medium.com/media/b45fa551ee2085e48611cda2d84230e1/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XDUAZb0oURGgLPF6cY3sw.png" /><figcaption>[Image made by author] Category and K-Means Cluster distributions</figcaption></figure><p>That’s a close-enough category distribution similarity to get us going. Don’t forget to ensure that K-Means has produced accurate results by using different internal validation indexes (I won’t be going through them as this will be out-of-scope), and you probably will not have true labels, so you will need to choose the best K in K-Means if K is unknown from the problem domain knowledge.</p><p>Moving on to interpretation, we can access the feature_importances_for the second cluster cluster 1 like this (The example is for WCSS Minimizers):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/309f3c1d61f04e29ac89a573beec9726/href">https://medium.com/media/309f3c1d61f04e29ac89a573beec9726/href</a></iframe><h4>Approaches Comparison</h4><p>We will compare both the WCSS Minimizers method and the Unsupervised to Supervised problem conversion method using the feature_importance_methodparameter in KMeanInterp class. The flow will be as follows:</p><ul><li>Plot categories distribution for comparison with unique colors</li><li>set feature_importance_methodparameter as wcss_min and plot feature importances</li><li>set feature_importance_methodparameter as unsup2supand plot feature importances</li><li>Infer the category of each cluster using its most important features</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bs8P2JQ-quc_BU7P_OuIoA.png" /><figcaption>[Image made by author] BBC News train.csv dataset categories distribution. Colors will be used for comparison below</figcaption></figure><p><strong>WCSS Minimizers</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTbxDCYR3rR4wg1i59HssA.png" /><figcaption>[Image made by author] Most important features using <strong>WCSS Minimizer</strong> method for each cluster and intuitively mapping each to the possible category in the actual dataset (Upper-right corner of each plot)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*leSpB8vuHTFoQEIit3PtaQ.png" /><figcaption>[Image made by author] Most important features using <strong>WCSS Minimizer</strong> method for each cluster and intuitively mapping each to the possible category in the actual dataset (Upper-right corner)</figcaption></figure><p><strong>Unsupervised to Supervised</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4oTkXX-GyrYI4mebZAbAA.png" /><figcaption>[Image made by author] Most important features using <strong>Unsupervised to Supervised </strong>method for each cluster and intuitively mapping each to the possible category in the actual dataset (Upper-right corner of each plot)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrtweypJn69dK-EDXvRncQ.png" /><figcaption>[Image made by author] Most important features using <strong>Unsupervised to Supervised </strong>method for each cluster and intuitively mapping each to the possible category in the actual dataset (Upper-right corner)</figcaption></figure><h3>Conclusion</h3><p>Clustering Interpretability becomes crucial when truth labels are not available at development time. It not only prevents data scientists from a direct evaluation of clustering validity due to the nature of internal validation indexes but also obstructs a simple and intuitive explanation of cluster performance to stakeholders. We have presented two possible approaches that aim to tackle this through extracting cluster-based feature importance, which allows us to know why the K-Means algorithm has chosen each cluster to be as such. The approach extends itself to stakeholder communication, simple and intuitive evaluation, cluster-based Keyword Extraction in NLP, and a general feature selection technique.</p><p><em>The notebook for this article, </em><em>KMeansInterp class, along with a direct usage example on Colab, can be found </em><a href="https://github.com/YousefGh/kmeans-feature-importance"><strong><em>here</em></strong></a><strong><em>. </em></strong><em>Happy Interpretation!</em></p><p><strong>References:</strong></p><ol><li>Y. Liu, Z. Li, H. Xiong, X. Gao and J. Wu, “Understanding of Internal Clustering Validation Measures,” 2010 IEEE International Conference on Data Mining, 2010, pp. 911–916, doi: 10.1109/ICDM.2010.35.</li><li>Kriegel, HP., Schubert, E. &amp; Zimek, A. The (black) art of runtime evaluation: Are we comparing algorithms or implementations?. Knowl Inf Syst 52, 341–378 (2017). <a href="https://doi.org/10.1007/s10115-016-1004-2">https://doi.org/10.1007/s10115-016-1004-2</a></li><li>Ng, A., &amp; Piech, C. (2021). CS221. Retrieved 18 July 2021, from <a href="https://stanford.edu/~cpiech/cs221/handouts/kmeans.html">https://stanford.edu/~cpiech/cs221/handouts/kmeans.html</a></li><li>Ismaili, Oumaima &amp; Lemaire, Vincent &amp; Cornuéjols, Antoine. (2014). A Supervised Methodology to Measure the Variables Contribution to a Clustering. 159–166. 10.1007/978–3–319–12637–1_20.</li><li>“<a href="https://scikit-learn.org/stable/modules/clustering.html">2.3. Clustering — scikit-learn 0.24.2 documentation</a>”, 2021</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e516eeb8d3c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/interpretable-k-means-clusters-feature-importances-7e516eeb8d3c">Interpretable K-Means: Clusters Feature Importances</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Harsh Truth about Data Science]]></title>
            <link>https://yousefgh.medium.com/the-harsh-truth-about-data-science-5f1c2ce3554?source=rss-f3cfbe3f803------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f1c2ce3554</guid>
            <category><![CDATA[newjoiner]]></category>
            <category><![CDATA[job-challenge]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-scientist]]></category>
            <dc:creator><![CDATA[Yousef Alghofaili]]></dc:creator>
            <pubDate>Mon, 12 Jul 2021 18:01:53 GMT</pubDate>
            <atom:updated>2021-07-12T18:01:53.708Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UyYyXoKpsoNbmeYik1ULQg.jpeg" /><figcaption>Image by <a href="https://pixabay.com/users/absolutvision-6158753/">AbsolutVision</a> via <a href="https://pixabay.com/illustrations/question-mark-labyrinth-lost-maze-2648236/">pixabay</a></figcaption></figure><p>One of the life-changing decisions you must have faced discomforting emotions about; is the career path you must follow. You must have asked, what will happen if I chose this and it turned out to be not at all your interest, or you might have realized that after a couple of years. In this article, I want to focus on choosing the path of being a data scientist, the other side of data science that is not very well-known to new joiners, and what data and data science mean outside the scientific realm.</p><h3>Dilemma of Choice</h3><p>With the sudden peak in popularity that Harvard Business Review contributed to in 2012 where they have annotated “Data Science” as the sexiest job of the 21st century [1], businesses started looking for data scientists to employ (Even when they sometimes don’t need to). Consequently, ambitious students started joining this demand wave by choosing this path.</p><p>If you were to look up on Google now “Why should I learn data science”, you will find multiple reasons summarized as such: To become good at problem-solving, having a lucrative career path, or due to the very high market demand. These reasons are too broad, not exclusive to data science, never guaranteed, and there might as well be better alternatives. However, they are being repeated everywhere missing out on one main point, people will never be great at something unless they are fully devoted to it, and people popularizing data science unknowingly mask out some challenges that are necessary to be successful. Hence, the title of this article.</p><h3>Concealed Side</h3><p>There’s always a difficult side for any field, let’s elaborate on what kind of predicaments or challenges data scientists might face but are not usually well-known.</p><h4>Reading, Reading, and Reading</h4><p>Not so many people enjoy reading every day, some of them are new joiners to data science. Data science is about reading books, academic literature, articles, and so on. To bring great ideas that are truly valuable which can improve your output, you must read a ton of knowledge. Following data scientists on social media platforms, subscribing to research organizations’ email lists (My favorite email list is <a href="https://deepai.org/this-week-in-ai">DeepAI</a>), and always being up-to-date is a must, your eyes must be everywhere. Most of what you think about is a byproduct of knowledge you have been introduced to, so be sure to have an abundance of it.</p><p>Furthermore, you have a strong backup when trying to fix/detect programming errors, exceptions are raised, program crashes, the output is clearly wrong,…etc, not so much with “Theoretical Bugs”. These bugs are too good at hiding, and you will never catch them if you were not a dedicated reader, you must understand a great level of the inner workings of what you are aiming to apply. Theoretical Bugs sometimes get detected after days, weeks, months, or never; where the model’s true quality is nowhere near to what has been reported.</p><h4>Living Under Uncertainty</h4><p>Imagine working for a whole month on a project, then throw it all away, how would that make you feel? Many people cannot accept failure and never let go. They go into a spiral of bad performance or multiple trials of reviving a machine learning project that is already a lost cause. Data science is uncertain, and it will always be, that’s why it’s distinguished by the word science. Managers as well must understand this uncertainty. To lead a successful data science project that is unique and valuable, you have to accept failure and be the first person who supports the team as failure is not so easy to consume.</p><p>To account for the risk of failure (For AI projects), I have briefly summarized some of the points that boost the probability of success or at least mitigate its failure:</p><ul><li>Switch your data science jargon off and accurately define and communicate the business requirements</li><li>Heavy research to define the algorithmic approaches and model’s quality KPI that are in alignment with business needs (e.g. Based on these <em>references</em>, we’re confident to mark a &gt; 85% accuracy as a KPI for use-case X)</li><li>Be clear with stakeholders about requirements &amp; KPI’s. Communicate exactly what the quality metric means (Further information in the Communication section).</li><li>Choose at least 3–5 fallback approaches if the chosen first approach failed and make sure you have your timeline buffered for this.</li><li>Fail fast, and let go if there’s no hope in achieving a value, or pushing the deadline</li></ul><h4>Communication</h4><p>You must have heard this phrase before “Explain it like I’m 5”, data science communication is all about this. Translating extreme complexity to minimal simplicity is the hardest-to-improve skill for data scientists, as the better you get, the more complexity you will face, and the harder it will be. To mention a few cases where proper communication (AI-Specific) is a must:</p><ul><li>Project Initiation: Convincing stakeholders to initiate a project necessitates grasping what the end goal is. You need to simulate how it looks like and attach it, always, to a business value. If your main goal is to directly support a decision-making process in a certain industry for example, when presenting a project, you should focus on simulating a decision-making scenario of which the data science project helps at.</li><li>Limitations: Limitations are unknown to stakeholders, but very well-studied by data scientists. Limitations must be clarified from the beginning as well as documented by focusing on cannot’s. For example: <em>“The project cannot do X”</em>.</li><li>Timeline: Project timeline choice should align with its value, and a proper Work Breakdown Structure must be prepared and communicated throughout the project life.</li><li>Performance Report and Continuous Monitoring: You must have communicated your model’s KPI beforehand, you have to bring examples sometimes, people have different perceptions about numbers. 85% accuracy might sound great for a person, but when introduced with an example, it becomes, for the same person, garbage! (I usually like flipping the quality metric by saying, for example, we will make 15 “mistakes” out of 100 “predictions” instead of saying 85% accuracy). Also, when monitoring the model’s performance in production, mistakes can happen, you always have to be ready to offer a proper defense or a proper retrospection when presented by mistakes. Unfortunately, one of the things that are most of the time not included in a data science curriculum is Interpretability. You need to know why the model has predicted an “Apple” instead of an “Orange”, and here where the conundrum peaks! Some projects are critical, and any prediction has a burden of responsibility, so account for the need for interpretability if the project expects it.</li></ul><h3>Bright Side</h3><p>Allow me to coat this field with fascination using my own definitions sacrificing some of the scientific jargon.</p><h4>“Data” in a Different Dimension</h4><p>Data is our way to represent the real world around us in a slightly different format than what we’re used to. It is a way to share information with others in a more accurate way, it is a method that allows us to play easily with this information using a machine. It’s a technique to convince others with evidence, it’s a method where we capture moments and occurrences of certain real-life events in this world to be later used. Your five senses are a considered data channels to your brain, as much as you can consider your phone’s camera as its sense of sight, or the microphone will be its sense of sound. Each type of computer will have these channeling mechanisms whereby it can receive different data with different formats. What then? The data will set there without any use. Here comes data science!</p><h4>“Data Science” in a Different Dimension</h4><blockquote><em>Data science is an inter-disciplinary field that uses scientific methods, statistics, mathematics, processes, algorithms, and systems to extract knowledge and insights from many structural and unstructured data. [2]</em></blockquote><p>Let’s throw that away for a bit and go with a simpler overview. We previously mentioned that data is just a representation of the real world; texts, sounds, images, numbers …etc. but this has no value. Data science transforms this representation, into another representation whereby people can relate to, it adds value and more information to what was only vague data flowing around us into things that are easily understood. After that, it affects our decision, it makes us realize things that we didn’t know before, it changes our actions, and might as well be used to give us a prediction of what will happen if that action was changed. Also, it might tell us things that we could not have known unless we learned, or even if we have learned it, it can tell us in a faster and more evidential way.</p><p>Imagine that you spend some amount of money every day, wouldn’t it be useful to see where you spend that money, every month, concerning a certain type of spending. Also, you might have to ask your friend for some amount of money in the next month or reduce how much you spend every day if only you were able to estimate your next month’s budget.</p><h3>Why Learn Data Science?</h3><p>“Why Learn Data Science?”, is an interesting question… or… — <strong>Questions Alert!</strong> — is it? How interesting is it? Why is it interesting? And for whom exactly is it interesting? How many people find that interesting? How many people find it boring? Can I compare how interesting that question is with other questions? But wait? How can I represent the concept “Interesting”? Also, Can I predict the number of people who would be interested in that question this year and in the coming year? Can I predict whether a person would be interested in that question or not before I ask?</p><p>Can I —<strong> Brainstorming Alert! </strong>— answer these questions by just seeing how many people searched for that question on google? Or how many people have clicked on websites that have the answer for that question? Or publish a survey that has related questions with that exact question being answered, and then publish the survey without that question and try to predict whether the person would answer “I am interested in that question” based on his other answers? Or can I just calculate the number of junior data scientists in a region at a certain time?</p><p>Data Science will give you the ability to ask questions about anything you see, read, or listen to in your everyday life whether it was as simple as the question above, or as hard as the Large Hadron Collider problem. It will make you capable of thinking about multiple approaches to overcome problems or answer questions. It will change the thought process you follow into an analytical thinker; it will change how you make decisions or receive factual claims from people or assess how truthful the claims are. It will provide you with a logical analytical domain of which you can tell when to accept a claim, reject a claim, or stay neutral.</p><blockquote><strong>Data Science is more of a lifestyle, and a philosophy, rather than just a career</strong></blockquote><p><strong>References:</strong></p><p>[1] Davenport TH, Patil DJ. Data scientist: the sexiest job of the 21st century. <em>Harvard Business Review</em>. 2012 Oct;90(10):70–6, 128.</p><p>[2] Dhar, V. (2013). “Data science and prediction”. <em>Communications of the ACM</em>. <strong>56</strong> (12): 64–73</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f1c2ce3554" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>