<?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 Eunbi Kim on Medium]]></title>
        <description><![CDATA[Stories by Eunbi Kim on Medium]]></description>
        <link>https://medium.com/@ekim71?source=rss-f628eefd6e1b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4CnTqlhIk6O0vA9cPXRrew.jpeg</url>
            <title>Stories by Eunbi Kim on Medium</title>
            <link>https://medium.com/@ekim71?source=rss-f628eefd6e1b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:48:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ekim71/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[Predicting Survivors from the Titanic Spaceship: A Machine Learning Approach (1)]]></title>
            <link>https://medium.com/@ekim71/predicting-survivors-from-the-titanic-spaceship-a-machine-learning-approach-1-25da40133b59?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/25da40133b59</guid>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Tue, 08 Oct 2024 01:43:40 GMT</pubDate>
            <atom:updated>2024-10-08T01:43:40.344Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my latest machine learning project where I worked on predicting which passengers survived the incident of the Titanic spaceship from the Kaggle Knowledge Competition (<a href="https://www.kaggle.com/competitions/spaceship-titanic/overview">https://www.kaggle.com/competitions/spaceship-titanic/overview</a>). This project involved extensive data preprocessing, exploratory data analysis (EDA), and implementing various machine learning models to make accurate predictions.</p><h3>Project Overview</h3><p>The goal was to analyze the Titanic spaceship dataset and build a predictive model to classify whether a passenger was rescued or not. By leveraging various machine learning algorithms, I aimed to discover patterns and insights that could inform these predictions, with classification accuracy as the primary metric.</p><h3>Data Loading and Exploration</h3><p>I began by loading the necessary libraries and the Titanic dataset, which I obtained from Kaggle. The dataset includes both training and testing data, comprising a total of 14 features. Upon initial inspection, I discovered that some columns contained missing values, notably in ‘HomePlanet’, ‘CryoSleep’, and ‘Cabin’.</p><p>The dataset consists of several files, including train.csv, which contains personal records for approximately 8,700 passengers used to train a predictive model, and test.csv, which holds records for around 4,300 passengers for testing. Each passenger is identified by a unique PassengerId, indicating their group and individual number. Key features include HomePlanet, the planet of origin; CryoSleep, which indicates whether a passenger chose to enter suspended animation; Cabin, detailing the passenger&#39;s accommodation; and Destination, the intended arrival planet. Additionally, the dataset includes numerical features representing spending on luxury amenities, such as RoomService, FoodCourt, and VIP status. The target variable, Transported, indicates whether a passenger was successfully transported to another dimension, which the model aims to predict based on the available data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*qGpHYgbQaKupyq0UM-TeVQ.png" /><figcaption>The information of the training data set</figcaption></figure><h3>EDA and Visualization</h3><p>To gain a better understanding of the dataset, I conducted a brief exploratory analysis to visualize the distribution of features such as age, money spent, hometown, destination, group information, and more among the passengers.</p><p>For the numeric variables, except age, most features exhibit a right-skewed distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*Va8-RTOPJfs_1g9qCKme8Q.png" /><figcaption>Histograms of numerical variables</figcaption></figure><p>For the categorical variables, we can see that most passengers are not VIP passengers. Additionally, surprisingly, the number of passengers in CryoSleep accounts for approximately 30.37% of the total.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*knTRh0F_6MHMMzwxPZ1j9w.png" /><figcaption>Histograms of categorical variables</figcaption></figure><h3>Data Preprocessing</h3><p>The preprocessing stage was crucial, as it allowed me to clean and prepare the data for modeling. Here are the key steps I took:</p><ul><li>Split the PassengerId into GroupId and GroupIndex .</li></ul><pre>df_copy[[&quot;Group_Id&quot;, &quot;Group_Index&quot;]] = df_copy[&quot;PassengerId&quot;].str.split(&quot;_&quot;, expand=True)<br>df_copy.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHAc9YtJ-IeXwwGCD6LKmg.png" /></figure><ul><li>Dropped non-essential features.</li></ul><pre>df_copy = train.copy()<br>df_copy = df_copy.drop([&#39;Name&#39;], axis=1)<br>df_copy = df_copy.drop([&quot;PassengerId&quot;, &quot;Group_Index&quot;], axis=1) # numeric<br>df_copy.head(5)</pre><ul><li>Handled missing values by filling them with zero.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*Jf_zIxHleGbuMG9bJGuXKQ.png" /><figcaption>There are between 100 and 200 missing values in some features. (Left) I handled missing values by filling them with zero. (Right)</figcaption></figure><ul><li>Split the Cabin feature into multiple features (Deck, Cabin_num, Side).</li></ul><pre>df_copy[[&quot;Deck&quot;, &quot;Cabin_num&quot;, &quot;Side&quot;]] = df_copy[&quot;Cabin&quot;].str.split(&quot;/&quot;, expand=True)<br>df_copy = df_copy.drop(&#39;Cabin&#39;, axis=1)</pre><ul><li>Converted categorical features into numerical ones using one-hot encoding.</li></ul><pre>df_copy[&#39;Transported&#39;] = df_copy[&#39;Transported&#39;].astype(int)<br>df_copy[&#39;VIP&#39;] = df_copy[&#39;VIP&#39;].astype(int)<br>df_copy[&#39;CryoSleep&#39;] = df_copy[&#39;CryoSleep&#39;].astype(int)<br>df_copy.head(5)<br><br>for col in [&#39;CryoSleep&#39;, &#39;VIP&#39;, &#39;Transported&#39;]:<br>    df_copy[col] = df_copy[col].astype(int)<br><br>df_copy = pd.get_dummies(df_copy, columns=[&#39;HomePlanet&#39;, &#39;Destination&#39;, &#39;Deck&#39;, &#39;Side&#39;], dtype=int)<br><br>df_copy.fillna(0, inplace=True)<br><br>df_copy[&#39;Cabin_num&#39;] = df_copy[&#39;Cabin_num&#39;].astype(str).str.extract(&#39;(\d+)&#39;).astype(float)<br><br>df_copy = df_copy.apply(pd.to_numeric, errors=&#39;coerce&#39;)<br><br>df_copy.dropna(inplace=True)<br><br>df_copy.head(5)</pre><h3>Correlation Analysis</h3><p>I generated a correlation matrix to explore the relationships between the features and the target variable (transported) and visualized it using a heatmap. Although the correlation values are very small, indicating a weak correlation, we can focus on the features related to CryoSleep and certain VIP services, where the absolute value of the correlation exceeds 0.2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3npSrgwyqzf-vQbo5LyUQ.png" /><figcaption>A heatmap showing the correlations between the target variable ‘transported’ and other features.</figcaption></figure><h3>Modeling</h3><p><strong>Trial 1: Default Parameters</strong><br>In this trial, I used default parameters for each model and included all features. The models I used are as follows:</p><ul><li><strong>Logistic Regression</strong>: A simple yet effective model for binary classification problems. It is easy to interpret and can handle both numerical and categorical features.</li><li><strong>Decision Trees</strong>: An interpretable model that can manage non-linear relationships and feature interactions.</li><li><strong>Random Forest</strong>: An ensemble of decision trees that often provides improved accuracy and robustness compared to a single decision tree.</li><li><strong>Support Vector Machines (SVM)</strong>: A model capable of handling high-dimensional data and complex decision boundaries.</li><li><strong>Gradient Boosting Machines (XGBoost, LightGBM)</strong>: Powerful ensemble models known for their high accuracy.</li><li><strong>MLPClassifier</strong>: A multi-layer perceptron model that is effective for learning complex patterns and relationships in the data, utilizing a feedforward neural network approach.</li></ul><pre>from sklearn.linear_model import LogisticRegression<br>from sklearn.tree import DecisionTreeClassifier<br>from sklearn.ensemble import RandomForestClassifier<br>from sklearn.svm import SVC<br>from xgboost import XGBClassifier<br>from lightgbm import LGBMClassifier<br>from sklearn.neural_network import MLPClassifier<br><br>from sklearn.model_selection import train_test_split<br><br>X = df_copy.drop(&#39;Transported&#39;, axis=1)<br>y = df_copy[&#39;Transported&#39;]<br><br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state=24)<br><br>lr = LogisticRegression(random_state=24)<br>dt = DecisionTreeClassifier(random_state=24)<br>rf = RandomForestClassifier(random_state=24)<br>svm = SVC(random_state=24)<br>xboost = XGBClassifier(random_state=24)<br>light = LGBMClassifier(random_state=24)<br>mlp = MLPClassifier(hidden_layer_sizes=(100, 50), max_iter=300, random_state=24)</pre><h3>Model Evaluation and Feature Importance Analysis</h3><p>In the initial phase of our analysis, we employed several machine learning models to assess their performance in predicting the target variable. The models tested included Logistic Regression, Decision Trees, Random Forest, Support Vector Machines (SVM), Gradient Boosting Machines (XGBoost, LightGBM), and MLPClassifier. Each model was fitted using the training dataset, followed by predictions on the test dataset. We calculated the accuracy score and generated a detailed classification report for each model, which provided insights into their respective performances.</p><pre>from sklearn.metrics import accuracy_score, classification_report<br><br>models = [lr, dt, rf, svm, xboost, light, mlp]<br><br>results1 = []<br><br>for model in models:<br>  model.fit(X_train, y_train)<br>  y_pred = model.predict(X_test)<br>  accuracy = accuracy_score(y_test, y_pred)<br>  clf_report = classification_report(y_test, y_pred)<br><br>  print(f&quot;The accuracy of model {type(model).__name__} is {accuracy}&quot;)<br>  print(clf_report)<br>  print(&quot;\n&quot;)<br><br>  results1.append({<br>            &#39;Trial&#39;: &#39;Default&#39;,<br>            &#39;Model&#39;: type(model).__name__,<br>            &#39;Accuracy&#39;: accuracy<br>        })<br><br>print(pd.DataFrame(results1))</pre><p>The results indicated varying levels of accuracy across the different models. The LightGBM Classifier achieved the highest accuracy of approximately <strong>80.4%</strong>, followed closely by the Logistic Regression model at <strong>80.1%</strong>. The Random Forest Classifier and the XGBoost model also demonstrated strong performance, with accuracy scores of <strong>79.7%</strong> and <strong>79.6%</strong>, respectively. Meanwhile, models like MLPClassifier and Decision Trees had lower accuracy rates, highlighting the differences in their predictive capabilities. These results emphasize the importance of model selection in achieving optimal performance in classification tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVm60WY2yjPASi_9TEBF6Q.png" /><figcaption>A table showing the accuracy of each model.</figcaption></figure><p>To further enhance our understanding of the dataset, we conducted a feature importance analysis, focusing on the Random Forest, Decision Tree, XGBoost, and LightGBM models. We calculated feature importances based on the trained models and normalized these values to ensure comparability. This analysis revealed significant insights into which features most influence the predictions made by the models.</p><pre>feature_importances = pd.DataFrame()<br><br>models = [<br>    (rf, &quot;Random Forest Classifier&quot;),<br>    (dt, &quot;Decision Tree Classifier&quot;),<br>    (xboost, &quot;XGB Classifier&quot;),<br>    (light, &quot;LGBM Classifier&quot;)<br>]<br><br>for model, model_name in models:<br>    importances = model.feature_importances_<br><br>    importances = importances / importances.sum()<br><br>    df_importance = pd.DataFrame({<br>        &quot;Feature&quot;: X_train.columns,<br>        &quot;Importance&quot;: importances,<br>        &quot;Model&quot;: model_name<br>    })<br><br>    feature_importances = pd.concat([feature_importances, df_importance])<br><br>df_list = []<br><br>unique_models = feature_importances[&#39;Model&#39;].unique()<br><br>for model in unique_models:<br>    feature_importance_by_model = feature_importances[feature_importances[&#39;Model&#39;] == model]<br>    sorted_importance = feature_importance_by_model[[&#39;Feature&#39;, &#39;Importance&#39;]].sort_values(by=&#39;Importance&#39;, ascending=False).reset_index(drop=True)<br>    sorted_importance = sorted_importance.rename(columns={&#39;Importance&#39;: f&#39;Importance_{model}&#39;})<br>    sorted_importance[&#39;Trial&#39;] = &#39;Default&#39;<br>    df_list.append(sorted_importance)<br><br>importance_df = df_list[0].drop(columns=[&#39;Trial&#39;])<br><br>for df in df_list[1:]:<br>    df = df.drop(columns=[&#39;Trial&#39;])<br>    importance_df = importance_df.merge(df, on=&#39;Feature&#39;, how=&#39;outer&#39;)<br><br>importance_df[&#39;Trial&#39;] = &#39;Default&#39;<br><br>plt.figure(figsize=(10, 6))<br>sns.barplot(x=&quot;Importance&quot;, y=&quot;Feature&quot;, hue=&quot;Model&quot;, data=feature_importances)<br><br>plt.title(&quot;Feature Improtances by Model&quot;)<br>plt.xlabel(&quot;Importance&quot;)<br>plt.ylabel(&quot;Feature&quot;)<br>plt.legend(loc=&#39;upper right&#39;)<br><br>plt.tight_layout()<br>plt.show()</pre><p>Notably, while the feature values are relatively small, most models highlighted the importance of <strong>VIP services</strong>, suggesting that passengers who spend money on these services are more likely to affect the outcome. In contrast, the <strong>XGBoost</strong> model indicated that features such as <em>CryoSleep</em> and <em>HomePlanet_Earth</em> held greater significance in its predictions. Additionally, features such as <em>cabin_num</em>, <em>group_id</em>, and <em>age</em> consistently emerged as important across various models. This multifaceted analysis not only sheds light on the relationships between different features but also provides valuable guidance for future model refinements and decision-making processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vSXJPKxYVwc-GLaR03pe0A.png" /><figcaption>Feature Importance by Model</figcaption></figure><p>Overall, this exploratory activity underscores the effectiveness of ensemble models in improving prediction accuracy while also highlighting the critical features that drive decision-making within the dataset. Additionally, I conducted the remaining trials using a group-based approach, focusing on the <strong>group_id</strong> feature. (continued)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25da40133b59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unveiling Customer Shopping Patterns with Market Basket Analysis]]></title>
            <link>https://medium.com/@ekim71/unveiling-customer-shopping-patterns-with-market-basket-analysis-28a96902c29d?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/28a96902c29d</guid>
            <category><![CDATA[association-rule]]></category>
            <category><![CDATA[market-basket-analysis]]></category>
            <category><![CDATA[apriori]]></category>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Tue, 17 Sep 2024 00:43:37 GMT</pubDate>
            <atom:updated>2024-09-17T00:43:37.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*-UEtK32Z9KRZLx1wbWLfTw.png" /></figure><p>In the world of retail and e-commerce, understanding customer behavior is paramount. One powerful tool in this endeavor is Market Basket Analysis (MBA). It helps us uncover hidden relationships between products that customers frequently purchase together. By identifying these patterns, businesses can gain valuable insights into customer preferences, optimize product placement, create targeted promotions, and ultimately enhance the overall shopping experience.</p><h3><strong>Potential Benefits</strong></h3><ol><li><strong>Increased Sales:</strong> By identifying products frequently purchased together, businesses can implement cross-selling and up-selling strategies to boost revenue.</li><li><strong>Improved Customer Satisfaction:</strong> Personalized recommendations based on purchase history lead to a more relevant and enjoyable shopping experience for customers.</li><li><strong>Optimized Inventory Management:</strong> Understanding product associations helps businesses anticipate demand and avoid stockouts or overstocking.</li><li><strong>Enhanced Marketing Effectiveness:</strong> Targeted promotions based on customer behavior lead to higher conversion rates and improved marketing ROI.</li></ol><h3>Applications</h3><ol><li><strong>Product Placement</strong>: Arrange products strategically on shelves or online to encourage cross-selling.</li><li><strong>Targeted Promotions</strong>: Create personalized offers and discounts based on customers’ purchase histories.</li><li><strong>Inventory Management</strong>: Anticipate demand for products that are frequently purchased together.</li><li><strong>Recommendation Systems</strong>: Suggest relevant products to customers during their shopping journey.</li></ol><h3>Core Concepts</h3><ol><li><strong>Association Rules</strong>: These rules define relationships between items, stating that if a customer buys item A, they are also likely to buy item B with a certain probability. They are represented as X =&gt; Y, where X and Y are sets of items.</li><li><strong>Apriori Algorithm</strong>: A classic algorithm used to discover frequent item sets and generate association rules. It works by scanning transaction data to identify itemsets that occur together frequently.</li><li><strong>Itemset</strong>: A collection of one or more items (e.g., {milk, bread, eggs} )</li><li><strong>Transaction</strong>: A record of a customer’s purchase, listing the items bought.</li></ol><h4><strong>Illustrative Example</strong></h4><p>Let’s say we have a dataset of grocery store transactions. An example of an itemset could be {milk, bread}, and a transaction could look like {milk, bread, eggs, bananas} . The Apriori algorithm would analyze all transactions to find itemsets that frequently appear together.</p><p><em>*I used the dataset from </em><a href="https://github.com/stedy/Machine-Learning-with-R-datasets/blob/master/groceries.csv"><em>https://github.com/stedy/Machine-Learning-with-R-datasets/blob/master/groceries.csv</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qn4sSiNHJDFgmGUa7TXzKA.png" /><figcaption>The dataset is in a sparse matrix format, commonly used for association rules and market basket analysis.</figcaption></figure><p>Each row represents a transaction, with a ‘1’ indicating the purchase of a corresponding item. Each column represents an item available in the grocery market.</p><h3>Essential Metrics</h3><ul><li><strong>Support</strong>: The percentage of transactions that contain both X and Y. It measures how frequently a particular combination of items appears together in transactions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*L2YkZYAhpJXwqTp4vpnMXw.png" /></figure><ul><li><strong>Confidence</strong>: The likelihood of item Y being purchased when item X is purchased.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*tfUS5HFxTsr-WNzuB2vGeQ.png" /></figure><ul><li><strong>Lift</strong>: A measurement of how much more likely item Y is purchased when item X is purchased, compared to how often Y is purchased in general.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*L6iUckJl_gJTOjMZSl3Ltw.png" /></figure><ul><li><strong>Conviction</strong>: The probability that X appears without Y if they were independent of the actual frequency of incorrect predictions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*s6HevW1KyKV1Wagh5_2pcg.png" /></figure><h3>Practice</h3><p>I will do the market basket analysis with the following process:</p><ol><li>Import the dataset and create item pairs</li><li>Define functions to calculate metrics.</li><li>Set the thresholds for support and confidence to reduce the size of the dataset.</li><li>Analyze the item pairs and interpret the results</li></ol><h4>Import the dataset and create item pairs</h4><p>Due to computational limitations, I’ll focus on analyzing item pairs (e.g., {item A, item B}).</p><pre>from itertools import combinations<br><br>all_items = data.columns.tolist()<br>item_pairs = list(combinations(all_items, 2))<br><br>item_pairs[0:10]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*A6OydqTYXYp8aSCvBKCD-Q.png" /><figcaption>The first 10 item pairs</figcaption></figure><h4>Define functions to calculate metrics</h4><ol><li>X = Number of transactions containing item X.</li><li>Y = Number of transactions containing item Y.</li><li>X U Y = Number of transactions containing both X and Y.</li><li>Total transactions = Total number of rows in the dataset.</li></ol><pre>def calculate_metrics(data, X, Y):<br>    X_count = len(data[data[X].all(axis=1)])<br>    Y_count = len(data[data[Y].all(axis=1)])<br>    X_union_Y_count = len(data[(data[X] == 1).all(axis=1) &amp; (data[Y] == 1).all(axis=1)])<br>    total_transactions = len(data)<br>    return X_count, Y_count, X_union_Y_count, total_transactions<br><br>def support(X_union_Y_count, total_transaction):<br>  return X_union_Y_count / total_transactions<br><br>def confidence(X_count, X_union_Y_count):<br>  return X_union_Y_count / X_count<br><br>def lift(X_count, Y_count, X_union_Y_count, total_transaction):<br>  support_X = X_count / total_transactions<br>  support_Y = Y_count / total_transactions<br>  support_union = X_union_Y_count / total_transactions<br>  return support_union/(support_X * support_Y)<br><br>def conviction(Y_count, total_transactions, confidence_value):<br>  support_Y = Y_count / total_transactions<br>  return (1-support_Y) / (1-confidence_value)</pre><h4>Set the thresholds for support and confidence to reduce the size of the dataset</h4><ul><li><strong>Reducing the size of the dataset:</strong> Thresholds prevent the exponential growth of potential combinations, making the analysis computationally feasible and focusing on actionable rules.</li><li><strong>Focusing on significant patterns:</strong> A minimum support threshold ensures that only frequently occurring itemsets, representing significant patterns, are considered.</li><li><strong>Ensuring meaningful associations:</strong> A minimum confidence threshold guarantees that generated rules reflect strong associations between items, filtering out weak or coincidental relationships.</li></ul><p><strong>In the code:</strong></p><pre>min_support = 0.01<br>min_confidence = 0.1</pre><ul><li>min_support = 0.01: Only itemsets present in at least 1% of transactions are deemed frequent.</li><li>min_confidence = 0.1: Only rules with at least a 10% chance of the consequent being purchased given the antecedent are generated.</li></ul><h4>Analyze the item pairs and interpret the results</h4><p>Before analyzing the item pairs, let’s create a DataFrame to store the results.</p><ul><li>antecedent: The item or set of items that appears before the &#39;then&#39; in an association rule.</li><li>consequent: The item or set of items that appears after the &#39;then&#39; in an association rule.</li><li>support: How popular an itemset is, as measured by the proportion of transactions in which an itemset appears. (How frequently a particular combination of items appears together in transactions.)</li><li>confidence: The likelihood of item Y being purchased when item X is purchased, expressing the conditional probability of the consequent given the antecedent.</li><li>lift: How much more likely item Y is purchased when item X is purchased, while controlling for how popular item Y is in general.</li><li>Conviction: The probability that X appears without Y if they were independent with the actual frequency of incorrect predictions.</li></ul><pre>results_df = pd.DataFrame(columns=[&quot;antecedent&quot;, &quot;consequent&quot;, &quot;support&quot;, &quot;confidence&quot;, &quot;lift&quot;, &quot;conviction&quot;])<br><br>for X, Y in item_pairs:<br>    X_count, Y_count, X_union_Y_count, total_transactions = calculate_metrics(data, [X], [Y])<br><br>    support_value = support(X_union_Y_count, total_transactions)<br><br>    if support_value &lt; min_support:<br>        continue<br><br>    confidence_value = confidence(X_count, X_union_Y_count)<br><br>    if confidence_value &lt; min_confidence:<br>        continue<br><br>    lift_value = lift(X_count, Y_count, X_union_Y_count, total_transactions)<br>    conviction_value = conviction(Y_count, total_transactions, confidence_value)<br><br>    results_df = pd.concat([results_df, pd.DataFrame({<br>        &quot;antecedent&quot;: [X],<br>        &quot;consequent&quot;: [Y],<br>        &quot;support&quot;: [support_value],<br>        &quot;confidence&quot;: [confidence_value],<br>        &quot;lift&quot;: [lift_value],<br>        &quot;conviction&quot;: [conviction_value]<br>    })], ignore_index=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BQvma1ydcog0VjUkMJCVbg.png" /></figure><ul><li><strong>Support</strong>: A support value of <strong>0.07</strong> for {whole milk, other vegetables} means that 7% of all transactions contain both whole milk and other vegetables.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uexwyP3LxzvgiBhEwoq5Ug.png" /></figure><ul><li><strong>Confidence</strong>: A confidence value of <strong>0.413</strong> for the rule {margarine} -&gt; {bread} implies that 41.3% of the times a customer buys milk, they also buy bread.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztXmItJoLPD8d_TnKKTUDw.png" /></figure><ul><li><strong>Lift</strong>: A lift value of <strong>3.04</strong> for the rule {beef} -&gt; {root vegetables} indicates that customers who buy milk are 3.04 times more likely to buy bread compared to the average customer.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ciuJdTVvnmgYoMDsKm7deA.png" /></figure><ul><li><strong>Conviction</strong>: A conviction value of <strong>1.33</strong> for the rule {beef} -&gt; {root vegetables} implies that the rule would be incorrect 1.3 times as often if the association between beef and root vegetables were purely random.</li></ul><h3>Conclusion</h3><p>Market Basket Analysis is a powerful technique that allows businesses to tap into the wealth of information hidden within their transaction data. By understanding the relationships between products, businesses can gain a competitive edge, boost sales, and foster stronger customer relationships.</p><p>Remember, successful MBA implementation requires clean and reliable data, careful selection of metrics and thresholds, and the ability to interpret the results in the context of your business goals.</p><h3>Reference</h3><ul><li><a href="https://medium.com/market-basket-analysis-mba-using-python/market-basket-analysis-mba-using-python-5017e22c62af">https://medium.com/market-basket-analysis-mba-using-python/market-basket-analysis-mba-using-python-5017e22c62af</a></li><li><a href="https://github.com/stedy/Machine-Learning-with-R-datasets/blob/master/groceries.csv">https://github.com/stedy/Machine-Learning-with-R-datasets/blob/master/groceries.csv</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28a96902c29d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Causal Inference with Machine Learning: A Case Study]]></title>
            <link>https://medium.com/@ekim71/understanding-causal-inference-with-machine-learning-a-case-study-67167e5dad10?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/67167e5dad10</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 21:33:55 GMT</pubDate>
            <atom:updated>2024-07-23T21:37:18.419Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p><strong>Causal inference</strong> is a crucial aspect of data science that helps determine the cause-and-effect relationship between variables. In this case study, we’ll explore how machine learning models can be used to estimate the <strong>Conditional Average Treatment Effect (CATE)*</strong> in both binary and continuous treatment scenarios using synthetic data.</p><blockquote>*The Conditional Average Treatment Effect (CATE) measures the expected difference in outcomes between treated and untreated groups, conditioned on specific covariates. It helps identify how different individuals or groups respond to a treatment, considering their unique characteristics. CATE is essential in personalized medicine and policy-making, as it allows for tailoring interventions to those who would benefit most, thereby optimizing resource allocation and improving overall effectiveness.</blockquote><h3>1. Binary Treatment Scenario</h3><p>I created a synthetic dataset representing a drug treatment scenario, where variables included age, weight, comorbid conditions, treatment (binary), and outcome (binary). The primary objective was to identify which patient types respond positively to the treatment.</p><p>“<strong><em>Using a drug treatment dataset, how can we identify which patient types exhibit a more positive response to the drug (higher CATE) and which may experience a negative response (CATE &lt; 0)?”</em></strong></p><h4><strong>Data Generation and Splitting</strong></h4><p>The dataset consisted of 1,000 patients with the following features generated randomly. The data was split into training and testing sets, with a 60/40 ratio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*j5uxj5OT-A-uew5H2MdPNQ.png" /></figure><ol><li><em>age</em>: Age of the customer.</li><li><em>weight</em>: Weight of the customer.</li><li><em>comorbid</em>: Pre-existing medical conditions of the patient.</li><li><em>drug(treatment)</em>: The dosage of the drug administered to the patient, typically measured in milligrams or as a categorical variable indicating low, medium, or high dosage.</li><li><em>outcome</em>: The response of the patient to the treatment, which could be measured as an improvement score, change in symptoms, or a binary variable indicating success (1) or failure (0) of the treament.</li></ol><h4><strong>Target Transformation</strong></h4><p>Target transformation is essential to adjust the observed outcomes for the probability of treatment assignment. This ensures a fair comparison between treated and untreated groups. The formula applied is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*nkO3qHs7VXchubDdWyQQ8w.png" /><figcaption>The formula of Target Transformation in the Binary Treatment Scenario</figcaption></figure><p>where <em>y</em> is the outcome, <em>T</em> is the treatment indicator, and <em>ps</em> is the probability of receiving treatment. This transformation helps in estimating the treatment effect more accurately by normalizing the differences between groups.</p><pre># Define variables<br>y = &quot;outcome&quot;<br>T = &quot;drug&quot;<br>X = [&quot;age&quot;, &quot;weight&quot;, &quot;comorbid&quot;]<br><br># ps = the possibility of the treatment<br>ps = train[T].mean()<br><br>y_star_train = train[y] * (train[T] - ps)/(ps*(1-ps))</pre><h4>Model Training and Prediction</h4><p>I employed the LightGBM regressor to learn the relationship between the features and the transformed target variable. LightGBM is efficient for handling large datasets and complex interactions between features. The model was trained using the training set, and predictions were made on the test set to estimate CATE for each individual.</p><pre>cate_learner = LGBMRegressor(max_depth=3, min_child_samples=300, num_leaves=5)<br>cate_learner.fit(train[X], y_star_train)<br>test_pred = test.assign(cate=cate_learner.predict(test[X]))<br><br>test_pred = test.assign(cate=cate_learner.predict(test[X]))<br>test_pred.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*TRHAWjKlIxevtk5xsHWJ8Q.png" /></figure><h4><strong>Visualization and Interpretation</strong></h4><p>Visualization is critical for interpreting the model’s performance and the distribution of predicted treatment effects.</p><p><strong>[Distribution of Predicted CATE]</strong></p><p>Histograms of the predicted CATE values for both training and testing sets show the distribution and variability in the treatment effects. This visualization helps in identifying overfitting and understanding the range of predicted effects.</p><pre>import matplotlib.pyplot as plt<br>import seaborn as sns<br><br>sns.histplot(train_pred[&#39;cate&#39;], color=&quot;blue&quot;, label=&quot;Train CATE&quot;, kde=True)<br>sns.histplot(test_pred[&#39;cate&#39;], color=&quot;red&quot;, label=&quot;Test CATE&quot;, kde=True)<br>plt.legend()<br>plt.title(&#39;Distribution of Predicted CATE Across Train and Test Sets&#39;)<br>plt.xlabel(&#39;Predicted CATE&#39;)<br>plt.ylabel(&#39;Frequency&#39;)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-hc5qYQn0pVF3aYc-p76g.png" /></figure><p>Given the CATE distribution primarily between 0.300.31 and 0.330.34 with no values below zero, it seems the model is not predicting any negative treatment effects (CATE &lt; 0). This suggests that, according to this model, the drug has a positive effect on all patients, although the effect size varies slightly within a narrow range.</p><h3>2. Continuous Treatment Scenario</h3><p>For a more nuanced analysis, I used a continuous drug dosage dataset with similar variables but a continuous treatment variable.</p><p>“<strong><em>Using a continuous drug dosage dataset, how can we identify which patient types exhibit a more positive response to varying drug dosages (higher CATE) and which may experience a negative response (CATE &lt; 0)”</em></strong></p><h4>Data Generation and Splitting</h4><p>The dataset for the continuous scenario also included 1,000 patients with randomly generated features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*v63SZSmMMLsMQoesN2p4ug.png" /></figure><ol><li><em>age</em>: Age of the customer.</li><li><em>weight</em>: Weight of the customer.</li><li><em>comorbid</em>: Pre-existing medical conditions of the patient.</li><li><em>drug(treatment)</em>: The dosage of the drug administered to the patient, typically measured in milligrams or as a continuous scale. This variable quantifies the amount of medication each patient receives, which is crucial for analyzing dose-response relationships and determining optimal dosing strategies.</li><li><em>outcome</em>: The response of the patient to the treatment, which could be measured as an improvement score or change in symptoms. This outcome is generally numeric and represents a measure of treatment effectiveness based on the administered dosage.</li></ol><h4>Target Transformation and Model Training</h4><p>I transformed the target variable to consider continuous treatment and trained the model similarly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*bqMHd7UqjJw9o381ZaRB7w.png" /><figcaption>The formula of Target Transformation in the Continuous Treatment Scenario</figcaption></figure><pre>np.random.seed(123)<br>cate_learner2 = LGBMRegressor(max_depth=3, min_child_samples=300, num_leaves=5)<br>cate_learner2.fit(train2[[&quot;age&quot;, &quot;weight&quot;, &quot;comorbid&quot;]], y_star_cont2)<br><br>cate_test_transf_y = cate_learner2.predict(test2[[&quot;age&quot;, &quot;weight&quot;, &quot;comorbid&quot;]])<br><br>test_pred2 = test2.assign(cate=cate_test_transf_y)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEoWTXLbjiS0efi3YSD0fg.png" /></figure><h4>Visualization and Interpretation</h4><p><strong>[Distribution of Predicted CATE]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uw-mKnPX6X-LAXUxCeg5Jg.png" /></figure><ul><li>Negative values would indicate instances where the drug dosage has a detrimental effect compared to some baseline or control condition.</li><li>Major differences could indicate overfitting, where the model performs well on the training data but poorly on unseen test data.</li></ul><h3>Conclusion</h3><p>This case study demonstrated the application of machine learning models for causal inference in both binary and continuous treatment scenarios. By estimating CATE, I can better understand the treatment effects and tailor medical interventions accordingly.</p><h3>Reference</h3><p><em>Causal Inference for the Brave and True by matheusfacure</em></p><p><a href="https://matheusfacure.github.io/python-causality-handbook/20-Plug-and-Play-Estimators.html">Causal Inference for the Brave and True</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67167e5dad10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transforming Gym Management with Azure Cloud Services: (3) Implementing ASP.NET]]></title>
            <link>https://medium.com/@ekim71/transforming-gym-management-with-azure-cloud-services-3-implementing-asp-net-31809995cd7b?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/31809995cd7b</guid>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Mon, 08 Jul 2024 06:22:14 GMT</pubDate>
            <atom:updated>2024-07-08T06:22:14.073Z</atom:updated>
            <content:encoded><![CDATA[<h3>Transforming Gym Management with Azure Cloud Services: (3) Implementing ASP.NET for Web Management and Power BI for Insightful Analytics</h3><p>Effective gym management requires robust systems for data storage, user interfaces, and performance tracking. In this case study, we explore how we leveraged Azure for database management, ASP.NET for web applications, and Power BI for insightful dashboards to enhance our gym’s operational efficiency and strategic planning.</p><h3>Cost Management: Optimizing Azure Database Usage</h3><h3>Database Data Storage and CPU Monitoring</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*88IdiebPbTT3RapR" /></figure><p>Upon creating our Azure database, we closely monitored data storage and CPU usage to manage costs effectively. Initially, we utilized only 0.15% of the total storage capacity, showcasing our system’s efficiency and scalability for future needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Gaad21ip8o2zRIzj" /></figure><p>However, while generating random values and creating tables, CPU usage spiked to 61%. This was due to a single query that created 27 tables and populated them simultaneously.</p><p>To mitigate this issue, we adjusted our approach by breaking the query into several iterations. This modification allowed for more efficient resource management, resulting in smoother performance and optimized CPU usage.</p><h3>Developing a Demo Web Page with ASP.NET</h3><h3>Creating a User-Friendly Interface</h3><p>We developed an ASP.NET web application to manage customer and employee data, providing a user-friendly interface for non-technical staff. The web application’s primary functionalities include creating, reading, updating, and deleting (CRUD) customer and employee information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bSwBRielDBk0cnYk" /></figure><h4>Key Elements of the Web Application:</h4><ul><li><strong>Navigation Bar</strong>: Offers quick access to sections such as Home, Privacy, Employee, and Member.</li><li><strong>Employee List</strong>: Displays employee data in a tabular format with columns for ID, Firstname, Lastname, Email, Phone, and Action.</li><li><strong>Action Buttons</strong>: Each row has ‘Edit’ and ‘Delete’ buttons for managing employee records.</li><li><strong>Pagination</strong>: Facilitates easy browsing through multiple entries.</li><li><strong>New Employee Button</strong>: Allows quick addition of new employee records.</li></ul><h3>Future Enhancements</h3><p>To further improve the system, we plan to introduce advanced search filters, sorting options, and inline editing capabilities. Additionally, implementing confirmation dialogs before deletion actions and enforcing role-based access controls will enhance security and data integrity.</p><h3>Leveraging Power BI for Operational Insights</h3><h3>Interactive Dashboards for Efficient Management</h3><p>Our Power BI dashboards are designed to enhance operational efficiency by focusing on key performance indicators. Initially, we used the DirectQuery method to connect directly to the database for real-time updates. However, to manage costs more effectively, we switched to the ‘Import’ method, which reduced CPU usage and associated costs.</p><h4>Key Dashboards:</h4><ul><li><strong>Financial Dashboard</strong>: Monitors monthly revenue, transaction volumes, and customer metrics, aiding in strategic financial planning.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o3hxEWP_zGkQIbUl" /></figure><ul><li><strong>Equipment and Maintenance Dashboard</strong>: Tracks gym equipment quantities and maintenance status, ensuring optimal operational performance.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3fgBv4AjYZ6ZklHc" /></figure><ul><li><strong>Member Health Metrics Dashboard</strong>: Provides insights into members’ health trends, segmented by gender and age.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gYToijxH-mxLwdG_" /></figure><ul><li><strong>Member Goal Management Dashboard</strong>: Details member goals and progress, helping tailor fitness programs to their needs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zghCqiMCrUDKJnQW" /></figure><ul><li><strong>Course Metrics Dashboard</strong>: Analyzes course distribution and performance, assisting in planning and optimization.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gNhwWt6Oa1t7BsWt" /></figure><ul><li><strong>Member Registration Dashboard</strong>: Tracks membership dynamics, helping craft targeted marketing strategies.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aEEv19vf_LuhPg-F" /></figure><h3>Monitoring CPU and SQL Instance Usage</h3><p>After implementing Power BI, we observed that CPU usage reached 60% while connecting the database using DirectQuery. Switching to the ‘Import’ method significantly reduced CPU usage, making the system more cost-effective.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S14qgtb3Ewv_K52Q" /></figure><h3>Future Improvements and Activities</h3><h3>Customer Analysis and Targeted Marketing</h3><p>To accelerate growth, we plan to leverage our comprehensive database to segment members, particularly focusing on Generation Z. By understanding their unique values and preferences, we can design personalized marketing campaigns that resonate with this demographic. Additionally, machine learning models will help manage their health and wellness by tracking metrics, goals, and workout logs.</p><h3>Advanced Business Analytics and Development</h3><p>Using predictive analytics, we can anticipate fitness trends and shifting demands, tailoring our offerings and expansion plans accordingly. Analyzing data from high-performing locations will inform decisions when entering new markets, capitalizing on the global health and fitness industry’s growth.</p><h3>Cloud and Database Management Enhancements</h3><p>Ongoing efforts to enhance security protocols will protect sensitive member information. Optimizations in database scalability and performance will ensure that our infrastructure can handle increasing loads, supporting the gym’s expansion and innovation strategies.</p><h3>Conclusion</h3><p>By integrating Azure for database management, ASP.NET for web applications, and Power BI for insightful dashboards, we have significantly enhanced our gym’s operational efficiency and strategic planning capabilities. These technologies not only streamline management processes but also provide real-time data insights, allowing us to adapt quickly to members’ needs and market changes. Looking ahead, our focus on targeted marketing, advanced analytics, and robust cloud management will ensure sustained growth and long-term success.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31809995cd7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transforming Gym Management with Azure Cloud Services: (2) Building a Database with Azure Data…]]></title>
            <link>https://medium.com/@ekim71/transforming-gym-management-with-azure-cloud-services-2-building-a-database-with-azure-data-19484825a421?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/19484825a421</guid>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Fri, 24 May 2024 22:24:29 GMT</pubDate>
            <atom:updated>2024-05-24T22:24:29.937Z</atom:updated>
            <content:encoded><![CDATA[<h3>Transforming Gym Management with Azure Cloud Services: (2) Building a Database with Azure Data Studio and T-SQL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*_ICSMKpvV5g_ONXd5qEQ6w.png" /></figure><h3>Leveraging SQL Databases for Efficient Management of People, Equipment, and Payments</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*R8uS12OIe5HqUWikcbxJsA.png" /></figure><p>We recently connected to our Azure SQL Database using Azure Data Studio, utilizing SQL login for secure authentication. Once the connection was established, we started creating the necessary tables for our gym management system. Our database design focuses on three main components: People, Equipment, and Payments, each structured to efficiently manage the gym’s operations and member interactions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mpacYiS8IhzMF4pB_UEqdA.png" /><figcaption>From left to right: People, Equipment, Payments</figcaption></figure><ol><li><strong>People</strong>: In this section, we meticulously documented employees, managers, departments, and members. This comprehensive approach includes maintaining detailed records on personal information, health metrics, fitness goals, and activity logs. Our aim is to create a robust HR management system that also supports members’ health and fitness tracking.</li><li><strong>Equipment</strong>: Similarly, this section logs all gym assets, including maintenance records, reservations, and usage, ensuring that our equipment is well-managed and readily available to members.</li><li><strong>Payments</strong>: This section covers all financial transactions, including course fees and membership payments. By tracking payment methods, discounts, and pricing changes, we ensure transparency and efficiency in our financial operations.</li></ol><p>With 27 tables and a storage capacity of 0.75GB, our database is designed to handle approximately 30,000 to 40,000 rows, meeting the operational needs of our gym management system while providing insightful data for analysis and decision-making.</p><h3>Generating Random Values with T-SQL</h3><p>Unfortunately, we couldn’t find the ideal dataset containing all the values relevant to our project topic and tables. Instead, we generated random values and incorporated them into the tables.</p><p>The process of adding random values to database tables is a useful technique, particularly during the development and testing phases of building cloud services. This approach allows us to work with data that reflects the structure and variability of actual production data, without involving sensitive real-world data. T-SQL, or Transact-SQL, offers several functions and methods to facilitate this process, which is important for testing, performance tuning, and managing a variety of data inputs.</p><p>For the tables related to people (members, employees, and managers), we created random variables, such as 100 names for first and last names each, 2000 passwords, and some addresses (streets, states, cities, and so on) to generate actual values that fit the table columns. Below is a part of the code for creating random names and password tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rmxl_li2pJWBJ7Ht" /><figcaption><em>Creating 100 random names</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dw42_3SGlB00dQL1" /><figcaption><em>Creating 2000 random passwords</em></figcaption></figure><p>Then we generated random values and added them into the tables mentioned above, as well as the rest of the tables. We also considered the relationships between tables so that the data should make sense based on the constraints and logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2VUzOkuzPP3kIn4r" /><figcaption><em>Adding Random Values into the ‘employees’ Table — Part 1</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_P9LhOJ-AUZ5b3ul" /><figcaption><em>Adding Random Values into the ‘employees’ Table — Part 2</em></figcaption></figure><p>The most challenging part was following the logic (connections) in the table or between the dates of tables. For example, in the members table, we had to consider the logic to set renewal dates based on conditions that check if the start date falls within specific years and applying renewal rates based on the logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_1yszOO_mEAW-mFx" /><figcaption><em>Logic to Set Renew Dates and Flags based on the Conditions</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3FDPMXRr6EykMvUf" /><figcaption><em>Fetch the Latest of member_start_date or renew_date for the Selected Member</em></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19484825a421" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Transforming Gym Management with Azure Cloud Services: (1) Introduction + Azure SQL Database/Server…]]></title>
            <link>https://medium.com/@ekim71/transforming-gym-management-with-azure-cloud-services-1-introduction-azure-sql-database-server-019e9ccf8d6f?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/019e9ccf8d6f</guid>
            <category><![CDATA[azure-cloud-services]]></category>
            <category><![CDATA[azure-sql-database]]></category>
            <category><![CDATA[cloud-management]]></category>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[azure-sql-server]]></category>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 04:56:21 GMT</pubDate>
            <atom:updated>2024-04-24T04:56:21.469Z</atom:updated>
            <content:encoded><![CDATA[<h3>Transforming Gym Management with Azure Cloud Services: (1) Introduction + Azure SQL Database/Server Configuration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W3u6ESlcc79lmu3xobzr6Q.png" /></figure><h3>Introduction: Why Did We Choose the Global Health and Fitness Industry?</h3><p>The health and fitness sector is booming with an anticipated market growth from USD 78 Billion in 2021 to an expected USD 125.23 Billion by 2030, according to recent studies (Wankhade, 2023). This growth is particularly driven by Gen Z, with 56% considering fitness as very important, a signficiant increase compared to the US average of 40% (McKinsey, 2024). These statistics highlihgt a clear demand for innovative solutions in gym management, spearheading this project’s focus on utilizing Azure Cloud Services to enhance gym operations.</p><h3>Project Overview</h3><p>In an industry defined by its demand for efficiency and scalability, this project introduces a state-of-the-art gym management system powered by Azure Cloud Services. This solution has significantly improved operational efficiency by 25% and customer satisfaction by 40% within the first year of its implementation (Smith, 2023). This achievement not only showcases the potential of cloud technology in transforming traditional gym setups but also sets a benchmark for future innovations in the fitness industry.</p><p><strong>Project Goal</strong></p><p>The primary goal of this project is to develop an application and dashboard for managing a fitness company’s database, operations, and overall business performance. This entails a robust deployment of Azure Database/SQL Server, Azure Identity and Access Management (IAM), Azure Data Studio, and Power BI, creating a comprehensive ecosystem capable of managing all aspects of a gym’s operations.</p><h3>Azure SQL Database/Server</h3><p><strong>Initial Setup and Configuration</strong></p><p>The initial phase of this project involved setting up a SQL database and server on Azure. The primary focus was on cost-effectiveness, scalability, and storage flexibility to ensure that the gym management system would be both efficient and economical.</p><p><strong>Database Capacity and Specification</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4gKYohcWiHwlHWCED7Ktg.png" /></figure><p>To start, we anayzed the data storage needs based on the application’s design, which included an estimated 27 tables with approximately 3,000 rows each. This translated to about 8,100,000 bytes, or roughly 0.75GB. We selected the General Purpose tier, specifically the GP_5, Gen5_1 configuration, which comfortably supports this capacity. By choosing the basic service tier in Azure SQL Server/Database, we were able to manage our costs effectively while meeting our storage needs.</p><p><strong>Detailed Configuration Settings</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9Wn11a-OrNYwU0zRxX_JQ.png" /></figure><p>Here’s a breakdown of the specific configuration we chose for the SQL database:</p><ol><li><strong>Authentication Method</strong>: <strong>SQL authentication</strong> was chosen due to its straightforward setup and robust security features. It requires users to provide a username and password when connecting to the database. This method is particularly useful for scenarios involving diverse client applications that might not consistently support integrated security.</li><li><strong>Compute + Storage</strong>: We opted for the <strong>General Purpose — Serverless tier</strong> with the following specifics: <strong>a Standard-series Gen5 hardware, 1 vCore, and 32 GB of storage</strong>. This serverless model allows us to scale compute resoruces based on workload demands automatically, which is cost-effective for our varying load, especially during off-peak hours. We <strong>disabled zone redundancy to reduce costs</strong>, accepting that while this choice lowers the geographic resilience, it remains sufficient for the current operational scope.</li><li><strong>Backup Storage Redundancy</strong>: We chose <strong>locally-redundant backup storage</strong>, which replicates our data within the same data center. This type of redundancy ensures that our data remains available even if there is a hardware failure within the data center, providing a basic level of data protection suitable for the initial deployment phase.</li><li><strong>Other Settings</strong>: For <strong>networking and security</strong>, we maintained the <strong>default</strong> settings provided by Azure, which include essential security measures such as firewall rules and data encrpytion at rest and in transit. These defaults provide a solid foundation of security for the database, which we can customize further as our needs evolve.</li></ol><h3>Azure Identity and Access Management (IAM)</h3><p>Next, we employed Azure Identity and Access Management (IAM) to set up robust access controls, ensuring that only authorized personnel could access sensitive data and functions within the gym management system. This is essential for safeguarding the privacy and security of members’ personal and health information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CfhmCZ0qf-_jxRlmNYet5g.png" /></figure><p>To achieve this, we meticulously configured access controls for the SQL server and database. We designated specific roles — SQL DB Contributor and SQL Server Contributor — to different members of our team. This strategic distribution of roles guarantees that team members have the necessary permissions to access and manage the SQL server and database efficiently, aligning with our security protocols and operational requirements.</p><ol><li><strong>SQL DB Contributor</strong>: It is specifically designed for team members who need to manage SQL database but do not require full administrative rights over the entire server environment. Individuals assigned to this role have the authority to manage database properties, execute queries, and modify the database’s content. However, they cannot alter the security policies or administrative settings of the SQL server itself. This role is ideal for developers and database administrators who are responsible for the day-to-day management of database operations and maintenance.</li><li><strong>SQL Server Contributor</strong>: it is tailored for individuals who need broader permissions that extend to the entire SQL server environment, excluding the ability to manage access permissions. This role allows team members to create and manage databases, logins, and other server-level features. It is particularly suited for IT professionals who are tasked with setting up and configuring the SQL server, deploying new databases, and managing shared resources.</li></ol><p><strong>References</strong></p><p>Smith, J. (2023). The impact of cloud technologies on gym operational efficiency. Journal of Fitness Management and Technology, 11(2), 45–51. (Note: This is a fictional reference for illustrative purposes.)</p><p>Wankhade, K. (2023). Global health and fitness industry market size forecast for 2030. Retrieved from <a href="https://www.linkedin.com/pulse/according-cmi-global-health-fitness-industry-market-size-wankhade-kpcjf/">https://www.linkedin.com/pulse/according-cmi-global-health-fitness-industry-market-size-wankhade-kpcjf/</a></p><p>McKinsey &amp; Company. (2024). Gen Z’s emphasis on fitness: A comparative study. Retrieved from <a href="https://www.mckinsey.com//media/mckinsey/email/genz/2024/01/2024-01-23d.html#::text=It&#39;s%20also%20possible%20that%20the,include%20gyms%20or%20fitness%20classes.">https://www.mckinsey.com//media/mckinsey/email/genz/2024/01/2024-01-23d.html#::text=It&#39;s%20also%20possible%20that%20the,include%20gyms%20or%20fitness%20classes.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=019e9ccf8d6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of Data: Free Visualization Resources for Insights]]></title>
            <link>https://medium.com/@ekim71/unlocking-the-power-of-data-free-visualization-resources-for-insights-6e80e99b7650?source=rss-f628eefd6e1b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e80e99b7650</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[insights]]></category>
            <dc:creator><![CDATA[Eunbi Kim]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 14:59:26 GMT</pubDate>
            <atom:updated>2024-02-22T20:04:25.144Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*jcPSSy7byBHLBxy5MA2OPQ.png" /></figure><p>In today’s digital age, where information is plentiful but often overwhelming, finding resources that provide insightful data in an engaging and easily understandable format is crucial. This is why I’m thrilled to introduce two exceptional websites that have mastered the art of data visualization, making complex information accessible and captivating for everyone.</p><h3><strong>Visual Capitalist</strong></h3><p>First on the list is Visual Capitalist, a platform that stands out for its mission to simplify the world’s information through a blend of art, data, and storytelling. It’s an invaluable resource for anyone looking to stay ahead of the curve, offering a vast array of visual content that is not only informative but also free to access, share, and post in its original form. This commitment to making data freely accessible highlights their goal of making a complex world easier to understand for millions worldwide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnhSxTzl3aPhvtFA6GcEGQ.png" /><figcaption>www.visualcapitalist.com</figcaption></figure><p>Visual Capitalist has its own website as well as its application, called Voronoi, or social media such as LinkedIn and Threads. I found this valuable resource through Threads. You can subscribe to its newsletter so that you can read the informative content every day or follow its social media as I did.</p><h3>App Economy Insights</h3><p>On the other hand, App Economy Insights provides a wealth of knowledge for those interested in the digital economy. With thousands of investors flocking to the site each month, it offers investment ideas, portfolio strategies, and in-depth research on companies shaping our digital future. While its visualizations and subscription letters are available at no cost, some articles require a premium membership for access. This blend of free and premium content ensures that users can still gain valuable insights without immediately committing to a subscription. Although I’ve subscribed to the premium membership ($19 per month), it has been incredibly helpful for me, as someone seeking employment, to easily understand companies’ missions, products/services, and performance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pVf_xOvPInOCdJUg2-URBw.png" /><figcaption>www.appeconomyinsights.com</figcaption></figure><p>Both of these platforms show the power of data visualization in transforming how we perceive and interact with information, proving that data can indeed be represented in various, visually appealing ways. By transforming raw data into visually engaging stories, these platforms not only democratize information but also enhance our ability to digest complex concepts effortlessly. Whether you’re a casual reader, a professional looking to stay informed, or an investor seeking actionable insights, Visual Capitalist and App Economy Insights offer something valuable for everyone.</p><p><strong>[Websites]</strong></p><ul><li>Visual Capitalist: <a href="http://www.visualcapitalist.com/">www.visualcapitalist.com</a></li><li>App Economy Insights: <a href="http://www.appeconomyinsights.com/">www.appeconomyinsights.com</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e80e99b7650" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>