<?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 Mountasser on Medium]]></title>
        <description><![CDATA[Stories by Mountasser on Medium]]></description>
        <link>https://medium.com/@moontucer?source=rss-3fee132feca3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xcEVnpyeveQwEejVNCTNvg.jpeg</url>
            <title>Stories by Mountasser on Medium</title>
            <link>https://medium.com/@moontucer?source=rss-3fee132feca3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:46:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moontucer/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[Data Streaming Project: Real-Time End-to-End Data Pipeline]]></title>
            <link>https://medium.com/@moontucer/data-streaming-project-real-time-end-to-end-data-pipeline-082f0d9cfbdb?source=rss-3fee132feca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/082f0d9cfbdb</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Mountasser]]></dc:creator>
            <pubDate>Wed, 25 Oct 2023 23:37:28 GMT</pubDate>
            <atom:updated>2023-10-29T18:07:28.077Z</atom:updated>
            <content:encoded><![CDATA[<h3>Intro</h3><p>— — — — — — — — —</p><p>Data engineering is a crucial phase of the modern data ecosystem that enables companies to store, process, and make sense of large amounts of data. Creating robust, scalable, and fault-tolerant data pipelines is a complex task that requires multiple tools and techniques. In this article, I will show you how I built a simple end-to-end data engineering project using Docker, Apache Airflow, Kafka, Spark, Cassandra, PostgreSQL, and GitHub Actions. We discuss how these technologies work together to ingest, process, and store data.</p><h3>Tools</h3><p>— — — — — — — — —</p><ol><li><strong>Python</strong>: High-level programming language known for its simplicity and versatility.</li><li><strong>Docker</strong>: Tool for creating consistent and isolated application containers.</li><li><strong>Git</strong>: Version control system for tracking changes in source code.</li><li><strong>GitHub Actions</strong>: CI/CD tool integrated into GitHub for workflow automation.</li><li><strong>Apache Airflow</strong>: Open-source tool for scheduling and monitoring workflows.</li><li><strong>Apache Kafka</strong>: Distributed system for high-throughput data streaming.</li><li><strong>Apache Spark</strong>: Engine for processing large datasets, supports streaming, SQL, ML, and graph tasks.</li><li><strong>PySpark</strong>: Python library for interfacing with Apache Spark.</li><li><strong>Apache Cassandra</strong>: NoSQL DB for large-scale, fault-tolerant data storage.</li><li><strong>PostgreSQL</strong>: Open-source relational DB emphasizing extensibility and SQL standards.</li></ol><h3>Project Architecture</h3><p>— — — — — — — — —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qysmnu4x8B-lV3DLxPCppw.png" /><figcaption>Project Architecture</figcaption></figure><ol><li><strong>Ingestion</strong>: Raw data is ingested into the system using Kafka. The data can come from various sources like sensors etc.</li><li><strong>Processing</strong>: Airflow schedules Spark jobs to process the raw data. The processing that we perform on our data should follow the business objectives.</li><li><strong>Storage</strong>: Processed information is kept in Cassandra for NoSQL tasks or in PostgreSQL for structured data retention.</li><li><strong>Orchestration</strong>: Each architectural piece is contained within Docker, guaranteeing isolation and straightforward setup.</li></ol><h3>Project Guide</h3><p>— — — — — — — — —</p><blockquote>Project structure:</blockquote><pre>├── dags<br>│   └── kafka_stream.py<br>├── compose.yml<br>├── dockerfile<br>├── requirements.txt<br>├── README.md<br>├── script<br>│   └── entrypoint.sh<br>├── image<br>│   └── architecture.png<br>└── spark_stream.py<br>4 directories, 8 files</pre><blockquote>Setup:</blockquote><ul><li>Requirements:</li></ul><p>Run the following command in order to install the requirements:</p><pre>pip install -r requirements.txt</pre><ul><li>Entrypoint:</li></ul><p>The <em>entrypoint.sh</em> file has the necessary commands to be executed once the corresponding container has been initialized. It is recommended to run the following script to make the script executable.</p><pre>chmod +x scripts/entrypoint.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1QC3baqRGvQOSLWcl7Sow.png" /><figcaption>entrypoint.sh</figcaption></figure><blockquote>Docker-compose containers</blockquote><ul><li><strong>Kafka Broker</strong>: Part of the Kafka streaming system, it manages message storage, access, and transport.</li><li><strong>Zookeeper</strong>: A service for distributed setup and coordination, essential for Kafka’s distributed functioning.</li><li><strong>Schema Registry</strong>: Offers a REST interface to store and fetch Avro schemas, aiding Kafka streams in recognizing record schemas.</li><li><strong>Control Center</strong>: A web tool for overseeing Kafka setups, allowing data checks, topic generation, and Kafka Connect configuration.</li><li><strong>Spark Master</strong>: The main access point for Spark services, it allocates tasks across the Spark cluster.</li><li><strong>Spark Worker</strong>: Executes tasks designated by the master and reports back the outcomes.</li><li><strong>Cassandra DB</strong>: A NoSQL database suitable for large-scale, high-speed data spread across multiple nodes, ensuring no sole point of breakdown. Used here so as to load the processed data.</li><li><strong>PostgresDB</strong>: A relational database employed as Apache Airflow’s metadata storage and also as a versatile data repository.</li><li><strong>ETL Service: </strong>After dockerizing the pipeline scripts, added the service to Compose for us to automatically update, build, and push the Docker image to DockerHub with GitHub Actions’ CI script.</li><li><strong>Airflow Webserver</strong>: Airflow’s UI for outlining and overseeing data workflows or DAGs.</li><li><strong>Scheduler</strong>: Within Airflow, it kickstarts tasks and forms data pipelines, ensuring timely execution or activation by other tasks.</li></ul><p>Nota Bene: The AIRFLOW__WEBSERVER__SECRET_KEY is the same for the webserver and the scheduler for the containers to work effectively.</p><p>You can set up the Docker compose containers by running:</p><pre>docker-compose up</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JAvKOeXvgpA6IVbZkdha8w.png" /><figcaption>Running Docker compose result</figcaption></figure><blockquote>Streamlining Data to Apache Kafka</blockquote><p>After getting your Docker containers active, initiate a new Airflow DAG. Then, navigate to the Airflow interface at <strong><em>localhost:8080</em></strong> and execute the <strong><em>user_automation</em></strong> DAG by clicking the play icon in the actions section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcRUvm5XS3VAjoqyfEDYBw.png" /></figure><p>And, to observe the live data stream, access the control center interface at <strong><em>localhost:9021</em></strong><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vioEOjB0nWPNZEZYiA3__Q.png" /><figcaption>Control center UI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_mrauJaMpb3Z7DGIAzvrA.png" /><figcaption>users_created Kafka topic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCVZ32jxzhn4ND2yA3JQ3g.png" /><figcaption>View users created</figcaption></figure><ul><li>You can find the repo down below in the resources section.</li></ul><blockquote>Streaming Data into Cassandra</blockquote><p>Within the main directory, forge a fresh file for Spark streaming, like the one in my repository. Proceed then to execute the following command to dispatch the task to your Spark cluster:</p><pre>spark-submit - master spark://localhost:7077 spark_stream.py</pre><p>Head to <strong><em>localhost:9090</em></strong>, you’ll spot the Spark master, the worker configurations, and note that the worker status is set to <em>ALIVE</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKRBjzNZba7BkxXWEZ1UEA.png" /></figure><p>Establish then a connection to the cluster to see the data stored in Cassandra.</p><pre>docker exec -it cassandra cqlsh -u cassandra -p cassandra localhost 9042</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DFDKYcwImKvPqSO0g3WMqQ.png" /><figcaption>Expected output</figcaption></figure><p>Keyspaces and their tables should display accordingly when running:</p><pre>DESCRIBE spark_streams.created_users;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gC78uzgqovpExf4v-9D0hw.png" /><figcaption>Keyspace output</figcaption></figure><p>To retrieve the data transferred to Cassandra, execute:</p><pre>SELECT * FROM spark_streams.created_users;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWxb15ilPuRmSMeQUTYdTQ.png" /><figcaption>Loaded data</figcaption></figure><p>And there you have it!</p><blockquote>Continuous Integration</blockquote><p>This is what the Docker image publish file in GitHub Actions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q5aeJ47CaQ8UHP4ADWpFIw.png" /><figcaption>Docker image CI pipeline using GitHub Actions</figcaption></figure><p>Let’s quickly go through it with a Q&amp;A.</p><ol><li><strong>When does this pipeline run?</strong><br>This pipeline is triggered every time there’s a new push to the main branch of your repository.</li><li><strong>Where does it run?</strong><br>The tasks in this pipeline are executed on a virtual machine with the latest version of Ubuntu.</li><li><strong>What are the steps of this pipeline?</strong></li></ol><ul><li><strong>Checkout code:<br> </strong>This step fetches the latest code from our repository. It uses a predefined action (actions/checkout@v2) to achieve this.</li><li><strong>Login to Docker Hub:<br> </strong>Before we can push an image to Docker Hub, we need to log in. This step uses my Docker Hub username and a token (both stored securely as secrets in my repository) to authenticate with Docker Hub.</li><li><strong>Build and push Docker image:<br> </strong>This is the core step. Here, the pipeline builds a Docker image using the provided dockerfile. Once the image is built, it&#39;s pushed to Docker Hub with the tag labchiri/data-streaming.</li></ul><p>That’s it for this article. I hope you learned something, and your attention is appreciated!</p><h3><strong>Resources</strong></h3><p>— — — — — — — — —</p><p><a href="https://github.com/moontucer/Data-Streaming-Project">Repository link</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=082f0d9cfbdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Only Machine Learning Article You’ll Ever Need: The Ultimate Comprehensive Guide]]></title>
            <link>https://medium.com/@moontucer/the-only-machine-learning-article-youll-ever-need-the-ultimate-comprehensive-guide-5fb763bddbdc?source=rss-3fee132feca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fb763bddbdc</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[information-technology]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mountasser]]></dc:creator>
            <pubDate>Mon, 13 Feb 2023 16:24:27 GMT</pubDate>
            <atom:updated>2023-02-13T16:24:27.559Z</atom:updated>
            <content:encoded><![CDATA[<p>A s you’ve surely noticed, Machine Learning is a rapidly expanding field with the potential to transform the way we live and work. It is the science of creating algorithms that can recognize patterns in data and predict or make decisions without being explicitly programmed to do so. However, if you’re new to the field, the concept of machine learning can be intimidating and difficult to grasp. The good news is that with a basic understanding of the concepts and math behind machine learning, you can get started and lay a solid foundation for a career in data science or machine learning engineering. In this article, we’ll look at how understanding machine learning algorithms and the underlying math concepts can help you build a solid foundation in the field. This article is for you if you’re just starting out or looking to advance your skills.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*iPFEzWcE0NxB62P7gx8j5A.jpeg" /><figcaption>Machine Learning Specifications</figcaption></figure><p>Prepare to embark on an adventure with this article! We’ll go over the fundamentals of machine learning and give you the knowledge you need to understand the various algorithms. By the end of this article, you should have a better understanding of the various approaches used in machine learning and be able to identify which algorithms interest you. This article will provide you with a solid foundation to build on if you are interested in classification, regression, clustering, association, or dimension reduction. Of course, a solid understanding of mathematics is required to fully comprehend the concepts, so make sure you have the prerequisites before diving in!</p><p>In this article, we’ll shed light into the following:</p><ul><li>ML? WTH is even that?</li><li>Its types and use cases</li><li>Classic algorithms’ concepts, pros and cons</li><li>A quick Python application</li><li>A Nota Bene: why learn the Math behind?</li><li>The necessary Math to learn and why?</li><li>Where to head next? Any Applications?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*khVjc2ZcBfZwm8ad1j78IQ.png" /></figure><h3><strong>What’s Machine Learning?</strong></h3><p>Machine learning is a branch of artificial intelligence that deals with the design and development of algorithms that can learn from data and predict or act without being explicitly programmed to do so. A large amount of data is fed into the algorithm during the learning process, allowing it to identify patterns and relationships in the data and then make predictions or decisions based on that information. As they are exposed to more data, the algorithms can continue to learn and improve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mdu-0am_11cL-Z7__bnwPw.jpeg" /></figure><h3><strong>Types and use cases</strong></h3><p>There are various types of machine learning, such as:</p><ul><li><strong>Supervised learning</strong> is a type of machine learning in which the algorithm is trained on labeled data with the goal of predicting the output label for new, unseen data.</li><li><strong>Unsupervised learning</strong>: The algorithm is not given any labeled data in this type of machine learning, and the goal is to find patterns or relationships in the data.</li><li><strong>Semi-supervised learning</strong> is a hybrid of supervised and unsupervised learning in which the algorithm is trained on both labeled and unlabeled data.</li><li><strong>Reinforcement learning</strong>: In this type of machine learning, the algorithm learns to make a series of decisions in a setting where it is rewarded or punished for its actions.</li><li><strong>Transfer learning</strong> is a type of machine learning in which the knowledge gained from solving one problem is transferred and applied to a related but distinct problem.</li><li><strong>Deep learning</strong>, also known as artificial neural networks, is a subfield of machine learning that is inspired by the structure and function of the human brain. It is used for a wide range of tasks including image and speech recognition, NLP (Natural Language Processing) etc.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*mlhCfNeNSo75TRH9yEUJIA.png" /></figure><p>Supervised learning is a type of machine learning where the algorithms are trained on labeled data, with the goal of making predictions or categorizing new data points based on past observations. Two common examples of supervised learning are classification and regression. Classification is used to predict a categorical label, such as “spam” or “not spam” for an email, while regression is used to predict continuous numerical values, such as the price of a house. These techniques have numerous applications in fields such as finance, healthcare, and marketing.</p><p>On the other hand, unsupervised learning focuses on finding patterns or relationships in data without labeled responses. This type of learning is useful when the desired output is not clear, and the goal is to explore the structure of the data and gain insight into it.</p><p>Clustering, association, and dimension reduction are some common examples of unsupervised learning techniques. Clustering involves grouping data points into clusters based on similarity, while association is used to identify relationships between variables. Dimension reduction is used to simplify the data by reducing the number of features while retaining as much information as possible. These techniques are often used in areas such as image recognition, anomaly detection, and market segmentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v6KSJnQiJXiRX9hq_s_h3Q.jpeg" /><figcaption>Illustration for the previous explanation</figcaption></figure><h3><strong>Classical ML Algorithms</strong></h3><p>Note that each of these algorithms has its own parameters that, if varied, can optimize its results. Furthermore, these variations can also affect its advantages and disadvantages.</p><blockquote><strong><em>Linear Regression</em></strong> is a statistical technique used to investigate the linear relationship between two variables, one of which is dependent (or output) and the other independent (or input). Linear regression’s goal is to find the best line that fits the data points and predict the output variable based on the input variable. The best fit line is determined by determining the parameter values that minimize the differences between the observed and predicted values.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*8NJPctdMWKe2ukD1hWyWcw.png" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Simple to implement and efficient to train</li><li>Overfitting can be reduced by regularization</li><li>Performs well when the dataset is linearly separable</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Assumes that the data is independent which is rare in real life</li><li>Prone to noise and overfitting</li><li>Sensitive to outliers</li></ul><blockquote><strong><em>Logistic Regression</em></strong> is a machine learning algorithm used to solve binary classification problems. It predicts the likelihood of an event occurring (e.g., whether a customer will buy a product or not) based on several inputs (also known as features) and maps the output to either 0 or 1. (yes or no, true or false). Logistic Regression seeks the best relationship between features and the target variable, which is represented by a mathematical equation that can be used to make predictions.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nm5Xc-YyUYfWxuAzWML9Q.jpeg" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Less prone to over-fitting but it can overfit in high dimensional datasets.</li><li>Efficient when the dataset has features that are linearly separable.</li><li>Easy to implement and efficient to train.</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Should not be used when the number of observations are lesser than the number of features</li><li>Assumption of linearity which is rare in practice</li><li>Can only be used to predict discrete functions</li></ul><blockquote><strong><em>Decision Trees </em></strong>is a diagram or flowchart-like structure that represents a series of decisions and their possible outcomes. It’s a tree-like model of decisions and their potential outcomes, such as random event outcomes, resource costs, and utility. Each node in the tree represents an attribute test, each branch represents the test result, and each leaf node represents a class label (decision taken after computing all attributes). The goal is to find the best solution by building the tree in such a way that it maximizes accuracy based on the training data provided. The end result is a decision tree that can be used to predict the class of new examples.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mlm81L-eEXJS-J0ZvJqmJw.png" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Can solve non-linear problems.</li><li>Can work on high-dimensional data with excellent accuracy</li><li>Easy to visualize and explain</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Overfitting. Might be resolved by random forest</li><li>A small change in the data can lead to a large change in the structure of the optimal decision tree.</li><li>Calculations can get very complex.</li></ul><blockquote><strong><em>K Nearest Neighbors (KNN) </em></strong>is a simple machine learning algorithm that can be used for classification as well as regression. The algorithm attempts to predict the label of an unseen data point given a set of labeled data points by locating the “K” number of nearest data points to it in the training set and taking the majority label among those neighbors as the prediction. The distance between data points can be calculated using a variety of methods, including Euclidean distance and Manhattan distance. Simply put, KNN compares a new, previously unseen data point to all of the data points in the training set, selecting the “K” closest ones. The label information of those “K” nearest neighbors is then used to make a prediction for the label of the new data.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*VoC6c5TDIO-qFq3-m1oc8g.png" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Can make predictions without training</li><li>Time complexity is O(n)</li><li>Can be used for both classification and regression</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Does not work well with large dataset</li><li>Sensitive to noisy data, missing values and outliers</li><li>Need feature scaling</li><li>Choose the correct K value</li></ul><blockquote><strong><em>K-Means </em></strong>is a method for grouping or clustering similar data points into “clusters.” The algorithm accepts a set of data points and assigns each data point to one of “K” clusters based on their attributes, where “K” is a number specified by the user. The algorithm then updates the cluster assignments and cluster centroids (the average of all cluster points) until convergence, at which point the final cluster assignments are returned. K-means minimizes the sum of squared distances between each data point and its assigned cluster centroid.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*2znurzpbeeaPiC-3cFBy-w.jpeg" /><figcaption>K means clustering example</figcaption></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Scales to large data sets</li><li>Simple to implement</li><li>Guarantees convergence</li><li>Easily adapts to new examples</li><li>Generalizes to clusters of different shapes and sizes.</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Choosing the k values manually is challenging</li><li>Dependent on initial values</li><li>Sensitive to the outliers</li><li>Scalability decreases when dimension increases</li></ul><blockquote><strong><em>Support Vector Machine (SVM) </em></strong>is an algorithm is used to categorize data into different groups. SVM’s goal is to find the best line or boundary that divides the data into the appropriate groups. It operates by determining the line or boundary that provides the greatest separation, or margin, between the various groups of data. This line or boundary is then used to sort new data into the appropriate category. Simply put, SVM is a method for categorizing data by determining the best dividing line or boundary between groups. When the data has complex patterns that cannot be easily separated using simple lines or boundaries, the algorithm comes in handy.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*I0WsnqLrfTlmOsffQdNM3A.png" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Can work on small dataset</li><li>Good at high dimensional data</li><li>Can solve non-linear problems</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Inefficient on large data</li><li>Requires picking the right kernel</li></ul><blockquote><strong><em>Principal Component Analysis (PCA) </em></strong>is a statistical technique for breaking down large and complex datasets into smaller, more manageable chunks of data. This is accomplished by identifying the most important underlying patterns in the data and then generating new, derived variables (also known as “components”) that capture these patterns. The goal is to reduce the number of variables or features in the data while retaining as much of the original information as possible. This facilitates the visualization, analysis, and comprehension of data, as well as the identification of correlations and relationships between variables that might not have been apparent otherwise.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*GVeZkXi6HL-_UHtpCwSOPg.png" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Reduce correlated features</li><li>Improve performance</li><li>Reduce overfitting</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Principal components are less interpretable</li><li>Information loss</li><li>Must standardize data before implementing or</li></ul><blockquote><strong><em>Naive Bayes </em></strong>Naive Bayes is a type of machine learning algorithm that predicts using the Bayes theorem. It is regarded as “naive” because it assumes that all features in the data are independent of one another, which is not always true. The Naive Bayes algorithm is based on the idea that the likelihood of a certain event occurring (for example, an email being spam) can be calculated based on the likelihood of other events occurring (such as certain words appearing in the email). This information is then used by the algorithm to make predictions about new data. It is a simple, fast, and effective algorithm used for classification problems such as spam filtering, sentiment analysis, and document classification.</blockquote><p>Here’s a video below that explains Naive Bayes really well.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO2L2Uv9pdDA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO2L2Uv9pdDA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FO2L2Uv9pdDA%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeb0ac544407e36a7fc08f35a7050ca7/href">https://medium.com/media/eeb0ac544407e36a7fc08f35a7050ca7/href</a></iframe><p><strong><em>Advantages:</em></strong></p><ul><li>Training period is less</li><li>Better suited for categorical inputs</li><li>Easy to implement</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Assumes that all features are independent which is rarely happening in real life</li><li>Zero Frequency</li><li>Estimations can be wrong in some cases</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvnYkLF9DPagoFyU1BzEJg.png" /><figcaption>Naive Bayes forumula and illustration</figcaption></figure><blockquote><strong><em>Artificial Neural Networks (ANN) </em></strong>are machine learning algorithms that are designed to mimic the structure and function of the human brain. They are made up of interconnected “neurons” that process and transmit information by forming connections and adjusting their strength based on experience. ANNs are used to perform various tasks, such as image recognition, natural language processing, and decision-making, by learning from large amounts of data. In layman’s terms, an ANN takes input, processes it through multiple layers of artificial neurons, and then outputs a result based on what it has learned from the data.</blockquote><p>Here’s a video from IBM that explains this concept well in 5 minutes:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjmmW0F0biz0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjmmW0F0biz0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjmmW0F0biz0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd2f49f00793871915542e1f88ce225a/href">https://medium.com/media/dd2f49f00793871915542e1f88ce225a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-67qcW23cgeEjAlEeQ_ljg.png" /></figure><p><strong><em>Advantages:</em></strong></p><ul><li>Have the ability to learn and model non-linear and complex relationships</li><li>Have fault tolerance</li><li>Can generalize on unseen data</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Long training time</li><li>Non-guaranteed convergence</li><li>Black box. Hard to explain the solution</li><li>Hardware dependence</li><li>Requires user’s ability to translate the problem.</li></ul><blockquote><strong><em>Ada Boost: </em></strong>is a machine learning algorithm that combines several “weak” models to create a stronger, more accurate prediction model. It works by giving more weight to examples that were incorrectly classified by previous models and then training the next model on these weighted examples. The final model is a composite of all weak models, each with a weight based on its accuracy. AdaBoost has solved complex classification and regression problems such as image and speech recognition. It combines several weak models to create a strong model that can handle complex input-output relationships.</blockquote><p>Simply, AdaBoost works by iteratively improving the model’s accuracy by assigning higher weights to examples misclassified by the previous model and then training the next model to focus on these misclassified examples. This process is repeated until a satisfactory level of accuracy is achieved or a predefined stopping criterion is met.</p><p><strong><em>Advantages:</em></strong></p><ul><li>Relatively robust to overfitting</li><li>Easy to understand and to visualize</li><li>High accuracy</li></ul><p><strong><em>Disadvantages:</em></strong></p><ul><li>Affected by outliers</li><li>Not optimized for speed</li><li>Sensitive to noise data</li></ul><h3>A quick Python application</h3><pre># Import the required libraries<br>import numpy as np<br>from sklearn.neighbors import KNeighborsClassifier<br>from sklearn.model_selection import train_test_split<br>from sklearn.metrics import accuracy_score<br><br># Load the data and split it into training and testing sets<br>X = np.loadtxt(&quot;data.txt&quot;)<br>y = np.loadtxt(&quot;labels.txt&quot;)<br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)<br><br># Create a k-NN classifier with k=3<br>knn = KNeighborsClassifier(n_neighbors=3)<br><br># Train the classifier on the training data<br>knn.fit(X_train, y_train)<br><br># Predict the class labels for the test data<br>y_pred = knn.predict(X_test)<br><br># Calculate the accuracy of the classifier<br>accuracy = accuracy_score(y_test, y_pred)<br><br># Print the accuracy<br>print(&quot;Accuracy:&quot;, accuracy)</pre><h3>Nota Bene</h3><p>While Python libraries like scikit-learn, TensorFlow, and PyTorch make it easy to implement machine learning algorithms, it’s the understanding of the theory and math behind these algorithms that sets apart the good machine learning practitioners from the great ones. A deep understanding of the theory and math helps in selecting the appropriate model for a given problem, fine-tuning and optimizing the model, and even building your own custom models that fit specific needs. Additionally, it allows you to manipulate a pre-built model’s parameters to drive better insights and to identify potential sources of bias or overfitting.</p><h3>The necessary Math and why?</h3><p>T o fully comprehend the theory and mathematics underlying machine learning, a solid foundation in several mathematical fields is required, including linear algebra, calculus, probability and statistics, and optimization.</p><p><a href="http://www.quickmeme.com/img/1e/1edc38f752c437bbd0f613a278c2871f5e1056b8831d48b32f6227f3263f6ffa.jpg"><strong>Linear algebra</strong></a> is critical for understanding the relationships between features in high-dimensional data, as well as for manipulating and transforming this data. <a href="http://www.quickmeme.com/img/1e/1edc38f752c437bbd0f613a278c2871f5e1056b8831d48b32f6227f3263f6ffa.jpg"><strong>Calculus</strong></a> is necessary for comprehending the optimization algorithms used to find the best model parameters. <a href="http://www.quickmeme.com/img/1e/1edc38f752c437bbd0f613a278c2871f5e1056b8831d48b32f6227f3263f6ffa.jpg"><strong>Probability</strong></a> and <a href="http://www.quickmeme.com/img/1e/1edc38f752c437bbd0f613a278c2871f5e1056b8831d48b32f6227f3263f6ffa.jpg"><strong>statistics</strong></a> lay the groundwork for understanding how to quantify uncertainty in model predictions and draw conclusions about population parameters based on sample data. Understanding how to find the best model parameters that minimize a loss function, which measures the difference between the predicted and true output, is critical. This is especially true in deep learning, where <a href="http://www.quickmeme.com/img/1e/1edc38f752c437bbd0f613a278c2871f5e1056b8831d48b32f6227f3263f6ffa.jpg"><strong>optimization</strong></a> algorithms play a critical role in training neural networks.</p><p>Overall, a solid understanding of these mathematical fields is essential for comprehending the theory and mathematics underlying machine learning and making informed decisions about how to design, train, and evaluate machine learning models.</p><h3>Any interesting applications? Yes;</h3><ol><li>Healthcare</li><li>Finance</li><li>Marketing</li><li>Natural Language Processing</li><li>Computer Vision</li><li>Robotics</li><li>Transportation</li><li>Environment</li></ol><p>N.B: ML can be applied in many more field. Find yourself a project idea (like house price prediction, image search engine etc.), find yourself a dataset (from Kaggle or Google Dataset Search) and build something nice, it’s gonna be fun, I promise!</p><h3>Where to head next?</h3><ul><li><a href="https://www.youtube.com/@statquest">StatQuest</a> (clickable) is a YouTube channel that explained nearly everything concerning Machine Learning in a fun, very clear, and unboring way.</li><li><a href="http://kaggle.com/">Kaggle</a> is a data science company that was acquired by Google that hosts competition and most importantly teaches machine learning through various fine tutorials.</li><li><a href="https://books.google.co.ma/books/about/Understanding_Machine_Learning.html?id=ttJkAwAAQBAJ&amp;printsec=frontcover&amp;source=kp_read_button&amp;hl=en&amp;redir_esc=y#v=onepage&amp;q&amp;f=false">Understanding Machine Learning</a> is a 400 pages book (and e-book) that clarifies all the math behind ML. If you read and understand all of it, I guarantee you’d be an ML expert haha.</li><li><a href="http://www.quickmeme.com/img/1e/1edc38f752c437bbd0f613a278c2871f5e1056b8831d48b32f6227f3263f6ffa.jpg">Google</a> of course, where you can find other interesting fields such adversarial machine learning which is the study of attacks against ML algorithms and the defense against these attacks.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fb763bddbdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>