<?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 Faisal Muhammad Adam on Medium]]></title>
        <description><![CDATA[Stories by Faisal Muhammad Adam on Medium]]></description>
        <link>https://medium.com/@vafaisalm93?source=rss-62694ab20100------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YeCGvQsPu5I1RHO9</url>
            <title>Stories by Faisal Muhammad Adam on Medium</title>
            <link>https://medium.com/@vafaisalm93?source=rss-62694ab20100------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 12:17:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vafaisalm93/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[# What Participating in Kaggle Submissions Taught Me About Multilingual NLP]]></title>
            <link>https://medium.com/@vafaisalm93/what-participating-in-kaggle-submissions-taught-me-about-multilingual-nlp-ca717fd87f8b?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca717fd87f8b</guid>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 19:16:22 GMT</pubDate>
            <atom:updated>2026-09-27T19:16:22.960Z</atom:updated>
            <content:encoded><![CDATA[<p># What Participati<em>n</em>g i<em>n</em> Kaggle Submissions Taught Me About Multilingual NLP</p><p><em>*Building topic classification and headline generation for four Nigerian languages with one model under one billion parameters.*</em></p><p>On September 25, 2026, I started working on the DSN Bootcamp Hackathon LLM/Agent Track. The challenge looked straightforward at first: read a news article, predict its topic, and generate a headline.</p><p>Then the constraints made it interesting.</p><p>The articles were written in Hausa, Igbo, Yoruba, and Nigerian Pidgin. The topic classifier had seven possible labels, while the generation system had to produce a headline in the article’s original language. Both tasks had to be handled by a single model with fewer than one billion parameters.</p><p>The final score combined three metrics:</p><p>```text</p><p>Final Score = 0.50 × Macro-F1</p><p>+ 0.25 × ROUGE-L</p><p>+ 0.25 × BERTScore</p><p>```</p><p>That formula shaped every decision. Classification contributed half of the score, but weak headline generation could still prevent an otherwise strong system from becoming competitive.</p><p>## Starting with the data, not the model</p><p>The supplied training set contained 6,068 articles, while the test set contained 1,743. Every test article required two submission rows: one for its topic and one for its generated headline.</p><p>The first useful discovery was that the label distribution depended heavily on language. Hausa contained examples from all seven classes, while some labels did not appear in the other languages. Technology, for example, appeared only in the Hausa training subset.</p><p>This meant language was not just metadata. It was a meaningful predictive feature and could also be used to prevent impossible classifications.</p><p>For the initial topic model, I built a lightweight hashed text classifier using:</p><p>- Word unigrams and bigrams</p><p>- Prefix and suffix features</p><p>- Language indicators</p><p>- TF-IDF weighting</p><p>- A passive-aggressive linear learner</p><p>- Language-specific label masking</p><p>I then constrained the final predictions so that each language’s topic distribution remained consistent with the training distribution. On local cross-validation, this produced a Macro-F1 score of approximately 0.861.</p><p>That was encouraging. The headline task was where things became difficult.</p><p>## Submission one: extract the article lead</p><p>Without access to a GPU or a pretrained sequence-to-sequence model in the local workspace, I began with an extractive headline baseline.</p><p>The system selected the opening words of each article, with a different length for each language. For Yoruba, it also learned a dictionary that restored common diacritics from the training headlines. Exact or highly similar articles found in the supplied training set reused their known topic and headline.</p><p>The first submission scored:</p><p>&gt; <strong>**0.60348**</strong></p><p>This was a respectable baseline, but it also exposed the weakness of the approach. Article leads are not headlines. They are longer, less direct, and often contain details that a human editor would remove.</p><p>Still, the score gave us a reference point. Any proposed improvement had to beat 0.60348 on the actual leaderboard — not only on a local approximation of ROUGE-L.</p><p>## Submission two: shorter does not always mean better</p><p>The second system trained a small supervised compression model. It aligned headline tokens with article tokens using the longest common subsequence, then learned which words were likely to appear in a headline.</p><p>On held-out training data, the compressor improved ROUGE-L for Hausa, Igbo, and Yoruba. It produced shorter, more headline-like outputs and reduced the average prediction length from roughly 19.5 words to 12.9 words.</p><p>Locally, this looked like progress.</p><p>The leaderboard disagreed.</p><p>&gt; <strong>**Submission two: 0.58712**</strong></p><p>The score fell by more than 0.016.</p><p>This was the most valuable failure in the experiment. It showed that the local lexical metric did not fully represent the competition’s evaluation. The shorter predictions may have been cleaner, but they lost too much semantic and lexical coverage.</p><p>It was a reminder that metric optimization can become misleading when the local evaluator is only an approximation of the real one.</p><p>## Submission three: restore fluency without losing coverage</p><p>For the third submission, I returned to the stronger first system and changed only the headline strategy.</p><p>Instead of selecting a fixed number of disconnected tokens, the new version preserved opening sentence boundaries and punctuation. The goal was to retain the coverage that helped submission one while making the output more fluent.</p><p>The result was:</p><p>&gt; <strong>**Submission three: 0.60422**</strong></p><p>It became the best submission, but only by 0.00074.</p><p>| Submission | Headline strategy | Score |</p><p>The conclusion was clear: extractive heuristics had reached their ceiling. More rules might move the fourth decimal place, but they were not going to produce a jump from 0.60 to 0.70.</p><p>## The pivot: one neural model for both tasks</p><p>At inference time, topic labels are not generated freely. The model scores every label permitted for the article’s language and selects the one with the lowest decoder loss. This guarantees a valid topic and avoids spelling variations.</p><p>Headlines are generated using four-beam search, language-specific maximum lengths, and repetition controls. Exact duplicate articles already present in the supplied training data reuse their known training targets.</p><p>The complete pipeline writes and validates the final Kaggle CSV automatically.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca717fd87f8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can School Funding Predict Success? Building an AI SAT Predictor for NYC High Schools]]></title>
            <link>https://medium.com/@vafaisalm93/can-school-funding-predict-success-building-an-ai-sat-predictor-for-nyc-high-schools-a04995f8a72a?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/a04995f8a72a</guid>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 17:09:24 GMT</pubDate>
            <atom:updated>2026-03-06T17:09:24.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6BSMkbwXthUB7T4n5khMPw.jpeg" /></figure><p>In the heart of New York City’s education system lies a perennial question: <strong>Does more money equal better scores?</strong> As a data enthusiast, I decided to stop guessing and start modeling. I built a full-stack machine learning application that predicts SAT performance based on school funding across the five boroughs and here is how I went from raw CSVs to a live AI dashboard.</p><h3>The Data Cleaning.</h3><p>No dataset arrives perfect. To build this, I merged two distinct New York City Open Data sources: school performance metrics and student funding allocations.</p><p>The challenge wasn’t just the math rather, it was the <strong>integrity</strong>. Data from different departments often uses different identifiers. I built a robust Python pipeline to standardize “DBN” (District Borough Numbers), handling leading zeros and formatting inconsistencies that would have broken a standard merge.</p><h3>Why Random Forest?</h3><p>For the predictive engine, I chose a <strong>Random Forest Regressor</strong>.</p><p>While a simple Linear Regression looks for a straight line, education data is rarely linear. A school in Manhattan might respond to funding differently than one in the Bronx. Random Forest excels here because it uses an ensemble of decision trees to capture these complex, non-linear relationships.</p><p>I didn’t just train the model; I evaluated it using <strong>Mean Absolute Error (MAE)</strong> and <strong>R-squared ($R²$)</strong> metrics to ensure the “AI” was actually learning patterns rather than just memorizing noise.</p><h3>The Interface: Bringing Data to Life</h3><p>A model hidden in a Jupyter Notebook is a model unused. I deployed the project using <strong>Streamlit</strong>, turning my Python script into an interactive web app.</p><p>The app features:</p><ul><li><strong>A Data Explorer:</strong> Users can visualize the correlation between budget and scores via interactive scatter plots.</li><li><strong>The Predictor:</strong> A “what-if” tool where users can adjust budgets and see the estimated impact on SAT results.</li><li><strong>Performance Metrics:</strong> A transparent look at the model’s error rates and residual plots.</li></ul><h3>The Key Takeaway</h3><p>This project taught me that data science isn’t just about the algorithm — it’s about the <strong>pipeline</strong>. From cleaning data in Pandas to deploying on Streamlit Cloud, the goal is to make complex data accessible and actionable.</p><p><strong>Check out the live app here:</strong> <a href="https://nycsatpredictor.streamlit.app/">App</a> ad also <strong>Explore the code on GitHub:</strong> [<a href="https://github.com/faisalm93/nyc-sat-predictor">here</a>]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a04995f8a72a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reinforcement Learning and its Components: The Journey to Intelligent Decision-Making]]></title>
            <link>https://medium.com/@vafaisalm93/reinforcement-learning-and-its-components-the-journey-to-intelligent-decision-making-8be82c946c5f?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/8be82c946c5f</guid>
            <category><![CDATA[deep-learning-framework]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Wed, 19 Jul 2023 11:35:47 GMT</pubDate>
            <atom:updated>2023-07-19T11:35:47.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QWw7bxIV1IuFR19xWCpHwA.png" /><figcaption>Image from Berkeley AI Research Lab</figcaption></figure><p><strong>Introduction:</strong></p><p>Reinforcement Learning (RL) is a subfield of artificial intelligence (AI) that deals with training agents to make decisions by interacting with an environment. Unlike other machine learning techniques, where the model is provided with labeled data for learning, reinforcement learning employs a trial-and-error approach. The agent learns through feedback in the form of rewards or penalties as it explores the environment and tries to maximize cumulative rewards over time. RL has shown remarkable success in solving complex problems, from playing games to controlling autonomous vehicles, making it a vital area of study in AI research.</p><p><strong>Components of Reinforcement Learning</strong></p><ol><li>Agent: The agent is the central component of the reinforcement learning system. It is an entity responsible for making decisions and taking actions within the environment. The agent’s objective is to learn a policy — a mapping of states to actions — that maximizes the cumulative reward it receives over time. The policy determines the agent’s behavior and how it selects actions based on its observations and experiences.</li><li>Environment: The environment represents the external world with which the agent interacts. It encompasses everything that the agent perceives and responds to, including the state of the environment, the actions it can take, and the rewards or penalties it receives. The environment can be real or simulated, and it is crucial in providing feedback to the agent about the consequences of its actions.</li><li>State: A state is a specific configuration of the environment at a particular time during the agent’s interaction. It captures all relevant information necessary for decision-making. In some cases, the state is fully observable, meaning the agent has complete information about the environment. However, in most real-world scenarios, the state may be partially observable, and the agent must infer it from limited observations.</li><li>Action: Actions are the choices available to the agent to interact with the environment. The agent selects actions based on its current state and the policy it has learned. The actions influence the state transition, leading the agent to a new state with potential rewards or penalties associated with the transition.</li><li>Reward Function: The reward function is a critical element in reinforcement learning. It quantifies the desirability of a state-action pair and represents the immediate feedback the agent receives after taking an action. The agent’s goal is to maximize the cumulative reward over time, which is often expressed as a sum of the rewards obtained during a sequence of actions.</li><li>Policy: The policy is the strategy that the agent uses to determine which action to take in a given state. It maps the agent’s observations (states) to actions and defines its behavior. The policy can be deterministic, meaning it directly specifies the action to take in each state, or stochastic, where it provides a probability distribution over actions. Reinforcement learning algorithms aim to optimize the policy to achieve the highest possible reward.</li><li>Value Function: The value function estimates the expected cumulative reward from a particular state or state-action pair under a given policy. It measures how good a state or action is in terms of the long-term reward it can lead to. The value function plays a crucial role in various RL algorithms, helping the agent assess the potential of different actions and states.</li><li>Q- Function: The Q function, also known as the action-value function, is a key concept in RL. It maps the value of taking a specific action in a given state while following a particular policy. The Q function helps the agent to estimate the expected total reward when following the policy from a particular state-action pair onwards. This estimation is instrumental in guiding the agent towards better decision-making.</li><li>Bellman Equation: The Bellman equation is a fundamental principle in RL, expressing the relationship between the Q function of a state-action pair and the Q function of its subsequent state-action pairs. It uses the principle of optimality to ensure that the Q function is updated iteratively based on the rewards and future states, leading to better policy optimization.</li><li>Exploration-Exploitation Tradeoff: Reinforcement learning agents often face the exploration-exploitation dilemma. During the learning process, the agent must strike a balance between exploring new actions and potentially discovering better strategies (exploration) and exploiting the currently known best actions to maximize short-term rewards (exploitation). Striking the right balance is crucial for efficient learning and optimal decision-making.</li><li>Epsilon Greedy Policy: To strike a balance between exploration and exploitation, RL agents often employ the epsilon-greedy policy. This policy dictates that the agent selects the action with the highest Q-value most of the time (exploitation) but occasionally chooses a random action with a small probability epsilon (exploration). This approach ensures that the agent discovers potentially better actions while still favoring the currently known best actions.</li><li>On-Policy vs. Off-Policy: Reinforcement learning algorithms can be classified as on-policy or off-policy. On-policy algorithms update their policy while interacting with the environment, meaning they use the data collected from their current policy. In contrast, off-policy algorithms maintain a separate dataset from a different policy, enabling them to learn from both exploratory and exploitative data. This distinction has practical implications for the efficiency and stability of learning.</li></ol><p><strong>Real World RL Applications</strong></p><p>Reinforcement Learning (RL) has a wide range of real-world applications across various industries and domains. Its ability to learn from interaction with the environment and optimize decisions based on rewards makes it particularly useful in scenarios where traditional rule-based or supervised learning approaches are less effective. Here are notable real-world applications of RL:</p><ol><li><strong>Game Playing</strong>: RL has been successfully applied to play complex games, including board games like Chess and Go, as well as video games. AlphaGo, developed by DeepMind, became famous for defeating the world champion Go player. RL algorithms can learn effective strategies through self-play and surpass human-level performance in many games.</li><li><strong>Robotics and Autonomous Systems:</strong> RL plays a crucial role in training robots and autonomous systems to perform tasks in dynamic and unstructured environments. Robots can learn to navigate, manipulate objects, and adapt to changes in their surroundings through RL. This has applications in industrial automation, warehouse management, and even space exploration.</li><li><strong>Recommendation Systems:</strong> In e-commerce and content platforms, RL can be used to optimize personalized recommendations for users. By learning from users’ interactions and feedback, RL algorithms can improve the relevance of product recommendations and content suggestions.</li><li><strong>Finance and Trading:</strong> Reinforcement Learning is applied in finance to optimize trading strategies and portfolio management. Agents can learn to make decisions in complex financial markets and adapt to changing conditions to maximize profits.</li><li><strong>Healthcare: </strong>RL has potential applications in healthcare, such as optimizing personalized treatment plans for patients or managing chronic diseases. For example, it could be used to determine the optimal dosage of medications for individual patients based on their responses to treatment.</li><li><strong>Energy Management:</strong> In energy-intensive industries, RL can be employed to optimize energy consumption, schedule maintenance tasks, and control processes for increased efficiency and cost savings.</li><li><strong>Traffic Management:</strong> RL can be used to control traffic signals and optimize traffic flow in urban areas. By learning from traffic patterns and congestion data, RL algorithms can reduce traffic jams and improve overall transportation efficiency.</li><li><strong>Resource Management:</strong> In agriculture, forestry, and environmental management, RL can be applied to optimize the allocation of resources such as water, fertilizers, and manpower for better crop yields and sustainable practices.</li><li><strong>Dialogue Systems: </strong>RL is used in natural language processing to train dialogue systems and chatbots. Agents can learn to engage in conversations and respond appropriately to user inputs, improving customer service and support interactions.</li><li><strong>Control Systems:</strong> RL has applications in controlling complex systems such as industrial processes, autonomous vehicles, and drones. Agents can learn to control these systems effectively, even in uncertain and dynamic environments.</li><li><strong>Education:</strong> In educational technology, RL can be utilized to create adaptive learning platforms that tailor content and learning paths to individual students’ needs and learning styles.</li></ol><p><strong>Conclusion:</strong></p><p>Reinforcement Learning (RL) is a powerful subfield of artificial intelligence that enables agents to learn by interacting with their environment and optimizing decisions based on rewards. Unlike traditional machine learning techniques that rely on labeled data, RL uses a trial-and-error approach, making it suitable for dynamic and uncertain real-world scenarios.</p><p>The components of RL, such as the agent, environment, state, action, reward function, policy, value function, Q-function, and Bellman equation, work together to facilitate the learning process. The agent’s objective is to learn an optimal policy that maximizes cumulative rewards over time by selecting actions based on observations and experiences.</p><p>The applications of RL in the real world are diverse and impressive. RL has shown remarkable success in playing complex games, controlling autonomous systems, optimizing recommendations in e-commerce, and managing financial portfolios. It is being utilized in healthcare for personalized treatments and resource management in agriculture and forestry.</p><p>Furthermore, RL plays a vital role in traffic management, energy optimization, dialogue systems, control of industrial processes, and education technology. As RL algorithms continue to advance and adapt, they promise to revolutionize various industries and domains, driving us closer to creating intelligent agents capable of making decisions and learning in complex and ever-changing environments. However, it is essential to consider ethical and safety aspects as RL becomes increasingly integrated into our daily lives and critical systems. The future holds exciting possibilities for RL, as ongoing research and development continue to unlock its full potential.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8be82c946c5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Series Analysis: Exploring ARIMA and SVR Models]]></title>
            <link>https://medium.com/@vafaisalm93/time-series-analysis-exploring-arima-and-svr-models-20dbe6d2abe2?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/20dbe6d2abe2</guid>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 17:02:41 GMT</pubDate>
            <atom:updated>2023-07-11T17:02:41.089Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*AZPtDT1PZDZaxSscqSMVQA.jpeg" /></figure><p>Introduction:</p><p>Time series analysis serves as a powerful tool for uncovering patterns and making predictions in various domains like finance, sports, and climate forecasting.</p><p>In this article, we will delve into the realm of time series analysis, exploring two widely utilized models: Autoregressive Integrated Moving Average (ARIMA) and Support Vector Regression (SVR).</p><p>By delving into these models and incorporating key terminologies such as stationarity, lag, and kernel functions, we aim to demonstrate their potential in achieving accurate predictions.</p><p><strong>Understanding the ARIMA Model:</strong></p><p>The Autoregressive Integrated Moving Average (ARIMA) model stands as a popular approach in analyzing and forecasting time series data. Comprising autoregression (AR), differencing (I), and moving average (MA) components, ARIMA addresses stationarity, trend, and noise.</p><p>Stationarity, a key concept, ensures that statistical properties of the data remain constant over time. The AR component captures the relationship between an observation and lagged observations, while differencing stabilizes the series by removing trends. The MA component accounts for the dependency between an observation and residual errors.</p><p>Below is an example of ARIMA model for predicting monthly sales in a retail company seeking to forecast its monthly sales based on historical patterns.</p><p>NB: The dataset was randomly generated for the purpose of this example.</p><pre>import pandas as pd<br>import numpy as np<br><br># Generate the sales data<br>start_date = &#39;2022-01-01&#39;<br>end_date = &#39;2022-12-31&#39;<br>dates = pd.date_range(start=start_date, end=end_date, freq=&#39;M&#39;)<br>sales = np.random.randint(100, 1000, size=len(dates))<br><br># Create the sales DataFrame<br>sales_data = pd.DataFrame({&#39;Date&#39;: dates, &#39;Sales&#39;: sales})<br><br># Save the sales data to a CSV file<br>sales_data.to_csv(&#39;sales_data.csv&#39;, index=False)<br><br># Print the generated sales data<br>print(sales_data)<br><br>import pandas as pd<br>from statsmodels.tsa.arima.model import ARIMA<br><br># Load the sales data<br>sales_data = pd.read_csv(&#39;sales_data.csv&#39;)<br><br># Prepare the data for ARIMA model<br>sales_series = sales_data[&#39;Sales&#39;].astype(float)<br><br># Fit the ARIMA model<br>model = ARIMA(sales_series, order=(1, 1, 1))<br>model_fit = model.fit()<br><br># Make future sales predictions<br>predictions = model_fit.predict(start=len(sales_series), end=len(sales_series)+12)<br><br># Create a DataFrame for the predicted sales<br>predicted_sales = pd.DataFrame({&#39;Date&#39;: pd.date_range(start=sales_data[&#39;Date&#39;].iloc[-1], periods=13, freq=&#39;M&#39;),<br>                                &#39;Predicted Sales&#39;: predictions})<br><br># Print the predicted sales<br>print(predicted_sales)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*Nb_CERFX08cKvVn111nCrw.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*GqkO-k-WdPp75paB9bhm4w.gif" /></figure><p>Employing the ARIMA model can provide some insight and empowers the retail company to make precise predictions for future sales, optimizing inventory management and formulating targeted marketing campaigns.</p><p><strong>Understanding the SVR Model:</strong></p><p>Support Vector Regression (SVR) is a machine learning algorithm employed in time series forecasting. It tackles complex relationships and nonlinear patterns within time-dependent data.</p><p>SVR finds a hyperplane that maximizes the margin between predicted values and actual values. Kernel functions play a pivotal role in SVR, transforming data into higher-dimensional spaces for improved separation.</p><p>For example, we can use SVR model to capture nonlinear patterns and intricate relationships, and makes accurate predictions by incorporating features like historical prices, trading volumes, and technical indicators, SVR can grasp the intricate dynamics of the stock market.</p><pre>import pandas as pd<br>import numpy as np<br>from sklearn.svm import SVR<br>from sklearn.preprocessing import StandardScaler<br><br># Generate the stock price data<br>start_date = &#39;2022-01-01&#39;<br>end_date = &#39;2022-12-31&#39;<br>dates = pd.date_range(start=start_date, end=end_date, freq=&#39;D&#39;)<br>prices = np.random.randint(100, 1000, size=len(dates)).astype(float)<br><br># Create the stock price DataFrame<br>stock_data = pd.DataFrame({&#39;Date&#39;: dates, &#39;Price&#39;: prices})<br><br># Save the stock price data to a CSV file<br>stock_data.to_csv(&#39;stock_data.csv&#39;, index=False)<br><br># Prepare the data for SVR model<br>dates = pd.to_datetime(stock_data[&#39;Date&#39;])<br>prices = stock_data[&#39;Price&#39;].values.reshape(-1, 1)<br><br># Scale the data<br>scaler = StandardScaler()<br>scaled_prices = scaler.fit_transform(prices)<br><br># Split the data into training and testing sets<br>train_size = int(len(dates) * 0.8)<br>train_dates, test_dates = dates[:train_size], dates[train_size:]<br>train_prices, test_prices = scaled_prices[:train_size].ravel(), scaled_prices[train_size:].ravel()<br><br># Fit the SVR model<br>svr_model = SVR(kernel=&#39;rbf&#39;)<br>svr_model.fit(train_dates.values.reshape(-1, 1), train_prices)<br><br># Make future stock price predictions<br>predictions = svr_model.predict(test_dates.values.reshape(-1, 1))<br><br># Print the predictions for the test set<br>print(predictions)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*pyT_qtMoxDvl_iX7jhfkew.gif" /></figure><p><strong>Comparing ARIMA and SVR:</strong></p><p>ARIMA and SVR models possess unique strengths, making them suitable for different scenarios. ARIMA is often employed with stationary time series data, capturing linear relationships and addressing seasonality and trend analysis.</p><p>Conversely, SVR excels in capturing complex nonlinear relationships and patterns. It adapts well to intricate dynamics in time series data, making it invaluable when traditional regression approaches fall short.</p><p><strong>Conclusion:</strong></p><p>Time series analysis plays a pivotal role in diverse industries, facilitating accurate predictions and informed decision-making. The ARIMA model provides insights into linear relationships, seasonality, and trends, enabling accurate forecasting. On the other hand, the SVR model thrives in capturing nonlinear relationships and intricate patterns, overcoming the limitations of traditional regression approaches.</p><p>By leveraging these models and incorporating key terminologies such as stationarity, lags, and kernel functions, organizations and investors can unlock the true potential of time series analysis, empowering them to make accurate predictions and gain a competitive edge in an ever-evolving world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20dbe6d2abe2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentiment Analysis with VADER: Analyzing Twitter Sentiment]]></title>
            <link>https://medium.com/@vafaisalm93/sentiment-analysis-with-vader-analyzing-twitter-sentiment-86ae8078dacb?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/86ae8078dacb</guid>
            <category><![CDATA[sentiment]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Sat, 01 Jul 2023 23:08:39 GMT</pubDate>
            <atom:updated>2023-07-01T23:18:38.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n3MZqdzEW2KN-LspS1MD6A.jpeg" /></figure><h3>Introduction</h3><p>Sentiment analysis, also known as opinion mining, is a crucial natural language processing (NLP) technique that allows us to determine the sentiment or emotional tone expressed in a given piece of text. It involves classifying text as positive, negative, or neutral based on the underlying sentiment conveyed by the words used. Twitter, being a rich source of user-generated content, offers an excellent opportunity to perform sentiment analysis on social media data.</p><p>In this article, I will explore how to perform sentiment analysis using the Twitter Sentiment Analysis Dataset and the VADER (Valence Aware Dictionary and Entiment Reasoner) sentiment analysis model. The Twitter Sentiment Analysis Dataset is a well-curated collection of positive and negative tweets, making it a valuable resource for training and evaluating sentiment analysis models. VADER, on the other hand, is a pre-trained sentiment analysis model specifically designed for social media text, like tweets.</p><h3>Prerequisites and Setup</h3><p>Before diving into sentiment analysis, we need to ensure that we have the required libraries installed. In this tutorial, we will be using NLTK (Natural Language Toolkit), a widely-used library for NLP tasks in Python. To install NLTK, execute the following command in your terminal:</p><pre>pip install nltk<br>import nltk<br>nltk.download(&#39;twitter_samples&#39;)<br>nltk.download(&#39;vader_lexicon&#39;)<br></pre><h3>Loading and Preparing the Data</h3><p>Once we have downloaded the required datasets and lexicons, we can proceed to load the Twitter Sentiment Analysis Dataset. The dataset consists of positive and negative tweets that will be used for training and evaluation.</p><p>We can load the positive and negative tweets using the twitter samples module provided by NLTK:</p><pre>from nltk.corpus import twitter_samples<br><br># Load the positive and negative tweets from the dataset<br>positive_tweets = twitter_samples.strings(&#39;positive_tweets.json&#39;)<br>negative_tweets = twitter_samples.strings(&#39;negative_tweets.json&#39;)</pre><h3>Sentiment Analysis with VADER</h3><p>Now that we have our dataset loaded, we can perform sentiment analysis using the VADER sentiment analysis model. VADER is a rule-based model that assigns sentiment scores to words based on their lexical properties and context.</p><pre>from nltk.sentiment import SentimentIntensityAnalyzer<br><br># Initialize the VADER sentiment analysis model<br>sia = SentimentIntensityAnalyzer()</pre><p>We are now ready to analyze the sentiment of the tweets. We will loop through the positive and negative tweets, and for each tweet, we will use the VADER model to analyze its sentiment.</p><h3>Analyzing Sentiment in Positive and Negative Tweets</h3><p>After setting up the sentiment analysis model and loading the dataset, we are ready to analyze the sentiment of both positive and negative tweets using VADER.</p><p>To analyze the sentiment of positive tweets, we can add the following code:</p><pre>print(&quot;Positive tweets:&quot;)<br>for tweet in positive_tweets:<br>    sentiment = sia.polarity_scores(tweet)<br>    print(f&quot;Tweet: {tweet}&quot;)<br>    print(f&quot;Sentiment: {sentiment[&#39;compound&#39;]}&quot;)<br>    print()</pre><p>In the code above, we loop through each positive tweet in the list. For each tweet, we use the polarity score method of the Sentiment Intensity Analyzer class to obtain sentiment scores. The sentiment scores include a compound score that represents the overall sentiment of the tweet. We print the tweet and its sentiment score.</p><p>Similarly, we can analyze the sentiment of negative tweets just s the positive one by adding the following code:</p><pre>print(&quot;Negative tweets:&quot;)<br>for tweet in negative_tweets:<br>    sentiment = sia.polarity_scores(tweet)<br>    print(f&quot;Tweet: {tweet}&quot;)<br>    print(f&quot;Sentiment: {sentiment[&#39;compound&#39;]}&quot;)<br>    print()</pre><h3>Conclusion</h3><p>In this article, we have explored how to perform sentiment analysis using the Twitter Sentiment Analysis Dataset and the VADER sentiment analysis model. We started by setting up the necessary libraries and downloading the required datasets and lexicons using NLTK. We then loaded the positive and negative tweets from the Twitter Sentiment Analysis Dataset.</p><p>Next, we initialized the VADER sentiment analysis model and used it to analyze the sentiment of positive and negative tweets. By leveraging the Sentiment Intensity Analyzer class from the NLTK library, we obtained sentiment scores for each tweet, including a compound score that represents the overall sentiment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86ae8078dacb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Text to Insights: Reveling NLP Capabilities with Python.]]></title>
            <link>https://medium.com/@vafaisalm93/from-text-to-insights-reveling-nlp-capabilities-with-python-e4d1c829ff54?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4d1c829ff54</guid>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[stemming-nltk]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 11:00:55 GMT</pubDate>
            <atom:updated>2023-06-23T11:00:55.316Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*1YXsduTjH_xsJhb3-_NVvg.png" /></figure><p><strong>Introduction:</strong><br>In the digital age, the explosion of textual data presents a significant challenge and this rise a question on how can we derive meaningful insights and knowledge from this vast amount of information?</p><p>Natural Language Processing (NLP) provides a powerful solution by combining artificial intelligence, computational linguistics, and computer science to enable machines to understand, interpret, and generate human language.</p><p>This article explores the immense potential of NLP and highlights the capabilities of its Python packages that facilitate NLP tasks. By leveraging these packages, we can unlock valuable insights hidden within text data and gain a deeper understanding of language patterns.</p><p><strong>Understanding NLP</strong><br>At its core, NLP focuses on bridging the gap between human language and machines. It encompasses a diverse set of techniques and methodologies that enable computers to process and analyze text, derive meaning, and respond intelligently. Key components of NLP include:</p><ol><li><strong>Text Preprocessing</strong>: Before any analysis can be performed, raw text data must undergo preprocessing steps such as tokenization (breaking text into smaller units), stemming (reducing words to their root form), and removing noise (stop words, punctuation, etc.). This ensures a clean and manageable dataset for further analysis.</li><li><strong>Language Understanding</strong>: NLP enables computers to understand language through tasks like part-of-speech tagging (identifying grammatical elements of a sentence), named entity recognition (identifying and classifying named entities such as people, organizations, and locations), and parsing (analyzing sentence structure and grammatical relationships).</li><li><strong>Sentiment Analysis</strong>: Sentiment analysis allows for the extraction of subjective information from text, enabling computers to determine the sentiment or emotional tone expressed in a piece of writing. This has applications in customer feedback analysis, social media monitoring, and reputation management.</li><li><strong>Language Generation</strong>: NLP enables machines to generate human-like language, whether it’s in the form of chatbots, automated content creation, or machine translation. Techniques such as language modeling, neural networks, and deep learning play a significant role in generating coherent and contextually relevant text.</li><li><strong>Machine Translation</strong>: NLP has revolutionized language translation by automating the process of converting text from one language to another. Advanced algorithms and neural machine translation models have improved translation accuracy and fluency, facilitating cross-border communication and global collaborations.</li><li><strong>Information Extraction:</strong> NLP techniques facilitate the extraction of structured information from unstructured text. Named Entity Recognition (NER), entity linking, and relation extraction allow for the identification and classification of specific information, contributing to tasks like knowledge graph construction, information retrieval, and data integration.</li></ol><p><strong>Necessary Python Packages for NLP</strong></p><p>There are several libraries for NLP and below are some of the prominent ones:-</p><ol><li><strong>NLTK (Natural Language Toolkit): </strong>NLTK is a comprehensive library that provides a vast collection of tools and resources for NLP tasks. It offers functionalities for tokenization, stemming, lemmatization, part-of-speech tagging, named entity recognition, sentiment analysis, and much more. NLTK is an excellent choice for beginners due to its extensive documentation and user-friendly interfaces.</li><li><strong>Text-Blob</strong>: Text Blob is a simple and intuitive library built on top of NLTK. It provides an easy-to-use API for common NLP tasks, including sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.</li><li><strong>SpaCy</strong>: spaCy is a popular and efficient library for NLP tasks. It is designed to be fast and scalable, making it suitable for processing large volumes of text. spaCy provides pre-trained models for various languages, allowing users to perform tasks such as tokenization, entity recognition, dependency parsing, and text classification with ease.</li><li><strong>PyTorch:</strong> PyTorch is another widely-used deep learning library that offers flexibility and ease of use. It provides tools for building and training neural networks, and it has gained popularity in the NLP community for tasks like text classification, sequence labeling, and machine translation.</li></ol><p><strong>Practical Applications of NLP</strong></p><p>NLP has found practical applications in numerous fields, transforming the way we interact with language and data. Here are some notable applications:</p><ol><li><strong>Customer Service and Support:</strong> NLP-powered chatbots and virtual assistants provide personalized customer service, answering queries, resolving issues, and automating routine tasks. They can understand and respond to natural language inputs, improving customer satisfaction and operational efficiency.</li><li><strong>Information Retrieval: </strong>NLP techniques enhance the effectiveness of search engines by understanding user queries and retrieving relevant information from vast amounts of textual data. This enables faster and more accurate search results, improving user experiences.</li><li><strong>Healthcare and Biomedicine: </strong>In the healthcare domain, NLP aids in medical record analysis, clinical decision support, and disease surveillance. It enables the extraction of crucial information from medical texts, facilitating better patient care, and medical research.</li><li><strong>Financial Analysis:</strong> NLP is extensively used in sentiment analysis of financial news, social media data, and reports to assess market sentiment, predict stock market trends, and inform investment decisions.</li><li><strong>Content Curation and Recommendation:</strong> NLP algorithms analyze user preferences, behaviors, and content patterns to curate personalized recommendations for articles, products, movies, and more.</li></ol><p><strong>Conclusion:</strong></p><p>To summarize, Natural Language Processing (NLP) is causing a paradigm shift in the processing, analysis, and extraction of insights from textual data. Its impact is felt across various industries, including customer experiences, information retrieval, and healthcare outcomes.</p><p>By harnessing the capabilities of NLP and utilizing its wide array of techniques and algorithms, we can tap into the untapped potential of language understanding, leading us towards a future that is more interconnected and intelligent.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4d1c829ff54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clustering Unleashed: Revealing Patterns and Insights in Data]]></title>
            <link>https://medium.com/@vafaisalm93/clustering-unleashed-revealing-patterns-and-insights-in-data-cb7c08d115e8?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb7c08d115e8</guid>
            <category><![CDATA[data-wrangling]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 18:56:19 GMT</pubDate>
            <atom:updated>2023-06-07T18:56:19.249Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*kIO6Io1w84CeXD2iPe5vgg.jpeg" /></figure><p>Introduction</p><p>Machine learning clustering is a technique used to group similar data points together based on their characteristics or features. Clustering algorithms aim to identify patterns or structures in the data without any predefined labels or target variables. It is an unsupervised learning method as it does not rely on labeled training data.</p><p>There are several popular clustering algorithms like K-means, hierarchical, DBSCAN, Gaussian Mixture, spectral, and each has its own approach and assumptions.</p><p>In this article, I will explore the intricacies of clustering, shedding light on popular K-means and Hierarchical algorithms with some toy dataset examples derived from Sci-kit Learn.</p><p>The below codes uses make_blobs function from scikit-learn to show how K-means and Hierarchical clustering works.</p><p>It consists of 200 data points distributed across four distinct blobs:</p><ol><li>K-means Clustering: K-means clustering is a widely used algorithm that aims to partition data into K clusters. It operates by iteratively assigning data points to the nearest centroid and updating the centroids until convergence. The algorithm’s simplicity and efficiency make it a popular choice, but it relies on a predefined number of clusters, which can be a drawback when the optimal K value is unknown.</li></ol><pre>from sklearn.cluster import KMeans<br>from sklearn.datasets import make_blobs<br><br># Generate sample data<br>X, _ = make_blobs(n_samples=200, centers=4, random_state=0)<br><br># Creating KMeans object with 4 clusters and setting n_init explicitly<br>kmeans = KMeans(n_clusters=4, n_init=10)<br><br># Fitting the data to the K-means algorithm<br>kmeans.fit(X)<br><br># Getting the cluster labels assigned to each data point<br>labels = kmeans.labels_<br><br># Getting the cluster centers<br>centers = kmeans.cluster_centers_<br><br>print(&quot;Cluster Labels:&quot;, labels)<br>print(&quot;Cluster Centers:&quot;, centers)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*aF5duf5-fT55vzcOGW70EA.gif" /><figcaption>K-means Cluster labels</figcaption></figure><pre>import matplotlib.pyplot as plt<br>from sklearn.datasets import make_blobs<br><br># Generate sample data<br>X, _ = make_blobs(n_samples=200, centers=4, random_state=0)<br><br># Clustering results<br>labels = [2, 3, 1, 0, 2, 1, 3, 1, 1, 1, 1, 2, 3, 3, 2, 1, 0, 0, 0, 1, 0, 1, 2, 3, 2, 2, 0, 2, 2, 1, 0, 1, 3, 2, 3, 1, 3,<br>          1, 1, 0, 0, 0, 0, 1, 2, 3, 1, 0, 0, 1, 0, 3, 3, 0, 2, 0, 3, 2, 0, 2, 0, 1, 2, 1, 0, 1, 2, 0, 3, 3, 2, 2, 1, 1,<br>          3, 0, 3, 3, 2, 2, 0, 1, 2, 2, 3, 1, 1, 2, 3, 3, 0, 0, 0, 1, 1, 2, 3, 0, 2, 1, 0, 2, 2, 0, 0, 3, 1, 2, 2, 1, 0,<br>          3, 3, 2, 2, 1, 2, 3, 0, 1, 0, 3, 1, 2, 1, 3, 1, 3, 2, 1, 3, 2, 1, 0, 0, 3, 0, 0, 2, 0, 2, 3, 2, 2, 3, 2, 1, 2,<br>          3, 0, 0, 0, 1, 3, 2, 1, 0, 3, 0, 2, 0, 2, 2, 3, 3, 0, 1, 2, 2, 3, 1, 1, 3, 0, 0, 0, 1, 0, 3, 3, 1, 2, 1, 2, 1,<br>          3, 3, 0, 1, 0, 2, 2, 1, 0, 3, 3, 3, 1, 0, 1]<br><br># Cluster centers<br>centers = [[-1.37860109, 7.59103386],<br>           [0.87599329, 4.21437989],<br>           [2.09071191, 1.00770612],<br>           [-1.90317099, 2.9957545]]<br><br># Plotting the data points and cluster centers<br>plt.scatter(X[:, 0], X[:, 1], c=labels, cmap=&#39;viridis&#39;)<br>plt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*QgniJUNT2mildxY11p9IZA.gif" /><figcaption>K-means Clustering</figcaption></figure><ol><li>Hierarchical Clustering: Hierarchical clustering takes a different approach by building a hierarchy of clusters. Agglomerative clustering starts with each data point as a separate cluster and merges the most similar clusters iteratively. Divisive clustering begins with all data points in a single cluster and recursively divides it. This algorithm provides a visual representation of the cluster hierarchy through dendrograms, allowing for flexibility in determining the number of clusters.</li></ol><pre>from sklearn.cluster import AgglomerativeClustering<br>from sklearn.datasets import make_blobs<br><br># Generate sample data<br>X, _ = make_blobs(n_samples=200, centers=4, random_state=0)<br><br># Creating AgglomerativeClustering object with 4 clusters<br>hierarchical = AgglomerativeClustering(n_clusters=4)<br><br># Fitting the data to the hierarchical clustering algorithm<br>hierarchical.fit(X)<br><br># Getting the cluster labels assigned to each data point<br>labels = hierarchical.labels_<br><br>print(&quot;Cluster Labels:&quot;, labels)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*KXZEIqHU7Nldj2PzV0I97Q.gif" /><figcaption>Hierarchical Cluster label</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*4G4Ql7Ysk1p8tFaufJMCpw.gif" /><figcaption>Hierarchical Clustering</figcaption></figure><p>In conclusion, clustering algorithms such as K-means and hierarchical clustering are vital tools for extracting meaningful patterns and valuable insights from data. Throughout this article, we have examined recent illustrations of these algorithms implemented with the scikit-learn library. By harnessing the power of clustering techniques, researchers and professionals can leverage the potential of diverse datasets to drive informed decision-making, uncover concealed patterns, and open up new possibilities in numerous fields and industries.</p><p>These algorithms serve as valuable assets in the realm of data analysis, empowering individuals to extract actionable knowledge and make significant strides in their respective domains.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb7c08d115e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparative Analysis of Linear SVC and Random Forest Classifiers for Multiclass Classification]]></title>
            <link>https://medium.com/@vafaisalm93/comparative-analysis-of-linear-svc-and-random-forest-classifiers-for-multiclass-classification-dd5aafeba79c?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd5aafeba79c</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[machine-learning-classes]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Fri, 26 May 2023 15:09:17 GMT</pubDate>
            <atom:updated>2023-05-26T15:09:17.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*GEfmzksWOS4Iskj1IJAF6Q.jpeg" /></figure><p><strong>Introduction:</strong></p><p>In the field of machine learning, choosing the right classifier for a given task is crucial. Different classifiers have varying strengths and weaknesses, making it essential to evaluate their performance on specific datasets. In this article, I present a comparative analysis of two popular classifiers, Linear SVC and Random Forest for multiclass classification.</p><p>Accuracy, precision, recall, and F1-score metrics were examined to determine their effectiveness in predicting the class labels of different cuisines.</p><p><strong>Experimental Setup:</strong></p><p>To run the experiment, a utilized labeled dataset comprising various cuisines, including Chinese, Indian, Japanese, Korean, and Thai was used and the dataset was split into training and test sets and applied both the Linear SVC and Random Forest classifiers to predict the cuisine labels.</p><p>I then evaluated the performance of each classifier using standard classification metrics.</p><pre>from sklearn.svm import SVC<br>from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier<br>from sklearn.model_selection import train_test_split, cross_val_score<br>from sklearn.metrics import accuracy_score,precision_score,confusion_matrix,classification_report, precision_recall_curve<br>import numpy as np<br>X_train, X_test, y_train, y_test = train_test_split(cuisines_feature_df, cuisines_label_df, test_size=0.3)</pre><p><strong>Results and Discussion:</strong></p><p>Upon evaluating the classifiers, the following results were obtained :</p><ol><li><strong>Linear SVC: </strong>The Linear SVC classifier achieved an accuracy of 69.0% on the test set. The precision, recall, and F1 score varied across the different classes. Notably, it performed well in predicting Indian cuisine, with precision and recall values of 0.80 and 0.86, respectively. However, its performance was comparatively weaker for the Japanese and Thai cuisines, with F1-scores of 0.54 and 0.60, respectively.</li><li><strong>Random Forest: </strong>The Random Forest classifier outperformed the Linear SVC, achieving an accuracy of 75.1% on the test set. It demonstrated higher precision, recall, and F1 scores for most of the classes. Particularly, it excelled in predicting Indian cuisine, with precision, recall, and F1-score values of 0.85, 0.92, and 0.88, respectively. The Random Forest classifier also showed a good overall performance, with a weighted average F1-score of 0.74.</li></ol><pre>from sklearn.impute import SimpleImputer<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.ensemble import RandomForestClassifier<br><br># Handle missing values<br>imputer = SimpleImputer(strategy=&#39;mean&#39;)<br>X_train_imputed = imputer.fit_transform(X_train)<br>X_test_imputed = imputer.transform(X_test)<br><br># Scale the data<br>scaler = StandardScaler()<br>X_train_scaled = scaler.fit_transform(X_train_imputed)<br>X_test_scaled = scaler.transform(X_test_imputed)<br><br># Create classifiers<br>classifiers = {<br>    &#39;Linear SVC&#39;: SVC(kernel=&#39;linear&#39;, C=C, probability=True, random_state=0),<br>    &#39;Random Forest&#39;: RandomForestClassifier(n_estimators=100, random_state=0)<br>}<br><br># Train and evaluate classifiers<br>for name, classifier in classifiers.items():<br>    classifier.fit(X_train_scaled, np.ravel(y_train))<br>    y_pred = classifier.predict(X_test_scaled)<br>    accuracy = accuracy_score(y_test, y_pred)<br>    print(&quot;Accuracy (test) for %s: %0.1f%%&quot; % (name, accuracy * 100))<br>    print(classification_report(y_test, y_pred))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*1DCWbmi1xTEVVaFUcSjrSA.gif" /><figcaption>Linear SVC and Random Forest Results</figcaption></figure><p><strong>Comparison and Conclusion:</strong></p><p>Comparing the two classifiers, the Random Forest classifier exhibited superior performance compared to the Linear SVC. It achieved higher accuracy and generally higher precision, recall, and F1 scores across multiple classes. This suggests that the Random Forest classifier is better suited for the given multiclass classification task.</p><p>However, it is important to note that the performance of classifiers can vary depending on the dataset and problem at hand. Therefore, it is advisable to consider the specific requirements of the task and domain knowledge when selecting a classifier.</p><p>In conclusion, the comparative analysis highlighted the effectiveness of the Random Forest classifier for predicting cuisine labels in a multiclass classification problem. It&#39;s higher accuracy and stronger performance across different classes make it a promising choice for similar tasks. Researchers and practitioners can benefit from these findings when selecting classifiers for multiclass classification problems in various domains.</p><p><strong>Disclaimer:</strong></p><p>This article is written as an outcome of knowledge acquired from the Arewa Data Science Machine Learning fellowship and the result presented in this article are based on a specific dataset and may not generalize to other datasets or problems. It is recommended to conduct thorough evaluations and consider domain-specific factors when choosing a classifier for a particular task.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd5aafeba79c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Linear Regression and Ridge Regression Models for Predictive Analysis]]></title>
            <link>https://medium.com/@vafaisalm93/exploring-linear-regression-and-ridge-regression-models-for-predictive-analysis-d0c8791c36ba?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0c8791c36ba</guid>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Sun, 21 May 2023 22:55:09 GMT</pubDate>
            <atom:updated>2023-05-22T13:39:50.887Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*-taXoUk2JNtQE-8GRPI6XA.png" /></figure><p><strong>Introduction:</strong><br>In today’s data-driven world, the ability to accurately predict outcomes based on available data is of paramount importance. Regression analysis, a statistical technique, enables us to estimate the relationship between a dependent variable and one or more independent variables. In this article, I delve into the comparative analysis of linear regression and ridge regression models for predicting a target variable. By examining their performance metrics and leveraging cross-validation.</p><p>Toy dataset was extracted from <a href="https://scikit-learn.org/stable/auto_examples/datasets/plot_random_multilabel_dataset.html#sphx-glr-auto-examples-datasets-plot-random-multilabel-dataset-py">here</a> and the aim is to shed light on their effectiveness in predictive modeling.</p><p>Linear regression is a widely used technique that seeks to establish a linear relationship between the target variable and the independent variables. It assumes that the relationship can be represented by a straight line. However, linear regression can be affected by multicollinearity, where the independent variables are highly correlated. To address this issue, ridge regression comes into play. Ridge regression incorporates a regularization term that penalizes large coefficients, mitigating the impact of multicollinearity and providing a more robust model.</p><p><strong>Dataset and Methodology:</strong><br>For this analysis, I modified and play around with a generated dataset using the make_multilabel_classification function from the sci-kit-learn library. The dataset comprises carefully chosen features that are expected to influence the target variable. I split the data into training and test sets to evaluate the models’ performance. The mean squared error (MSE) and R-squared values serve as evaluation metrics. Additionally, cross-validation is applied to validate the models and assess their generalization capability.</p><pre>import numpy as np<br>import pandas as pd<br>from sklearn.datasets import make_multilabel_classification<br>from sklearn.linear_model import LinearRegression<br><br># Define the random seed<br>RANDOM_SEED = np.random.randint(2**10)<br># Set random seed for reproducibility<br>RANDOM_SEED = 42<br># Generate the dataset<br>X, Y = make_multilabel_classification(<br>    n_samples=150,<br>    n_features=2,<br>    n_classes=3,<br>    n_labels=1,<br>    length=50,<br>    allow_unlabeled=False,<br>    return_distributions=False,<br>    random_state=RANDOM_SEED,<br>)<br># Convert the arrays to pandas DataFrame for easy printing<br>X_df = pd.DataFrame(X)<br>Y_df = pd.DataFrame(Y)<br><br># Print the head of X and Y<br>print(&quot;Features (X):&quot;)<br>print(X_df.head())<br>print(&quot;\nLabels (Y):&quot;)<br>print(Y_df.head())<br><br># Train a linear regression model<br>regression_model = LinearRegression()<br>regression_model.fit(X, Y)<br><br># Generate new test data<br>X_test, _ = make_multilabel_classification(<br>    n_samples=50,<br>    n_features=2,<br>    n_classes=3,<br>    n_labels=1,<br>    length=50,<br>    allow_unlabeled=False,<br>    return_distributions=False,<br>    random_state=RANDOM_SEED + 1,<br>)<br><br># Predict the labels for the test data<br>Y_pred = regression_model.predict(X_test)<br><br># Print the predicted labels<br>print(&quot;Predicted labels:&quot;)<br>print(Y_pred)</pre><p><strong>Performance Evaluation:</strong></p><pre>import numpy as np<br>from sklearn.datasets import make_multilabel_classification<br>from sklearn.linear_model import LinearRegression<br>from sklearn.metrics import mean_squared_error, r2_score<br><br># Generate the dataset<br>X, Y = make_multilabel_classification(n_samples=150, n_features=2, n_classes=3, n_labels=1, length=50, allow_unlabeled=False, random_state=42)<br><br># Train a linear regression model<br>regression_model = LinearRegression()<br>regression_model.fit(X, Y)<br><br># Generate new test data<br>X_test, Y_test = make_multilabel_classification(n_samples=50, n_features=2, n_classes=3, n_labels=1, length=50, allow_unlabeled=False, random_state=43)<br><br># Predict the labels for the test data<br>Y_pred = regression_model.predict(X_test)<br><br># Calculate metrics<br>mse = mean_squared_error(Y_test, Y_pred)<br>r2 = r2_score(Y_test, Y_pred)<br><br># Print metrics<br>print(&quot;Mean Squared Error (MSE):&quot;, mse)<br>print(&quot;R-squared:&quot;, r2)</pre><pre>Mean Squared Error (MSE): 0.30512712366914196<br>R-squared: -0.6526122205436339</pre><p>Upon applying the linear regression model to the dataset, I obtained an MSE of 0.30512712366914196 and an R-squared value of -0.6526122205436339. These results indicate that the linear regression model’s predictions deviate significantly from the actual values. It suggests that the model may not adequately capture the underlying relationships in the data.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.datasets import make_regression<br>from sklearn.linear_model import Ridge<br>from sklearn.metrics import mean_squared_error, r2_score<br>from sklearn.model_selection import train_test_split<br><br># Set random seed<br>np.random.seed(42)<br><br># Generate the dataset<br>X, Y = make_regression(n_samples=150, n_features=2, noise=0.5)<br><br># Split the dataset into training and test sets<br>X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=42)<br><br># Train the Ridge regression model<br>ridge_model = Ridge(alpha=0.5)  # You can experiment with different values of alpha<br>ridge_model.fit(X_train, Y_train)<br><br># Make predictions using the trained model<br>Y_pred = ridge_model.predict(X_test)<br><br># Evaluate the model<br>mse = mean_squared_error(Y_test, Y_pred)<br>r2 = r2_score(Y_test, Y_pred)<br><br>print(&quot;Mean Squared Error (MSE):&quot;, mse)<br>print(&quot;R-squared:&quot;, r2)</pre><pre>Mean Squared Error (MSE): 0.4349376954203173<br>R-squared: 0.999454250343002</pre><p>In contrast, the ridge regression model demonstrates enhanced performance with an MSE of 0.4349376954203173 and an R-squared value of 0.999454250343002. The substantially lower MSE and higher R-squared value signify that the ridge regression model provides a better fit to the data. It successfully captures a larger proportion of the target variable’s variance, indicating its superior predictive accuracy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*erYTyerOv32jiflXQ7LEMA.png" /></figure><p><strong>Robustness Assessment with Cross-Validation:</strong><br>To ensure the stability and robustness of the ridge regression model, cross-validation was employed. The results reveal a mean MSE of 0.2617991554821172 with a standard deviation of 0.03256626322896778. These findings highlight the reliability of the ridge regression model across different subsets of the data. The model consistently performs well, underscoring its ability to generalize and make accurate predictions.</p><pre>import matplotlib.pyplot as plt<br><br>mean_mse = 0.2617991554821172<br>std_mse = 0.03256626322896778<br><br># Create a bar plot<br>plt.bar([&quot;Mean MSE&quot;], [mean_mse], yerr=[std_mse])<br><br># Add labels and title<br>plt.xlabel(&quot;Evaluation Metric&quot;)<br>plt.ylabel(&quot;Value&quot;)<br>plt.title(&quot;Cross-Validation Results&quot;)<br><br># Show the plot<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*MGOhk3_lkVCObXGuJT-8ow.png" /></figure><p><strong>Conclusion:</strong><br>In this article, I explored the application of linear regression and ridge regression models for predictive analysis. The evaluation revealed that the ridge regression model outperforms linear regression in terms of predictive accuracy and capturing the underlying relationships in the data. The regularization incorporated in the ridge regression model effectively addresses multicollinearity issues, resulting in improved performance metrics. The cross-validation results further reinforced the stability and robustness of the ridge regression model.</p><p>Researchers and practitioners can benefit from these findings by incorporating ridge regression in their predictive modeling endeavors, particularly when faced with multicollinearity challenges. However, further research can explore other regression techniques, such as Lasso regression or elastic net regression, and compare their performance against linear regression and ridge regression models. Additionally, feature selection techniques can be implemented to identify the most influential features and further enhance the models’ predictive power.</p><p>In conclusion, predictive analysis using ridge regression offers a powerful approach for accurate target variable estimation. By leveraging advanced modeling techniques and evaluating their performance, we can make more informed decisions and unlock value.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0c8791c36ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Machine Learning: An Overview of Techniques, History, and Ethical Considerations”]]></title>
            <link>https://medium.com/@vafaisalm93/machine-learning-an-overview-of-techniques-history-and-ethical-considerations-3381743f7f19?source=rss-62694ab20100------2</link>
            <guid isPermaLink="false">https://medium.com/p/3381743f7f19</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Faisal Muhammad Adam]]></dc:creator>
            <pubDate>Sun, 02 Apr 2023 22:58:32 GMT</pubDate>
            <atom:updated>2023-04-02T23:12:15.190Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Machine learning is an exciting field that involves using algorithms to learn patterns from data and make predictions or decisions. It has the potential to transform various industries, including healthcare, finance, and transportation. In this article, we will provide an overview of machine learning techniques, their history, and ethical considerations.</p><p><strong>History of Machine Learning</strong></p><p>The history of machine learning can be traced back to the 1940s, with early pioneers such as Alan Turing, Marvin Minsky, and Arthur Samuel making significant contributions to the field.</p><p>From the 1950s through the mid-’70s, the era was named “The golden years”. This is because the research was well funded by government agencies, advances were made in computation and algorithms, and prototypes of intelligent machines like shakey the robot, block worlds, and Eliza were built.</p><p>Also, machine learning experienced a surge in popularity, with the development of algorithms such as decision trees, neural networks, and support vector machines.</p><p>From 1974 to 1980, was called the AI winter era where funding for ML dried up, computing power was too limited and the number of parameters needed to be trained grew exponentially as more was asked of computers, without a parallel evolution of computing power and capability.</p><p>The 1980s to the 90s was an era of expert systems and neural networks. Machine learning became more interdisciplinary, with the incorporation of statistics, optimization, and data mining. In the 21st century, machine learning has continued to evolve, with the rise of deep learning and reinforcement learning.</p><p>From 1993 to 2011, the field began to gain maturity as it solves some of the problems that had been caused earlier by the lack of data and computing power. The amount of data began to rapidly increase and become more widely available, especially with the advent of the smartphone around 2007.</p><p>From 2011 to date, machine learning and AI touch almost every part of our lives. This era calls for a careful understanding of the risks and potential effects of these algorithms on human lives. As Microsoft’s Brad Smith has stated, “Information technology raises issues that go to the heart of fundamental human rights protections like privacy and freedom of expression. These issues heighten the responsibility of tech companies that create these products.</p><p><strong>Ethical Considerations in Machine Learning</strong></p><p>Fairness is an important ethical consideration in machine learning, as algorithms can perpetuate or even amplify existing biases and discrimination. For example, facial recognition technology has been shown to be less accurate for people with darker skin tones, and credit scoring systems can be biased against certain demographic groups. To mitigate these biases, techniques such as counterfactual fairness and algorithmic transparency have been developed.</p><p>In addition to fairness, other ethical considerations in machine learning include privacy, accountability, and transparency.</p><p>Privacy concerns arise when machine learning algorithms are trained on sensitive data, such as medical records or financial information.</p><p>Accountability is important to ensure that decisions made by machine learning algorithms are explainable and can be audited.</p><p>Transparency involves making the decision-making process of machine learning algorithms more understandable to users.</p><p><strong>Techniques in Machine Learning</strong></p><p>Machine learning can be broadly classified into three types: supervised learning, unsupervised learning, and reinforcement learning. In supervised learning, the algorithm is trained on labeled data, where each example is accompanied by a target variable. The goal is to learn a function that maps input variables to output variables based on the examples in the training data. Some examples of supervised learning include image classification, speech recognition, and regression analysis.</p><p>In unsupervised learning, the algorithm is trained on an unlabeled dataset, where there are no target variables. The goal is to discover patterns or structures in the data, such as clusters or latent variables. Unsupervised learning is often used in exploratory data analysis or to preprocess data before using other techniques of machine learning. Some examples of unsupervised learning include clustering, dimensionality reduction, and anomaly detection.</p><p>Reinforcement learning involves training an algorithm to make decisions in an environment, with the goal of maximizing some reward signal. The algorithm receives feedback in the form of rewards or penalties based on its actions, and over time, it learns to make better decisions to achieve its goal. Reinforcement learning is often used in robotics, game-playing, and optimization problems.</p><p>Semi-supervised learning is a hybrid approach that combines both supervised and unsupervised learning. In semi-supervised learning, the algorithm is trained on a partially labeled dataset, where only some examples are accompanied by target variables. The goal is to use the labeled data to guide the learning process and improve the accuracy of predictions on the unlabeled data. Semi-supervised learning is often used when labeled data is scarce or expensive to obtain.</p><p>Transfer learning involves reusing a pre-trained model for a new task, rather than training a new model from scratch. The pre-trained model is often trained on a large and diverse dataset, and the goal of transfer learning is to transfer the knowledge learned from that dataset to the new task. Transfer learning is often used in computer vision and natural language processing, where pre-trained models can be used as a starting point for new applications</p><p><strong>Conclusion</strong></p><p>In conclusion, machine learning is a rapidly evolving field with a wide range of applications in various industries. Understanding the different techniques of machine learning, its history, and ethical considerations is essential for designing and implementing effective and responsible machine learning systems. As the use of machine learning continues to grow, it is important to ensure that its development and deployment are guided by ethical principles to ensure that the benefits of machine learning are shared by everyone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3381743f7f19" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>