<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Waleed Shamhan</title>
    <description>The latest articles on DEV Community by Waleed Shamhan (@waleedshamhan2050sys).</description>
    <link>https://dev.to/waleedshamhan2050sys</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4044503%2F21d445ad-a539-425a-9c8d-2fb0458d3466.jpg</url>
      <title>DEV Community: Waleed Shamhan</title>
      <link>https://dev.to/waleedshamhan2050sys</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/waleedshamhan2050sys"/>
    <language>en</language>
    <item>
      <title>Cybersecurity Roadmap #2: Computer Basics Every Security Learner Needs</title>
      <dc:creator>Waleed Shamhan</dc:creator>
      <pubDate>Fri, 16 Oct 2026 18:07:23 +0000</pubDate>
      <link>https://dev.to/waleedshamhan2050sys/cybersecurity-roadmap-2-computer-basics-every-security-learner-needs-5c24</link>
      <guid>https://dev.to/waleedshamhan2050sys/cybersecurity-roadmap-2-computer-basics-every-security-learner-needs-5c24</guid>
      <description>&lt;p&gt;This is episode 2 of my &lt;strong&gt;Cybersecurity Roadmap&lt;/strong&gt; series, where I learn cybersecurity in public. Last time: what cybersecurity is and the CIA triad. Today: the computer basics you need &lt;em&gt;before&lt;/em&gt; any hacking or defending makes sense.&lt;/p&gt;

&lt;p&gt;You cannot protect what you do not understand. So let us build the mental model.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Hardware: what actually runs your code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;CPU&lt;/strong&gt; — executes instructions. Every program, including malware, is ultimately instructions for the CPU.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RAM&lt;/strong&gt; — fast, temporary memory. Turn the power off and it is gone. Passwords and keys sitting in RAM can be stolen while the machine runs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage (SSD/HDD)&lt;/strong&gt; — permanent memory. Deleted files are often recoverable, because "delete" usually just marks space as reusable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network card&lt;/strong&gt; — connects the machine to other machines. Every attack from the internet arrives through it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security lesson: data in RAM is exposed while the machine runs, and "deleted" does not mean "gone".&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Operating system: the boss of the machine
&lt;/h2&gt;

&lt;p&gt;The OS (Windows, Linux, macOS) sits between programs and hardware. It decides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Which program runs when&lt;/strong&gt; (processes)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Who can read or change which file&lt;/strong&gt; (permissions)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Which program may use the network&lt;/strong&gt; (firewall rules)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two security ideas live here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Processes:&lt;/strong&gt; every running program is a process. Malware is just a process you did not want. Task Manager (Windows) or &lt;code&gt;ps&lt;/code&gt; (Linux) shows you what is running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Users and permissions:&lt;/strong&gt; files and programs have owners and permission levels. A normal user account cannot change system files; an administrator can. This is why you should not browse the web as administrator — any malware you run inherits your permissions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Files, extensions, and why they matter
&lt;/h2&gt;

&lt;p&gt;A file's extension hints at what it is — but it is only a hint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.txt&lt;/code&gt;, &lt;code&gt;.pdf&lt;/code&gt;, &lt;code&gt;.jpg&lt;/code&gt; — usually data, not programs&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.exe&lt;/code&gt;, &lt;code&gt;.bat&lt;/code&gt;, &lt;code&gt;.sh&lt;/code&gt; — programs that &lt;em&gt;run&lt;/em&gt; when opened&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.docx&lt;/code&gt;, &lt;code&gt;.xlsx&lt;/code&gt; — documents that can contain macros (code!) — a classic malware carrier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security lesson: "invoice.pdf.exe" is a program, not a PDF. Windows hides extensions by default — turn "show file extensions" on. It is a five-second change that stops a whole class of tricks.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The command line is not optional
&lt;/h2&gt;

&lt;p&gt;A lot of security work happens in the terminal: checking processes, inspecting files, testing networks. You do not need to memorize everything — you need to be comfortable with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listing files and moving between folders (&lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;, &lt;code&gt;dir&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Reading a file (&lt;code&gt;cat&lt;/code&gt;, &lt;code&gt;type&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Seeing what is running (&lt;code&gt;ps&lt;/code&gt;, Task Manager)&lt;/li&gt;
&lt;li&gt;Checking network connections (&lt;code&gt;netstat&lt;/code&gt;, &lt;code&gt;ss&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the command line scares you, practice ten minutes a day. It pays off in every later episode.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Updates: the most boring, most important defense
&lt;/h2&gt;

&lt;p&gt;Most successful attacks do not use genius zero-days. They use &lt;strong&gt;known vulnerabilities in unpatched software&lt;/strong&gt; — bugs the vendor already fixed. Updating your OS, browser, and apps closes those holes. Automatic updates exist for a reason: turn them on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick checklist before the next episode
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] You can explain CPU, RAM, storage, and network card in one sentence each&lt;/li&gt;
&lt;li&gt;[ ] You know what a process is and how to list running ones&lt;/li&gt;
&lt;li&gt;[ ] You know why running as administrator is risky&lt;/li&gt;
&lt;li&gt;[ ] File extensions are visible on your machine&lt;/li&gt;
&lt;li&gt;[ ] Your OS and browser are up to date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next episode: &lt;strong&gt;Networks — how data actually moves&lt;/strong&gt;, and why that matters for attackers and defenders. Follow along, and tell me in the comments: &lt;strong&gt;Windows, Linux, or macOS — what do you learn on?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>beginners</category>
      <category>security</category>
      <category>learning</category>
    </item>
    <item>
      <title>Cybersecurity Roadmap #1: What Is Cybersecurity, Really?</title>
      <dc:creator>Waleed Shamhan</dc:creator>
      <pubDate>Fri, 16 Oct 2026 18:07:22 +0000</pubDate>
      <link>https://dev.to/waleedshamhan2050sys/cybersecurity-roadmap-1-what-is-cybersecurity-really-24oi</link>
      <guid>https://dev.to/waleedshamhan2050sys/cybersecurity-roadmap-1-what-is-cybersecurity-really-24oi</guid>
      <description>&lt;p&gt;Welcome to my &lt;strong&gt;Cybersecurity Roadmap&lt;/strong&gt; — a series where I learn cybersecurity in public, one topic at a time, and share everything I learn. No fluff, no assumed knowledge. If you are a student or a beginner wondering where to start, this series is for you.&lt;/p&gt;

&lt;p&gt;In this first episode: what cybersecurity actually is, why it matters, and the three ideas everything else is built on.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is cybersecurity?
&lt;/h2&gt;

&lt;p&gt;Cybersecurity is the practice of protecting systems, networks, and data from digital attacks. Those attacks usually aim to do one of three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Steal&lt;/strong&gt; information (passwords, personal data, business secrets)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Damage&lt;/strong&gt; systems (delete data, shut down services, spread malware)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trick&lt;/strong&gt; people (phishing, scams, fake websites)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every defense you will ever learn — firewalls, encryption, strong passwords, updates — exists to stop one of those three.&lt;/p&gt;

&lt;h2&gt;
  
  
  The foundation: the CIA triad
&lt;/h2&gt;

&lt;p&gt;Almost everything in cybersecurity comes back to three goals, known as the &lt;strong&gt;CIA triad&lt;/strong&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Confidentiality — only the right people see the data
&lt;/h3&gt;

&lt;p&gt;Your messages, passwords, and files should be readable only by the people allowed to see them. Tools: passwords, encryption, access control.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Integrity — the data stays correct and unmodified
&lt;/h3&gt;

&lt;p&gt;Nobody should be able to secretly change your data — not a bank balance, not a grade, not a medical record. Tools: hashing, digital signatures, backups.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Availability — the system works when you need it
&lt;/h3&gt;

&lt;p&gt;Security means nothing if the service is down. Systems must stay up and reachable for legitimate users. Tools: redundancy, backups, protection against denial-of-service attacks.&lt;/p&gt;

&lt;p&gt;A real attack usually breaks at least one of the three. A phishing email that steals your password? That breaks &lt;strong&gt;confidentiality&lt;/strong&gt;. Ransomware that encrypts your files? That breaks &lt;strong&gt;availability&lt;/strong&gt; (and often confidentiality too). A tampered download? That breaks &lt;strong&gt;integrity&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why should you care?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Your accounts, photos, and messages are targets — attackers automate their work, so you do not need to be famous to be attacked.&lt;/li&gt;
&lt;li&gt;Companies lose money and trust after breaches, so cybersecurity is one of the most in-demand skills in tech right now.&lt;/li&gt;
&lt;li&gt;The basics stop most attacks. You do not need to be a hacker to be safer — you need the fundamentals, applied consistently.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next in this series
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;What is cybersecurity (this post)&lt;/li&gt;
&lt;li&gt;Computer basics every security learner needs&lt;/li&gt;
&lt;li&gt;Networks: how data actually moves&lt;/li&gt;
&lt;li&gt;The CIA triad in depth: encryption and hashing&lt;/li&gt;
&lt;li&gt;Common attacks: phishing, malware, and social engineering&lt;/li&gt;
&lt;li&gt;And more — one topic at a time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are learning too, follow along and tell me in the comments: &lt;strong&gt;what made you interested in cybersecurity?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>beginners</category>
      <category>security</category>
      <category>learning</category>
    </item>
    <item>
      <title>AI Post Generator, Now Running on Local Open-Weight Models (Gemma 3 + Ollama)</title>
      <dc:creator>Waleed Shamhan</dc:creator>
      <pubDate>Fri, 16 Oct 2026 18:02:00 +0000</pubDate>
      <link>https://dev.to/waleedshamhan2050sys/ai-post-generator-now-running-on-local-open-weight-models-gemma-3-ollama-a7c</link>
      <guid>https://dev.to/waleedshamhan2050sys/ai-post-generator-now-running-on-local-open-weight-models-gemma-3-ollama-a7c</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week2-2026-10-12"&gt;Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;AI-Post-Generator&lt;/strong&gt; is a Python command-line tool that generates professional Arabic posts for WhatsApp and Telegram channels. I originally built it on a hosted API — and for this challenge I added a new mode that runs it on a &lt;strong&gt;local open-weight model (Gemma 3)&lt;/strong&gt; through &lt;strong&gt;Ollama&lt;/strong&gt;, with no hosted API involved.&lt;/p&gt;

&lt;p&gt;Who would pay for it? Anyone who runs a channel and posts every day: channel owners, small businesses, media coordinators, and community managers. Writing fresh, consistent posts daily is the tedious task they all complain about — this tool turns a topic + a template into a ready post in seconds.&lt;/p&gt;

&lt;p&gt;The problem it solves is threefold: the blank page (what do I post today?), consistency (same voice across every post), and cost/privacy (with the local mode, there is no per-post API bill and the channel's content never leaves the owner's machine).&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Run it with the local open-weight model (default):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull gemma3
python main.py
&lt;span class="c"&gt;# or explicitly:&lt;/span&gt;
python main.py &lt;span class="nt"&gt;--provider&lt;/span&gt; ollama &lt;span class="nt"&gt;--model&lt;/span&gt; gemma3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The original hosted mode still works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python main.py &lt;span class="nt"&gt;--provider&lt;/span&gt; openai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below is a &lt;strong&gt;real post generated by the tool running Gemma 3:1b locally via Ollama&lt;/strong&gt; — topic "daily reading", template "morning motivation". The exact output is also saved in the repo as &lt;code&gt;examples/gemma3_local_sample.txt&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;صباح الخير يا أصدقائي! 📚&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;هل تبحث عن طريقة رائعة لتهدئة ذهنك، وتعزيز تركيزك، وفتح أبواب جديدة للمعرفة؟ القراءة اليومية هي الحل! ☀️&lt;/p&gt;

&lt;p&gt;تذكروا، القراءة ليست مجرد قراءة، بل هي رحلة استكشافية، وتطوير الذات، وراحة البال. 🧘‍♀️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;اكتشفوا قوة القراءة&lt;/strong&gt;! 📖&lt;/p&gt;

&lt;p&gt;شاركوا معنا أفكاركم حول القراءة اليومية. ما هي الكتب التي تحبون قراءتها؟ 🤔&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;دعونا نُشجع بعضكم البعض!&lt;/strong&gt; 🤝&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#صباح_الخير #تحفيز #إيجابية&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/waleedshamhan2050-sys/AI-Post-Generator" rel="noopener noreferrer"&gt;https://github.com/waleedshamhan2050-sys/AI-Post-Generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The open-model mode is a &lt;code&gt;--provider&lt;/code&gt; flag in &lt;code&gt;main.py&lt;/code&gt;: &lt;code&gt;get_client()&lt;/code&gt; points the same OpenAI-compatible client at the local Ollama server (&lt;code&gt;http://localhost:11434/v1&lt;/code&gt;) instead of the hosted API, and the model defaults to &lt;code&gt;gemma3&lt;/code&gt; (configurable via &lt;code&gt;OLLAMA_MODEL&lt;/code&gt; in &lt;code&gt;.env&lt;/code&gt; or &lt;code&gt;--model&lt;/code&gt;). The prompt, the JSON templates, and the saving logic are unchanged — only the provider changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ollama&lt;/strong&gt; for local inference — it exposes an OpenAI-compatible API, so the same client code works for both the hosted and the local path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gemma 3&lt;/strong&gt;, an open-weight model, as the default local model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JSON templates&lt;/strong&gt; for each post type (announcement, quick tip, morning motivation, upcoming event, interactive question) with guiding examples.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;python-dotenv&lt;/strong&gt; for configuration (&lt;code&gt;OLLAMA_MODEL&lt;/code&gt;, &lt;code&gt;OLLAMA_BASE_URL&lt;/code&gt;, and the optional &lt;code&gt;OPENAI_API_KEY&lt;/code&gt; for the hosted mode).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key design decision: one codebase, two providers. The tool does not care where the model lives — the templates and the flow stay the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;This project is the reason I believe in open innovation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; a channel owner posting daily would pay per-post API fees forever. With a local open-weight model, the marginal cost of a post is zero — which is what makes the business actually work for small channels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy:&lt;/strong&gt; channel content, business announcements, and audience ideas never leave the owner's machine. Nothing is sent to a third-party API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No lock-in:&lt;/strong&gt; no vendor can change the pricing, rate limits, or terms under you. If one model stops suiting you, you swap it — &lt;code&gt;llama3.2&lt;/code&gt;, &lt;code&gt;qwen2.5&lt;/code&gt;, &lt;code&gt;mistral&lt;/code&gt; — without rewriting the tool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Works offline:&lt;/strong&gt; the tool runs on a laptop with no connection, which matters for users with unreliable internet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built for a niche:&lt;/strong&gt; the templates are tuned for Arabic WhatsApp/Telegram channel style — a niche a general-purpose hosted API handles poorly out of the box.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open weights made this possible. A closed API could never offer all five at once.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Best Use of Gemma&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
    </item>
    <item>
      <title>Customer Purchase Prediction with Logistic Regression - A Beginner's End-to-End ML Project</title>
      <dc:creator>Waleed Shamhan</dc:creator>
      <pubDate>Fri, 16 Oct 2026 16:38:45 +0000</pubDate>
      <link>https://dev.to/waleedshamhan2050sys/customer-purchase-prediction-with-logistic-regression-a-beginners-end-to-end-ml-project-2d24</link>
      <guid>https://dev.to/waleedshamhan2050sys/customer-purchase-prediction-with-logistic-regression-a-beginners-end-to-end-ml-project-2d24</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3bgdvv87pcjcs9h5j2tw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3bgdvv87pcjcs9h5j2tw.png" alt=" " width="800" height="336"&gt;&lt;/a&gt;When I finished my first machine learning lectures, I wanted a project that used everything I had learned: data loading, preprocessing, train-test split, scaling, training, and evaluation. So I built a small but complete project: predicting whether a customer will purchase a product, based on their age, salary, experience, and gender.&lt;/p&gt;

&lt;p&gt;The dataset is tiny (8 customers), which makes it perfect for learning — you can follow every number by hand.&lt;/p&gt;

&lt;h2&gt;
  
  
  The data
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Age&lt;/th&gt;
&lt;th&gt;Salary&lt;/th&gt;
&lt;th&gt;Experience&lt;/th&gt;
&lt;th&gt;Gender&lt;/th&gt;
&lt;th&gt;Approved&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;25&lt;/td&gt;
&lt;td&gt;600&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;28&lt;/td&gt;
&lt;td&gt;700&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;31&lt;/td&gt;
&lt;td&gt;800&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;34&lt;/td&gt;
&lt;td&gt;900&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;37&lt;/td&gt;
&lt;td&gt;1000&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;1100&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;43&lt;/td&gt;
&lt;td&gt;1200&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Approved is the target: Yes means the customer bought, No means they didn't. The rest are the features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Load the data and encode the categories
&lt;/h2&gt;

&lt;p&gt;Models work with numbers, so the Gender and Approved columns need encoding: Male = 0, Female = 1, No = 0, Yes = 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.model_selection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;train_test_split&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.preprocessing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.linear_model&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LogisticRegression&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn.metrics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;accuracy_score&lt;/span&gt;

&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Age&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;37&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;43&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Salary&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Experience&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Gender&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Male&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Female&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Male&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Female&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Male&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Female&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Male&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Female&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Approved&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;No&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;No&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;No&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Gender&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Gender&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Male&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Female&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Approved&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Approved&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;No&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Yes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Split features and target, then train/test
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Age&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Salary&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Experience&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Gender&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Approved&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;train_test_split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;test_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# Train shape: (6, 4) — Test shape: (2, 4)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;test_size=0.2 means 20% of the data goes to testing. random_state=42 makes the split reproducible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Scale the features
&lt;/h2&gt;

&lt;p&gt;Age ranges up to 43, Salary up to 1200. Without scaling, the bigger numbers dominate the model. StandardScaler fixes that — and the key rule is: fit only on the training data, then transform both sets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;scaler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;X_train&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;X_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# never fit_transform on test data!
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Train and evaluate
&lt;/h2&gt;

&lt;p&gt;Since the target is yes/no, this is a classification problem, and logistic regression is the natural first model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;y_pred&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Actual:   &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_test&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;   &lt;span class="c1"&gt;# [0, 1]
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Predicted:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_pred&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;   &lt;span class="c1"&gt;# [0, 1]
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Accuracy: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;accuracy_score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_pred&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;  &lt;span class="c1"&gt;# 1.0
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model predicted both test customers correctly: accuracy 1.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Predict a new customer
&lt;/h2&gt;

&lt;p&gt;Now the fun part — a brand-new customer: age 36, salary 950, 6 years of experience, female. The new data must go through the same scaler (transform, not fit):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;new_customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;950&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;span class="n"&gt;new_customer_scaled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_customer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_customer_scaled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Approved&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prediction&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Not Approved&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Approved
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: Approved (Yes) — the model predicts this customer will purchase.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Preprocessing is half the project. Encoding categories and scaling features matter as much as the model itself.&lt;/li&gt;
&lt;li&gt;Never fit on test data. Fitting the scaler on test data leaks information and gives fake results.&lt;/li&gt;
&lt;li&gt;Small data teaches the pipeline. With 8 rows I could trace every step; the same pipeline scales to thousands of rows.&lt;/li&gt;
&lt;li&gt;Accuracy on 2 test samples is not proof. A 1.0 here is encouraging, not conclusive — real evaluation needs more data and more metrics (precision, recall, confusion matrix).&lt;/li&gt;
&lt;li&gt;If you are learning ML, build this project yourself and change one thing at a time: try a different random_state, add a feature, or compare logistic regression with a decision tree. That is where the real learning happens.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>datascience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I Built an AI Post Generator for WhatsApp and Telegram - Here's What I Learned</title>
      <dc:creator>Waleed Shamhan</dc:creator>
      <pubDate>Fri, 16 Oct 2026 16:21:37 +0000</pubDate>
      <link>https://dev.to/waleedshamhan2050sys/i-built-an-ai-post-generator-for-whatsapp-and-telegram-heres-what-i-learned-3glg</link>
      <guid>https://dev.to/waleedshamhan2050sys/i-built-an-ai-post-generator-for-whatsapp-and-telegram-heres-what-i-learned-3glg</guid>
      <description>&lt;p&gt;I'm an IT student, and I also work as a media coordinator. That means I live in two worlds: writing code, and writing content. One day I got tired of staring at a blank screen every time I needed a post for a WhatsApp or Telegram channel, so I built a small tool to solve my own problem: &lt;strong&gt;AI-Post-Generator&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's a Python command-line tool that generates professional posts for WhatsApp and Telegram channels using AI. You can find it here: &lt;a href="https://github.com/waleedshamhan2050-sys/AI-Post-Generator" rel="noopener noreferrer"&gt;https://github.com/waleedshamhan2050-sys/AI-Post-Generator&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Running a channel means publishing constantly: announcements, tips, motivational posts, interactive questions. Writing all of that by hand is slow, and the tone drifts from post to post. I wanted something that could produce good drafts fast, in a consistent voice, and in Arabic.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;The flow is deliberately simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You pick a topic and a template from the command line.&lt;/li&gt;
&lt;li&gt;The tool loads a JSON template for that post type (announcement, tip, motivation, interactive question) with guiding examples.&lt;/li&gt;
&lt;li&gt;It sends the prompt to the OpenAI API (using &lt;code&gt;gpt-4.1-mini&lt;/code&gt;) and gets back a generated post.&lt;/li&gt;
&lt;li&gt;The generated post is saved automatically in an &lt;code&gt;examples/&lt;/code&gt; folder, so you can reuse or review it later.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The tech stack is small: &lt;strong&gt;Python 3.x&lt;/strong&gt;, the &lt;strong&gt;OpenAI API&lt;/strong&gt;, &lt;strong&gt;python-dotenv&lt;/strong&gt; for managing the API key safely in a &lt;code&gt;.env&lt;/code&gt; file, and &lt;strong&gt;JSON&lt;/strong&gt; for the templates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design decisions I am proud of
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Templates instead of free-form prompts.&lt;/strong&gt; Every post type has a JSON template with examples. This keeps the output consistent and lets me steer the AI toward a specific kind of post instead of hoping for a good result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arabic-first.&lt;/strong&gt; The tool generates posts in Modern Standard Arabic with appropriate emojis, because that is the audience I write for. Most AI writing tools I tried defaulted to English, so this mattered to me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Keep the secrets out of the code.&lt;/strong&gt; The API key lives in a &lt;code&gt;.env&lt;/code&gt; file, never in the source. It is a small thing, but it is the kind of habit I want to keep for every project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Building this taught me more than the tool itself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python CLI apps:&lt;/strong&gt; structuring a command-line program and keeping the code clean and documented.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Working with AI APIs:&lt;/strong&gt; how to call the OpenAI API, shape prompts through templates, and handle the response.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structured data:&lt;/strong&gt; using JSON to store and manage templates in an organized way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Environment management:&lt;/strong&gt; keeping sensitive data like API keys secure with &lt;code&gt;.env&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt design:&lt;/strong&gt; writing templates that guide the AI toward a specific post type is a skill of its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content automation:&lt;/strong&gt; how the whole loop of creating content for social channels can be automated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is next
&lt;/h2&gt;

&lt;p&gt;I want to add direct publishing to channels, more template types, and support for scheduling posts. The goal is the same as when I started: less time staring at a blank screen, more time on the ideas that matter.&lt;/p&gt;

&lt;p&gt;If you run a channel or create content regularly, I would love to hear how you handle the blank-page problem. And if you try the tool, feedback is welcome.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>openai</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
