<?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 Dayana Vincent on Medium]]></title>
        <description><![CDATA[Stories by Dayana Vincent on Medium]]></description>
        <link>https://medium.com/@dayanavincent2000?source=rss-28541ecbe267------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WzExhmcS_Tw9m6O4</url>
            <title>Stories by Dayana Vincent on Medium</title>
            <link>https://medium.com/@dayanavincent2000?source=rss-28541ecbe267------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 20:42:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dayanavincent2000/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[Why 87% of ML Models Fail in Production?]]></title>
            <link>https://medium.com/@dayanavincent2000/why-87-of-ml-models-fail-in-production-ec3e4ef5af3b?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec3e4ef5af3b</guid>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Tue, 31 Dec 2024 14:15:41 GMT</pubDate>
            <atom:updated>2024-12-31T14:15:41.817Z</atom:updated>
            <content:encoded><![CDATA[<p>Deploying machine learning (ML) models into production is a challenging task. Studies suggest that nearly 87% of ML models fail in real-time environments. Early identification and resolution of these issues are crucial to prevent failures and prevent many business conclusions. This blog delves into a detailed analysis of the primary reasons why ML models often struggle in production.</p><p><strong><em>1. Choosing an Inappropriate Model</em></strong></p><p>There are various ML models available, ranging from base models like Linear Regression and Logistic Regression to advanced techniques such as LightGBM, XGBoost, and MLP (Multi-Layer Perceptron).</p><p><strong>Base Models</strong>: Easy to deploy but often underperform on complex data patterns.</p><p><strong>Advanced Models (Bagging &amp; Boosting Techniques)</strong>: Capable of handling non-linear, complex relationships, feature interactions, and variations in data effectively.</p><p>Key Insight: If a model performs well during training and testing but fails in production, the core issue often lies in the data quality, distribution shift, or insufficient generalization, overfitting, Class Imbalanced.</p><p><strong><em>2. Data Warehouse and Data Understanding in Model Building</em></strong></p><p>Data understanding is essential for building effective ML models. Poor data quality — inconsistencies, irregularities, incompleteness, and inaccuracy — leads to unreliable predictions, regardless of the model’s complexity.</p><p><strong>Single Source of Truth</strong>: Data should come from a centralized database to ensure consistency.</p><p><strong>Data Distribution</strong>: Understanding patterns, anomalies, and variations is crucial.</p><p><strong>Handling Missing Data</strong>: Address missing values appropriately.</p><p><strong>Business Context</strong>: Align data preprocessing with business requirements for better generalization.</p><p><strong><em>Clean, accurate, and well-structured data is the foundation for reliable ML models in production.</em></strong></p><p><strong><em>3. Data Drift issues</em></strong></p><p>Data drift occurs when the data the model was trained on no longer reflects the data it encounters in production. This can happen due to gradual changes, business shifts, or seasonal campaigns, affecting the model’s performance and reliability.</p><p>Example:</p><p>During a seasonal marketing campaign on social media, the incoming lead characteristics might differ significantly from the data the model was trained on. If not addressed, this drift can degrade model performance.</p><p>Key Actions to Address Data Drift:</p><p>Monitor Drift Regularly: Track changes in data patterns over time.</p><p>Evaluate Campaign Impact: Understand how frequently campaigns run and their effect on incoming data.</p><p>Retrain the Model: Decide when to retrain using fresh data while appropriately managing older data.</p><p>Conclusion: Continuous monitoring, analysis, and periodic retraining are essential to keep the model aligned with evolving data patterns.</p><p><strong><em>4. Data Leakage</em></strong></p><p>Data leakage occurs when information from the target variable unintentionally influences the training process, leading to overly optimistic performance during training and testing but poor results in production.</p><p>Common Causes of Data Leakage:</p><p>1. Future Information: Variables containing future insights (e.g., Number of follow-ups after booking, where booking is the target).</p><p>2. Train-Test Contamination: Mixing training and testing data during preprocessing or feature engineering, Feature Scaling or during any preprocessing techniques.</p><p><em>Key Mitigation Strategies</em>:</p><p>· Ensure proper data splitting before any feature engineering.</p><p>· Remove variables with future information about the target.</p><p>· Apply scaling and preprocessing independently on training and testing data.</p><p>· Regularly audit features for potential leaks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec3e4ef5af3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Drift is a Major Problem in Machine Learning? Solutions to Address Drift Issues]]></title>
            <link>https://medium.com/@dayanavincent2000/why-drift-is-a-major-problem-in-machine-learning-solutions-to-address-drift-issues-efdbc9a31db4?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/efdbc9a31db4</guid>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 00:48:53 GMT</pubDate>
            <atom:updated>2024-12-20T00:48:53.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*t5PQp9eWpTke0Fj_8TZUmg.png" /></figure><p>Drift is a critical challenge in machine learning and deep learning, particularly when models are deployed in real-time environments. It refers to changes in data or the relationship between data and target variables over time, which can significantly degrade model performance. Drift causes issues such as decreased accuracy, precision, recall, and overall reliability, leading to poor predictions and untrustworthy results in production. There are three primary types of drift:</p><p><strong>1. Data Drift</strong></p><p><strong>Definition</strong>:<br> Data drift occurs when the statistical distribution of input features changes over time, even if the relationship between features and the target variable remains constant. These shifts disrupt the model’s ability to generalize effectively to new data, making its predictions less accurate.</p><p><strong>Examples</strong>:</p><ul><li><strong>Environmental Factors</strong>: Changes in weather, geography, or seasonality can affect data distribution.</li><li><em>Example</em>: An e-commerce platform’s sales patterns may shift during a rainy season, impacting a weather-dependent product recommendation model.</li><li><strong>Economic Changes</strong>: Holidays, discounts, or major events can alter customer behavior.</li><li><em>Example</em>: Flight bookings may spike during holiday seasons due to promotional offers, affecting a model trained on data from off-peak periods.</li><li><strong>Customer Behavior</strong>: Shifts in preferences or behavior over time introduce variability.</li><li><em>Example</em>: In healthcare, preferences for teleconsultations during a pandemic might shift back to in-person visits as restrictions ease.</li><li><strong>New Features or Variables</strong>: Adding new features like “Loyalty Points” or “Membership Tier” changes the data distribution and impacts predictions.</li><li><strong>Missing Data</strong>: Software or logging errors can lead to incomplete datasets, further skewing distributions.</li></ul><p><strong>Impact</strong>:<br> If a model is trained on older data with a specific distribution and tested on new data with a different distribution, its predictions may fail to generalize effectively. For instance, in a lead conversion model, the number of calls received by a call center might fluctuate due to seasonal factors or the introduction of new communication channels, altering the input distribution.</p><p><strong>2. Concept Drift</strong></p><p><strong>Definition</strong>:<br> Concept drift occurs when the relationship between input features (<strong>X</strong>) and the target variable (<strong>Y</strong>) changes over time. This implies that the model’s assumptions about how features influence the target variable are no longer valid.</p><p><strong>Examples</strong>:</p><ul><li><strong>Seasonality</strong>: Appointment bookings in healthcare might increase during specific times of the year due to seasonal illnesses or campaigns.</li><li><strong>Climate</strong>: Different cities have varying climatic conditions that impact customer behavior. Cold weather in one city might increase healthcare appointments, while in another, it could reduce them due to accessibility issues.</li><li><strong>Economic or Regulatory Factors</strong>: Changes in economic conditions, new regulations, or competitor campaigns can alter the relationship between input variables and the target.</li><li><em>Example</em>: A lead scoring model trained to prioritize severe cases might struggle if, over time, less severe cases begin converting at a higher rate.</li></ul><p><strong>Impact</strong>:<br> Concept drift often leads to significant performance drops as the model can no longer capture the true relationship between features and the target variable.</p><p><strong>3. Model Drift</strong></p><p><strong>Definition</strong>:<br> Model drift is a combination of data drift and concept drift, where both the input data distribution and the relationship between features and the target variable change over time. This results in degraded model performance, increased false positives (FP), false negatives (FN), and reduced reliability.</p><p><strong>Impact</strong>:<br> Model drift makes predictions inaccurate and unreliable, causing issues in decision-making processes.</p><p><strong>How to Detect Data Drift During Model Training</strong></p><p>Data drift can occur even during the training phase when patterns in the data evolve over time. This makes models less effective in production despite being trained on large datasets.</p><p><strong>Examples</strong>:</p><ul><li>A lead scoring model might show that longer call durations (e.g., 9 minutes) lead to higher conversions in one year, but shorter call durations (e.g., 5 minutes) become more effective the next year.</li></ul><p><strong>Steps to Detect Data Drift</strong>:</p><ol><li><strong>Split Data Temporally</strong>:</li></ol><ul><li>Divide datasets into training and test sets based on time periods to identify distribution changes over time.</li></ul><ol><li><strong>Use Statistical Tests</strong>:</li></ol><ul><li>Perform statistical tests like:</li><li><strong>Population Stability Index (PSI)</strong>: Measures shifts in feature distributions.</li><li><strong>Kolmogorov-Smirnov (K-S) Test</strong>: Compares the distribution of a feature across datasets.</li></ul><ol><li><strong>Visualize Feature Shifts</strong>:</li></ol><ul><li>Use histograms, density plots, or boxplots to observe changes in key feature distributions.</li></ul><ol><li><strong>Monitor Performance Metrics</strong>:</li></ol><ul><li>Evaluate metrics like recall, precision, false positives (FP), and false negatives (FN) on test sets.</li></ul><p><strong>How to Handle Data Drift During Training</strong></p><ol><li><strong>Use Reliable Data</strong>:</li></ol><ul><li>Focus on data that reflects current trends to ensure better generalization.</li></ul><ol><li><strong>Weighted Training</strong>:</li></ol><ul><li>Assign higher weights to recent data and lower weights to older data to prioritize current patterns.</li></ul><ol><li><strong>Incremental Learning</strong>:</li></ol><ul><li>Use online learning models that can adapt in real-time as new data arrives.</li></ul><ol><li><strong>Regular Retraining</strong>:</li></ol><ul><li>Retrain models periodically (e.g., quarterly or yearly) or when drift metrics exceed thresholds.</li></ul><ol><li><strong>Feature Monitoring</strong>:</li></ol><ul><li>Continuously track feature importance and distributions to identify changes affecting predictions.</li></ul><p><strong>Backtesting for Drift Detection</strong></p><p><strong>Definition</strong>:<br> Backtesting involves training a model on data from a specific time period and testing it on subsequent time periods to evaluate its performance over time.</p><p><strong>Steps</strong>:</p><ol><li>Train the model on an initial time period (e.g., T1).</li><li>Test the model on subsequent periods (T2, T3, …, Tn).</li><li>Analyze performance metrics and feature distributions to detect drift.</li></ol><p><strong>Benefits</strong>:</p><ul><li>Helps identify temporal changes in data or feature-target relationships.</li><li>Ensures the model remains robust over time.</li></ul><p><strong>Tools for Drift Detection</strong></p><ul><li><strong>Evidently AI</strong>: Detects data drift, concept drift, and monitors model performance.</li><li><strong>River</strong>: A library for real-time machine learning and drift detection.</li><li><strong>Alibi Detect</strong>: Provides tools for detecting various types of drift.</li><li><strong>WhyLabs</strong>: Monitors data pipelines and detects drift in production.</li></ul><p><strong>Disadvantages of Data Drift</strong></p><ul><li><strong>Decreased Model Accuracy</strong>: Predictions fail to generalize, leading to unreliable outcomes.</li><li><strong>Increased FP/FN Rates</strong>: Misclassifications result in incorrect decisions.</li><li><strong>Business Impact</strong>: Drift leads to financial losses, regulatory risks, and reduced customer trust.</li></ul><p><strong>Conclusion</strong></p><p>Drift is an inevitable challenge in machine learning due to the dynamic nature of real-world data. By implementing robust monitoring tools, retraining strategies, and adaptive techniques, organizations can mitigate the impact of drift and ensure their models remain accurate and reliable over time.</p><p><em>To be continued with more concept and tools for data drift</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efdbc9a31db4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Secrets of Llama 2: A Beginner’s Guide]]></title>
            <link>https://medium.com/@dayanavincent2000/unlocking-the-secrets-of-llama-2-a-beginners-guide-c8bbe064a5f7?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8bbe064a5f7</guid>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Tue, 24 Oct 2023 18:44:22 GMT</pubDate>
            <atom:updated>2023-10-24T18:44:22.341Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article presents a very simple explanation about Llama 2, a wonderful groundbreaking concept from Meta AI. But why is this article worth your attention? Well, it serves as a key to unlock the theoretical underpinnings behind Llama 2. This isn’t just theory; it’s a crucial foundation for beginners in the world of LLMs. It allows you with the knowledge needed for future implementation. And here’s the best part of it : this article is entirely based on the Llama 2 research paper, ensuring you’re getting insights straight from the source. So, if you’re looking to start your journey of understanding Llama 2 and its future applications, you’ve found the perfect starting point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*uPgG8o9p-Z7fFcpjnv5gKg.jpeg" /></figure><p>Llama 2 (Large Language Model Meta AI) is a pre-trained and fine tuned large language model which has 7 billions to 700 billions of parameters. Meta AI claims that Llama 2 performs better than existing open-source models. Llama 2 is an advanced version of Llama 1 which is trained(over 2 trillion tokens of data)on public available data. One cool thing is they used a special method called “autoregressive transformers” to make Llama 2 better at understanding things. Not only the autoregression transformer they have applied various techniques like RMSNorm(Root Mean Square Layer Normalization- sucessful in NLP based models , It can handle the internal covariate shift issue to stabilize the layer activations and improve model convergence),SwiGLU( very popular swish activation function) activation function,increasing the context length ~ 4k and rotatory positional embeddings. The models was trained using AdamW optimizer with beta1=0.9,beta2=0.95 and eps=10^-5, weight edcay 0.1,batch size 64, gradient clipping of 0.1 and scheduling learning rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bx7geW1L1PCsk9MMPh_LyQ.jpeg" /></figure><h4><strong>Fine Tuning</strong></h4><p>Llama 2 uses auto regression,Ghost attention(GAtt) and RLHF techniques ,requiring computational and annotation resources. A ton of quality dataset collected is annotated using vendor- based annotation which proved a better model performance. As when comes to RLHF (Reinforcement Learning With Human Feedback) which is applied to fine tune the model to align model behavior with human preferences and instructions. Data collected represents sampled human preferences, whereby human annotators select which of two model output they prefer. This human feedback is used to train the reward model,which can learn insights from the human annotations and can make decisions based on it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8bbe064a5f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Augmentation using TensorFlow]]></title>
            <link>https://medium.com/@dayanavincent2000/data-augmentation-using-tensorflow-fca405530243?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/fca405530243</guid>
            <category><![CDATA[data-augmentation]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 10:13:41 GMT</pubDate>
            <atom:updated>2023-08-26T10:13:41.586Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article gives an idea to how to use TensorFlow for data augmentation as we came across using </em>TensorFlow’s ImageDataGenerator<em> in our CNN and other deep learning models. TensorFlow also gives methods to do Data Augmentation.</em></p><p><strong>Data augmentation using TensorFlow — </strong>This helps to improve the generalization ability of deep learning models, especially in scenarios with limited training data, increases training data size if it suffers from Data imbalance and increases the size and diversity of available data and thus improve the results. If a deep learning learning model is not properly trained with much enough data, it can cause overfitting and less to false predictions.</p><p><strong><em>Benefits of Data Augmentation:</em></strong></p><ul><li><strong>Data Imbalance Correction</strong>: Data augmentation can help mitigate the effects of class imbalance by generating more samples for underrepresented classes, thereby improving the model’s ability to learn from those classes.</li><li><strong>Regularization</strong>: Augmentation acts as a form of regularization, reducing the risk of overfitting by introducing noise and variations to the training data.</li><li><strong>Improved Generalization</strong>: The augmented data provides a broader representation of the data distribution, leading to better generalization on unseen data.</li></ul><p>So we need to find a way to find to increase the training data to decrease the loss. This involves using various techniques listed below:</p><h3>Data Augmentation on Multiple Images</h3><ol><li>Flipping of images</li><li>Gray Scale of Images</li><li>Saturate Images</li><li>Change Image Brightness</li><li>Center Crop on Images</li><li>Rotation at different Angles</li></ol><pre>def flip_images(image_path,output_path):<br>    image=load_img(image_path)<br>    image_array=img_to_array(image)<br>    flipped = tf.image.flip_left_right(image_array) #apply flip using tensorflow<br>    flipped_image=array_to_img(flipped)<br>    #save flipped images<br>    image_filename = os.path.basename(image_path)<br>    #print(image_filename)<br>    output_path = os.path.join(output_directory, f&#39;flipped_{image_filename}&#39;)<br>    flipped_image.save(output_path)<br><br>input_images_directory = &#39;/kaggle/input/pcb-dataset/Dataset&#39;<br>output_directory = &#39;/kaggle/working/&#39;    <br><br># Loop through each image in the input directory<br>for image_filename in os.listdir(input_images_directory):<br>    image_path = os.path.join(input_images_directory, image_filename)<br>    <br>    # Apply flip left-right and save<br>    flip_images(image_path, output_directory)</pre><h3>Visualisation of Flipped Images</h3><pre>def visualize(original, augmented):<br>    fig = plt.figure()<br>    plt.subplot(1,2,1)<br>    plt.title(&#39;Original image&#39;)<br>    plt.imshow(original)<br>    plt.axis(&quot;off&quot;)<br><br>    plt.subplot(1,2,2)<br>    plt.title(&#39;Augmented image&#39;)<br>    plt.imshow(augmented)<br>    plt.axis(&quot;off&quot;)<br>    <br>image_filename = os.listdir(input_images_directory)[4]<br>original_image = load_img(os.path.join(input_images_directory, image_filename))<br>flipped_image = load_img(os.path.join(output_directory, f&#39;flipped_{image_filename}&#39;))<br><br># Visualize the images<br>visualize(original_image, flipped_image)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*xqiaso5eWbItQJAlTVbfBg.png" /></figure><h3>Gray Scale of Images</h3><p>You can grayscale an image with tf.image.rgb_to_grayscale</p><pre>def grayscale_image(image_path, output_directory):<br>    image = Image.open(image_path)<br>    image_array = np.array(image)<br>    image_grayscale = tf.image.rgb_to_grayscale(image_array)<br>    array_image = Image.fromarray(tf.squeeze(image_grayscale).numpy().astype(np.uint8))<br>    <br>    image_filename = os.path.basename(image_path)<br>    output_path = os.path.join(output_directory, f&#39;grayscaled_{image_filename}&#39;)<br>    array_image.save(output_path)<br><br>input_images_directory = &#39;/kaggle/input/pcb-dataset/Dataset&#39;<br>output_directory = &#39;/kaggle/working/&#39;<br><br># Loop through each image in the input directory<br>for image_filename in os.listdir(input_images_directory):<br>    image_path = os.path.join(input_images_directory, image_filename)<br>    <br>    # Apply grayscale conversion and save<br>    grayscale_image(image_path, output_directory)</pre><pre>def visualize(original, augmented):<br>    fig = plt.figure()<br>    plt.subplot(1,2,1)<br>    plt.title(&#39;Original image&#39;)<br>    plt.imshow(original)<br>    plt.axis(&quot;off&quot;)<br><br>    plt.subplot(1,2,2)<br>    plt.title(&#39;Augmented image&#39;)<br>    plt.imshow(augmented)<br>    plt.axis(&quot;off&quot;)<br>    <br>image_filename = os.listdir(input_images_directory)[2]<br>original_image = load_img(os.path.join(input_images_directory, image_filename))<br>grayscale_image = load_img(os.path.join(output_directory, f&#39;grayscaled_{image_filename}&#39;))<br><br># Visualize the images<br>visualize(original_image, grayscale_image)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*DSqeAItveuuz7Ti8KWxMFA.png" /></figure><h3>Saturate images</h3><p>At different saturation levels</p><p>Saturate an image with tf.image.adjust_saturation by providing a saturation factor</p><pre>def saturated_images(image_path,output_path,images_sat):<br>    image=load_img(image_path)<br>    image_array=img_to_array(image)<br>    saturated = tf.image.adjust_saturation(image_array,images_sat) #apply flip using tensorflow<br>    saturated_image=array_to_img(saturated)<br>    #save flipped images<br>    image_filename = os.path.basename(image_path)<br>    #print(image_filename)<br>    output_path = os.path.join(output_directory, f&#39;saturated_images_{image_filename}&#39;)<br>    saturated_image.save(output_path)<br><br>input_images_directory = &#39;/kaggle/input/pcb-dataset/Dataset&#39;<br>output_directory = &#39;/kaggle/working/&#39;    <br><br># Loop through each image in the input directory<br>for image_filename in os.listdir(input_images_directory):<br>    image_path = os.path.join(input_images_directory, image_filename)<br>    <br>    for images_sat in [1,1.5,2,2.5]:<br>        saturated_images(image_path, output_directory,images_sat)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*kfjl9X2uHe8uI3G-vGuj-A.png" /></figure><h3>Change image brightness</h3><pre>def brightness_images(image_path,output_path,images_bright):<br>    image=load_img(image_path)<br>    image_array=img_to_array(image)<br>    saturated = tf.image.adjust_brightness(image_array,images_bright) #apply flip using tensorflow<br>    saturated_image=array_to_img(saturated)<br>    #save flipped images<br>    image_filename = os.path.basename(image_path)<br>    #print(image_filename)<br>    output_path = os.path.join(output_directory, f&#39;bright_{image_filename}&#39;)<br>    saturated_image.save(output_path)<br><br>input_images_directory = &#39;/kaggle/input/pcb-dataset/Dataset&#39;<br>output_directory = &#39;/kaggle/working/&#39;    <br><br># Loop through each image in the input directory<br>for image_filename in os.listdir(input_images_directory):<br>    image_path = os.path.join(input_images_directory, image_filename)<br>    <br>    for images_bright in [0.1,0.2,0.4]:<br>        brightness_images(image_path, output_directory,images_bright</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*Y_8aN5jU1jTeSVEQH15-3Q.png" /></figure><h3>Center crop on images</h3><p>Crop the image from center up to the image part you desire using tf.image.central_crop</p><pre>def center_images(image_path,output_path):<br>    image=load_img(image_path)<br>    image_array=img_to_array(image)<br>    center= tf.image.central_crop(image_array, central_fraction=0.5) #apply flip using tensorflow<br>    center_image=array_to_img(center)<br>    #save flipped images<br>    image_filename = os.path.basename(image_path)<br>    #print(image_filename)<br>    output_path = os.path.join(output_directory, f&#39;cropped_{image_filename}&#39;)<br>    center_image.save(output_path)<br><br>input_images_directory = &#39;/kaggle/input/pcb-dataset/Dataset&#39;<br>output_directory = &#39;/kaggle/working/&#39;    <br><br># Loop through each image in the input directory<br>for image_filename in os.listdir(input_images_directory):<br>    image_path = os.path.join(input_images_directory, image_filename)<br>    <br>    <br>    center_images(image_path, output_directory)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*jncN8c1MJTFOxYkwb364Iw.png" /></figure><h3>Rotation at different angles</h3><pre>from tensorflow.keras.preprocessing.image import ImageDataGenerator<br><br>def rotate_and_save_images(image_path, output_directory, rotation_angle_deg):<br>    image = Image.open(image_path)<br>    image_array = np.array(image)<br>    <br>    datagen = ImageDataGenerator(rotation_range=rotation_angle_deg)<br>    rotated_image = datagen.random_transform(image_array)<br>    <br>    rotated_pil_image = Image.fromarray(rotated_image.astype(np.uint8))<br>    <br>    image_filename = os.path.basename(image_path)<br>    output_path = os.path.join(output_directory, f&#39;rotated_{rotation_angle_deg}_{image_filename}&#39;)<br>    rotated_pil_image.save(output_path)<br><br><br>input_images_directory = &#39;/kaggle/input/pcb-dataset/Dataset&#39;<br>output_directory = &#39;/kaggle/working/&#39;<br><br># Loop through each image in the input directory<br>for image_filename in os.listdir(input_images_directory):<br>    image_path = os.path.join(input_images_directory, image_filename)<br>    <br>    # Apply different rotation angles and save<br>    for rotation_angle in [30, 60, 90]:  # Adjust these angles as needed<br>        rotate_and_save_images(image_path, output_directory, rotation_angle)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*maIYGAElxc0DEJQ97Y5T0A.png" /></figure><h3>References</h3><p><a href="https://www.tensorflow.org/tutorials/images/data_augmentation">https://www.tensorflow.org/tutorials/images/data_augmentation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fca405530243" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s have a fun with your own Alexa….]]></title>
            <link>https://medium.com/@dayanavincent2000/lets-have-a-fun-with-your-own-alexa-705485968dde?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/705485968dde</guid>
            <category><![CDATA[alexa-skills]]></category>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 15:11:26 GMT</pubDate>
            <atom:updated>2023-06-11T15:11:26.469Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article contains some features of Alexa such as current news, playing songs, current time, Climate, joke and which is build using some certain python libraries. Let start to explore more about it.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*pPx2r581OrdEIqdu0u-P-Q.gif" /></figure><h3>1. Install necessary packages</h3><ul><li>For using speech recognition functionalities we need to install</li></ul><p><strong># pip install SpeechRecognition</strong> (popular python library for speech recognition)</p><ul><li>pyttsx3 is popular package that allow for easy and more convenient way to perform text to speech conversion.</li></ul><p><strong>#pip install pyttsx3</strong></p><ul><li>For Alexa to tell jokes we are using pyjokes for install this</li></ul><p>#<strong> pip install pyjokes</strong></p><ul><li>For Alexa we need to Alexa to talk more about the relevant information for this we need to use wikipedia</li></ul><p>#<strong>pip install wikipedia</strong></p><h3>2. Import all above mentioned libraries</h3><p>for speech recognition functionalities we need to import</p><p><strong>import speech_recognition as sr</strong></p><pre>import warnings<br>warnings.filterwarnings(&#39;ignore&#39;)<br>import speech_recognition as sr<br>import pyttsx3<br>import pywhatkit<br>import datetime<br>import pyjokes<br>import wikipedia<br>import sys<br>import requests, json<br>import requests<br>import json<br>import http.client, urllib.parse<br>import urllib.parse<br><br><br># Twilio credentials<br>account_sid = &#39;YOUR_TWILIO_ACCOUNT_SID&#39; <br>#Create an twilio account for sending whatsapp messages <br># and after verifying the account , select the feature whatsapp and then copy the sid<br># and token provided and your whatsapp number<br>auth_token = &#39;YOUR_TWILIO_AUTH_TOKEN&#39;<br>whatsapp_number = &#39;YOUR_TWILIO_WHATSAPP_NUMBER&#39;<br><br>listener = sr.Recognizer() # it is used to provide source of Recognition we will use microphone<br><br>def fetch_news_headlines():<br>    conn = http.client.HTTPConnection(&#39;api.mediastack.com&#39;)<br>    params = urllib.parse.urlencode({<br>        &#39;access_key&#39;: &#39;provide your own access key&#39;, # create an account in mediastack and go to dashboard where we can find the accesskeyk<br>        &#39;categories&#39;: &#39;-general,-sports&#39;,<br>        &#39;sort&#39;: &#39;published_desc&#39;,<br>        &#39;limit&#39;: 5, # you can set any limit for the number of news<br>    })<br><br>    conn.request(&#39;GET&#39;, &#39;/v1/news?{}&#39;.format(params))<br><br>    res = conn.getresponse()<br>    data = res.read()<br>    parsed_data = json.loads(data)<br>    headlines = [article[&#39;title&#39;] for article in parsed_data[&#39;data&#39;]]<br>    <br>    return headlines<br><br><br><br><br>def engine_talk(text):<br>    engine = pyttsx3.init()<br>    voices = engine.getProperty(&quot;voices&quot;)<br>    engine.setProperty(&#39;voice&#39;, voices[1].id)<br>    engine.say(text)<br>    engine.runAndWait()<br><br>def user_commands():<br>    try:<br>        command = &quot;&quot;  # Initialize command with an empty string<br>        with sr.Microphone() as source:<br>            print(&quot;Start Speaking!!&quot;)<br>            voice = listener.listen(source)<br>            command = listener.recognize_google(voice)<br>            command = command.lower()<br>            command = command.replace(&#39;alexa&#39;, &#39;&#39;)<br>            if &#39;alexa&#39; in command:<br>                print(command)<br>    except:<br>        pass<br>    return command<br><br><br>def weather(city):<br>    # Enter your API key here<br>    api_key = &quot;YOUR_OPENWEATHERMAP_API_KEY&quot;<br>    base_url = &quot;http://api.openweathermap.org/data/2.5/weather?&quot;<br><br>    city_name = city<br>    complete_url = base_url + &quot;appid=&quot; + api_key + &quot;&amp;q=&quot; + city_name<br><br>    response = requests.get(complete_url)<br>    x = response.json()<br><br>    if x[&quot;cod&quot;] != &quot;404&quot;:<br>        y = x[&quot;main&quot;]<br>        current_temperature = y[&quot;temp&quot;]<br>        temp_in_celcius = current_temperature - 273.15<br>        return str(int(temp_in_celcius))<br><br>def send_whatsapp_message(to_number, message):<br>    client = Client(account_sid, auth_token)<br>    message = client.messages.create(<br>        body=message,<br>        from_=f&quot;whatsapp:{whatsapp_number}&quot;,<br>        to=f&quot;whatsapp:{to_number}&quot;<br>    )<br>    print(&quot;Message sent:&quot;, message.sid)<br><br>def run_alexa():<br>    command = user_commands()<br>    if &#39;play a song&#39; in command:<br>        song = &#39;Vineeth Shreenivasan&#39;<br>        engine_talk(&#39;Playing some music&#39;)<br>        print(&quot;Playing....&quot;)<br>        pywhatkit.playonyt(song)<br>    elif &#39;play&#39; in command:<br>        song = command.replace(&#39;play&#39;, &#39;&#39;)<br>        engine_talk(&#39;Playing....&#39; + song)<br>        print(&quot;Playing....&quot;)<br>        pywhatkit.playonyt(song)<br>    elif &#39;time&#39; in command:<br>        time = datetime.datetime.now().strftime(&#39;%I:%M %p&#39;)<br>        print(time)<br>        engine_talk(&#39;Current Time is&#39; + time)<br>    elif &#39;joke&#39; in command:<br>        get_j = pyjokes.get_joke()<br>        print(get_j)<br>        engine_talk(get_j)<br>    elif &#39;who is&#39; in command:<br>        person = command.replace(&#39;who is&#39;, &#39;&#39;)<br>        info = wikipedia.summary(person, 1)<br>        print(info)<br>        engine_talk(info)<br>    elif &#39;weather&#39; in command:<br>        city = &#39;Hong Kong&#39;<br>        engine_talk(&#39;The temperature in Hong Kong is &#39; + weather(city) + &#39; degree Celsius&#39;)<br>    elif &#39;send message&#39; in command:<br>        engine_talk(&quot;Sure, please provide the recipient&#39;s phone number and the message content.&quot;)<br>        recipient_number = input(&quot;Recipient&#39;s Phone Number: &quot;)<br>        message_content = input(&quot;Message Content: &quot;)<br>        send_whatsapp_message(recipient_number, message_content)<br>        engine_talk(&quot;Message sent successfully.&quot;)<br>   <br>    elif &#39;news&#39; in command:<br>        headlines = fetch_news_headlines()<br>        if headlines:<br>            engine_talk(&#39;Here are the latest news headlines:&#39;)<br>            engine_talk(headlines)<br>        else:<br>            engine_talk(&#39;Sorry, I could not fetch the news headlines.&#39;)<br>    elif &#39;stop&#39; in command:<br>        engine_talk(&quot;Goodbye!&quot;)<br>    elif &#39;how are you&#39; in command:<br>        engine_talk(&quot;I am Good. What about you&quot;)    <br>    else:<br>        engine_talk(&quot;I didn&#39;t hear you properly&quot;)<br>        print(&quot;I didn&#39;t hear you properly&quot;)<br><br>run_alexa()</pre><p>Thank you have a nice day with Alexa !!!!!!!!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=705485968dde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Classification Models]]></title>
            <link>https://medium.com/@dayanavincent2000/image-classification-models-6ee1faf06927?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ee1faf06927</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[alexnet]]></category>
            <category><![CDATA[image-classification]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Tue, 25 Apr 2023 07:40:28 GMT</pubDate>
            <atom:updated>2023-04-25T07:42:09.308Z</atom:updated>
            <content:encoded><![CDATA[<h3>Image Classification Models (part 1)</h3><p>Note : The model’s performance can be compared based on the dataset and its hyperparameters . Because it is necessary to analyse which model suits for the given research problem.</p><p>In this article I’m going to discuss how the model works based on the my observation for Face Mask Detection 😷.</p><p>The models that are commonly used for Image Classification are:</p><ol><li>AlexNet :A deep convolutional neural network (CNN) designed by Alex Krizhevsky, Ilya Sutskever, and Geoffrey Hinton from University of Toronto. It won the ImageNet Large Scale Visual Recognition Challenge (ILSVRC) in 2012 by achieving a top-5 error rate of 15.3%, significantly lower than the 26.2% error rate of the runner-up. AlexNet was one of the first deep CNNs to demonstrate the power of deep learning in image recognition tasks. It consists of eight learned layers, including five convolutional layers and three fully connected layers. The architecture of AlexNet is as follows:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arJJYgK-_7VcuKKX1TCKMA.png" /><figcaption>source : <a href="https://www.kaggle.com/code/blurredmachine/alexnet-architecture-a-complete-guide/notebook">https://www.kaggle.com/code/blurredmachine/alexnet-architecture-a-complete-guide/notebook</a></figcaption></figure><ul><li>The input is an RGB image of size 224x224 pixels.</li><li>The first layer is a convolutional layer with 96 filters of size 11x11 and a stride of 4 pixels. The output is passed through a rectified linear unit (ReLU) activation function and then through a max pooling layer with a stride of 2.</li><li>The second layer is also a convolutional layer with 256 filters of size 5x5 and a stride of 1. Again, the output is passed through a ReLU activation function and then through a max pooling layer with a stride of 2.</li><li>The third layer is a convolutional layer with 384 filters of size 3x3 and a stride of 1. There is no pooling layer after this layer.</li><li>The fourth layer is a convolutional layer with 384 filters of size 3x3 and a stride of 1. Again, there is no pooling layer after this layer.</li><li>The fifth layer is a convolutional layer with 256 filters of size 3x3 and a stride of 1. This layer is followed by a max pooling layer with a stride of 2.</li><li>The fully-connected layers have 4096 neurons each. The last layer has 1000 neurons corresponding to the 1000 classes in the ImageNet dataset.</li></ul><p>AlexNet uses several techniques to improve performance, including the use of ReLU activations, Reduce Overfitting(Dropout,Data Augmentation),local response normalization,Overlapping Pooling. The use of GPUs for training also allowed for faster training times.</p><blockquote><strong>What is Local Response Normalisation?</strong></blockquote><blockquote>Local Response Normalisation is applied for AlexNet to normalize the output of each neuron based on its neighbouring neurons in its same activation map. The main goal of LRN is to enhance the features which importantly identified by the neurons and avoid irrelevant features.</blockquote><blockquote>LRN is applied after activation function and before max pooling (down sampling).</blockquote><p>2. VGG19</p><p>VGG19 is a deep convolutional neural network architecture that was developed by the Visual Geometry Group (VGG) at the University of Oxford. It was introduced in the 2014 paper “Very Deep Convolutional Networks for Large-Scale Image Recognition” by Simonyan and Zisserman.</p><p>The VGG19 architecture consists of 19 layers, including 16 convolutional layers and 3 fully connected layers. The convolutional layers have a fixed kernel size of 3x3 and a stride of 1, and are followed by max pooling layers with a kernel size of 2x2 and a stride of 2. The fully connected layers have 4096 neurons each, and are followed by a final output layer with 1000 neurons, corresponding to the 1000 ImageNet classes.</p><p>The VGG19 architecture is known for its simplicity and high accuracy in image recognition tasks, and has been used as a base model in many computer vision applications. However, it is also a computationally expensive model, requiring a large amount of memory and processing power for both training and inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8mFtY_COg-j4V-Awtxnx5Q.png" /><figcaption>source:<a href="https://www.kaggle.com/code/sagnik1511/transfer-learning-with-vgg-19">https://www.kaggle.com/code/sagnik1511/transfer-learning-with-vgg-19</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ee1faf06927" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keyword Extraction using Happy Transformer]]></title>
            <link>https://medium.com/@dayanavincent2000/keyword-extraction-using-happy-transformer-e41b31e98bd0?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/e41b31e98bd0</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[transformers]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 11:56:45 GMT</pubDate>
            <atom:updated>2023-04-26T10:35:33.244Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>KeyBERT</strong> is a library developed by Maarten Grootendorst in 2020 that uses BERT-based embeddings to extract keywords or keyphrases from a given text. It works by first generating contextualized embeddings for the words in the input text using a pre-trained BERT model, and then using those embeddings to rank the words or phrases based on their relevance to the overall text.</p><p><strong>KeyBERT</strong> can be useful for a variety of natural language processing tasks, including text summarization, information retrieval, and keyword-based topic modelling. It is a relatively lightweight and easy-to-use library.</p><p><strong>INSTALL NECASSARY LIBRARIES</strong></p><pre>!pip install keybert<br>!pip install sentence-transformers</pre><p><strong>IMPORT LIBRARIES</strong></p><pre>from keybert import KeyBERT<br>from sentence_transformers import SentenceTransformer</pre><p><strong>CONFIGURE THE KEYBERT MODEL</strong></p><pre>model = SentenceTransformer(&#39;sentence-transformers/all-mpnet-base-v2&#39;)<br>keyBERT_model = KeyBERT(model = model)</pre><p>This model has been trained on a large corpus of text data and can be used to generate high-quality sentence embeddings, which are fixed-length representations of text that capture its semantic meaning.</p><p>Keywords and keyphrases extraction</p><pre>keywords = keybert_model.extract_keywords(text, top_n=5)<br>for keyword in keywords:<br>    print(keyword)</pre><p>(‘analytics’, 0.4008)</p><p>(‘nlp’, 0.3798)</p><p>(‘prediction’, 0.3661)</p><p>(‘organization’, 0.3473)</p><p>(‘regression’, 0.3427)</p><p>(‘apply’, 0.3348)</p><p>(‘data’, 0.3341)</p><p>(‘collaboratively’, 0.3309)</p><p>(‘topic’, 0.3269)</p><p>(‘classification’, 0.3246)</p><p>time: 8.43 ms (started: 2023–04–16 11:28:34 +00:00)</p><p>This is the resultant of the above code this gives the cosine similarity of the keyword extracted from the text in a contextual manner.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e41b31e98bd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Semantic Analysis]]></title>
            <link>https://medium.com/@dayanavincent2000/semantic-analysis-fdc08b2e22d4?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdc08b2e22d4</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[nlp-courses]]></category>
            <category><![CDATA[semantic-analysis]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Sun, 16 Apr 2023 11:36:02 GMT</pubDate>
            <atom:updated>2023-04-16T11:55:01.810Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*c8UOjRhMsCF9m1TvQzXMLQ.png" /></figure><h3><strong>What is Semantic Analysis ?</strong></h3><p>Semantic Analysis is a process to get meaning from text. It can be helpful to analyze paragraphs, sentences, and text documents. This helps to understand the grammatical structure and relationship between the individual words in the text and their context.</p><p>for example, He is in a terrible state</p><p>In the above sentence, there is an existence of <em>Semantic Ambiguity</em> here state refers to any mental state (mood of the person) or any geographical region.</p><p>This can be useful in the areas of marketing, and customer services, to understand customer sentiment and identify trends and improve communication. Every time semantic analysis is NOT always seen as 100% accurate because it depends on languages to languages and their complexities.</p><p>Semantic analysis is different from Lexical analysis because it focuses on a large corpus. Therefore we can divide the semantic analysis into two parts.</p><ul><li>Analysis of the relationship between the individuals’ words ::::: This is a lexical based analysis that focuses on the meaning and relationship between the individual words</li></ul><p>For example: “ <strong>I am happy today.</strong>” I — the subject, am — verb, happy — adjective.</p><ul><li>Analysis of relationship between the combination of words:::: This is an example of semantic analysis which looks for the relations between the combinations of individual words.</li></ul><p>For example He lost his bicycle.</p><p>By analyzing the combination of words <strong>“lost his bicycle”</strong> a semantic analysis could recognize that this implies that the person had ownership of the bicycle and has now lost it, rather than just analyzing the individual words “lost,” “his,” and “bicycle” in isolation.</p><p>Thus this helps to understand the context better than lexical analysis (focuses on individual words).</p><h3><strong>Way to get meaning from the corpus !!!!!</strong></h3><p>Sometimes one words can have different meaning.</p><p>This can be handled using</p><ul><li>Word Sense Disambiguation</li><li>Relationship Extraction</li></ul><blockquote>Word Sense Disambiguation using NLTK</blockquote><pre>import nltk<br>nltk.download(&#39;punkt&#39;)<br>nltk.download(&#39;wordnet&#39;)<br>from nltk.wsd import lesk<br>from nltk.tokenize import word_tokenize<br><br>a1= lesk(word_tokenize(&#39;I went to the bank to deposit my money.&#39;),&#39;bank&#39;)<br>print(a1,a1.definition())</pre><blockquote>Relationship Extraction</blockquote><pre>import spacy<br>from spacy.matcher import Matcher <br>from spacy import displacy <br>import visualise_spacy_tree<br>from IPython.display import Image, display<br>nlp = spacy.load(&#39;en_core_web_sm&#39;,disable=[&#39;ner&#39;,&#39;textcat&#39;])<br>doc = nlp(&#39;Atiq Ahmed, who was under police escort, was talking to reporters when a gun was pulled close to his head in Prayagraj, also known as Allahabad. &#39;)<br>png = visualise_spacy_tree.create_png(doc)<br>display(Image(png))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLQOTiUh0Ck3CvswlTi57g.png" /></figure><h3>— — — — — — — — — — — — — — — — — — — — — — — —</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdc08b2e22d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regression Methods (Part 1)]]></title>
            <link>https://medium.com/@dayanavincent2000/regression-methods-f17a49672e5e?source=rss-28541ecbe267------2</link>
            <guid isPermaLink="false">https://medium.com/p/f17a49672e5e</guid>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Dayana Vincent]]></dc:creator>
            <pubDate>Sat, 08 Apr 2023 16:16:53 GMT</pubDate>
            <atom:updated>2023-04-08T16:36:12.215Z</atom:updated>
            <content:encoded><![CDATA[<p><em>I will share my ideas on how to clean the dataset, deal with outliers, multicollinearity, feature selection, and different Regression techniques for linear and non-linear relationships. I uploaded the whole code to my GitHub page ….Don’t forget to follow me for more updates</em></p><p>Regression is a statistical analysis technique to find the relationship between the dependent (response) variable and the Independent (predictor) variable. Relationship between the dependent and independent can be</p><ol><li>Linear Relationship — The relationship between the independent and dependent variable is linear, i.e the output of their relationship is a straight line. Regression techniques that can model the linear relationship are Simple linear regression, Multiple linear regression.</li></ol><figure><img alt="source : https://en.wikipedia.org/wiki/Simple_linear_regression" src="https://cdn-images-1.medium.com/max/300/1*UZpUW4-hMBsXzvecyGeNYw.png" /><figcaption>source : <a href="https://en.wikipedia.org/wiki/Simple_linear_regression">https://en.wikipedia.org/wiki/Simple_linear_regression</a></figcaption></figure><p>2) Non-Linear relationship — The relationship between the dependent and Independent variable is Non-Linear, i.e the output can be exponential, logarithmic, curves, or other complex shapes. To model non-linear relationships we can use Polynomial regression, Exponential regression, Poisson Regression, and many more… we will be seeing it later…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*-W0nlmk27Tmn4VT1pJ3whQ.png" /><figcaption>source:<a href="https://easystats.github.io/modelbased/articles/describe_nonlinear.html">https://easystats.github.io/modelbased/articles/describe_nonlinear.html</a></figcaption></figure><p><em>First, Let’s Start with Linear Regression</em></p><h3>Simple Linear Regression</h3><p>The relationship between one dependent and one Independent Variable.</p><p>Mathematically we can write it as, y = b0 + b1x + e</p><blockquote>where y — is the dependent variable</blockquote><blockquote>b0 — y intercept /constant (The expected value of y when x=0)</blockquote><blockquote>b1- slope/coefficient ( The change in y when there is a unit change in x)</blockquote><blockquote>x- independent variable</blockquote><blockquote>e — a sum of the square of residuals (residual = actual value -predicted value)</blockquote><p>Example: Height (dependent variable) and Weight (Independent Variable)</p><p>In 2D if we plot values of x along the x-axis and y along the y-axis,b0: the constant or intercept the value of y when x =0, b1: the slope of the line which gives the rate of change in y with a unit change in x which means that b1 gives the direction and steepness for the best fit of data points on the line.</p><p><em>The goal of simple linear regression is to find the coefficient estimates (bo,b1) for the given regression equation that will best fit the data points.</em></p><h3>Multiple Linear Regression</h3><p>The relationship between one dependent and two or more Independent variables. The output of their relationship is a straight line</p><blockquote>Mathematically this can be represented as,</blockquote><blockquote>y = b0 +b1x1 +b2x2+………+bnxn+e</blockquote><blockquote>where,</blockquote><blockquote>y- dependent variable</blockquote><blockquote>x- independent variable</blockquote><blockquote>x1,x2,…..xn — the independent variables</blockquote><blockquote>e- sum of the square of residuals</blockquote><p>Assumptions in Multiple Regression</p><ul><li>Linearity: There is a linear relationship between the dependent and independent variables. If not, then we cannot use MLR we have to use polynomials, Poisson regression, etc…</li><li>No Multicollinearity: There is no Multicollinearity (Multicollinearity is the situation where there is a high correlation between the independent variables).</li><li>Homoscedasticity: There is constant error variance (This means that the variability of error should remain constant even if there is a change in values of independent variables).</li><li>Normality: The errors should be normally distributed.</li><li>Outliers: The model will get highly affected by the presence of outliers which can affect the fitness of the model and coefficient estimates. Various steps can be taken to reduce these effects.</li><li>Independence: The observations should be independent of each other.</li></ul><p>Advantages of Multiple Linear Regression</p><p>😎 : I can deal with many independent variables</p><p>😎 : I can capture complex relationships between the variables</p><p>😎 : I can deal with categorical and continuous variables.</p><p>😎 : I will allow hypothesis tests between the dependent and independent variables, as well as the testing of the fitness of data points.</p><p>Disadvantages of Multiple Linear Regression</p><p>😥 : One of the assumptions: is that there should be linear relation. If the relation is non-linear if we are fitting the MLR then the following problems will occur 1) Wrong coefficient estimates 2) Poor fit which will lead to high residuals 3) Wrong predictions</p><p>😥 : Overfitting: This occurs when model is too complex. This can be solved using Winsorization, Trimming, Regularization techniques ( L1 and L2 regularization), Gradient boosting regression. Their presence can be visualized using a boxplot, scatterplot, or histogram.</p><p>😥 : Complexity: MLR can be complex and time-consuming to implement, especially when there are many independent variables or interactions between them.</p><p>😥 : Sample size: MLR requires a relatively large sample size to produce stable and reliable estimates of the coefficients.</p><p>Let us do practice Multiple Regression using Python on next page….😎</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f17a49672e5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>