<?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 adlanmuammars on Medium]]></title>
        <description><![CDATA[Stories by adlanmuammars on Medium]]></description>
        <link>https://medium.com/@adlanmuammar9?source=rss-454f1abc182d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GBGaGT4XHD0ir-JnbbwNiQ.jpeg</url>
            <title>Stories by adlanmuammars on Medium</title>
            <link>https://medium.com/@adlanmuammar9?source=rss-454f1abc182d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 30 May 2026 02:26:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adlanmuammar9/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[Building a Modern Portfolio Website with React, Vite, and Tailwind CSS]]></title>
            <link>https://medium.com/@adlanmuammar9/building-a-modern-portfolio-website-with-react-vite-and-tailwind-css-3330e148ed26?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3330e148ed26</guid>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Tue, 08 Jul 2025 15:13:21 GMT</pubDate>
            <atom:updated>2025-07-08T15:13:21.752Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0cE2rXz66qQlq5KT.jpg" /></figure><p>In today’s digital age, having a compelling online portfolio is essential for showcasing your skills and experience. This article will walk you through my journey of creating a modern, responsive portfolio website using React, Vite, and Tailwind CSS for my Web Development final project (UAS).</p><h3>Project Overview</h3><p>This portfolio website serves as a comprehensive showcase of my educational background, work experience, skills, and projects. The website features a clean, modern design with smooth animations and responsive layout that works seamlessly across all devices.</p><h4>Key Features:</h4><ul><li>Responsive Design : Optimized for desktop, tablet, and mobile devices</li><li>Interactive UI : Smooth animations and particle effects</li><li>Project Showcase : Detailed presentation of completed projects</li><li>Contact Section : Easy way for visitors to get in touch</li><li>Modern Stack : Built with cutting-edge web technologies</li></ul><h4>Technology Stack</h4><p><strong>React.js</strong></p><p>React was chosen as the frontend framework for its component-based architecture, which allows for:</p><ul><li>Reusable UI components</li><li>Efficient state management</li><li>Fast rendering with virtual DOM</li><li>Strong community support and extensive ecosystem</li></ul><p><strong>Vite</strong></p><p>Vite serves as the build tool and development server, providing:</p><ul><li>Lightning-fast hot module replacement (HMR)</li><li>Optimized build process</li><li>Modern ES modules support</li><li>Excellent developer experience</li></ul><p><strong>Tailwind CSS</strong></p><p>Tailwind CSS was selected for styling because it offers:</p><ul><li>Utility-first approach for rapid development</li><li>Consistent design system</li><li>Easy responsive design implementation</li><li>Small bundle size with purging unused styles</li></ul><h4>Project Structure</h4><pre>src/<br>├── components/<br>│   ├── Particle.js          # Particle animation effects<br>│   ├── Project.jsx          # Individual project component<br>│   └── sections/<br>│       ├── Contact.jsx      # Contact form and information<br>│       ├── EducationAndExperience.jsx<br>│       ├── Footer.jsx       # Website footer<br>│       ├── Hero.jsx         # Landing section<br>│       ├── Projects.jsx     # Projects showcase<br>│       └── Skills.jsx       # Skills presentation<br>├── data/<br>│   └── user_info.js         # Centralized data management<br>├── pages/<br>│   ├── 404.jsx             # Error page<br>│   └── Homepage.jsx        # Main page layout<br>└── App.jsx                 # Main application component</pre><h4>Key Components Breakdown</h4><ol><li><strong>Hero Section</strong></li><li><strong>Education &amp; Experience</strong></li><li><strong>Projects Showcase</strong></li><li><strong>Contact Section</strong></li></ol><h3>Conclusion</h3><p>Building this portfolio website was an excellent learning experience that reinforced the importance of modern web development practices. The combination of React, Vite, and Tailwind CSS proved to be a powerful stack for creating fast, maintainable, and visually appealing web applications.</p><p>The project successfully demonstrates proficiency in:</p><ul><li>Modern JavaScript frameworks</li><li>Responsive web design</li><li>User interface development</li><li>Project organization and deployment</li><li>Version control and collaboration tools</li></ul><p>This portfolio serves not only as a showcase of my work but also as a testament to the skills acquired during my Web Development studies. The clean, professional design and smooth user experience reflect the attention to detail and technical competence that employers and clients value.</p><h4>Getting Started</h4><pre>1. Clone the repository:<br>```bash<br>git clone https://github.com/adlanmuammarshiddiq/adlan-portofolio.git<br>```<br><br>2. Install dependencies:<br>```bash<br>npm install<br>```<br><br>3. Start the development server:<br>```bash<br>npm run dev<br>```<br><br>4. Open your browser and navigate to `http://localhost:5173`</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3330e148ed26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evolusi Pengelolaan Kode Sumber untuk Developer Modern]]></title>
            <link>https://medium.com/@adlanmuammar9/evolusi-pengelolaan-kode-sumber-untuk-developer-modern-9eb5cc155c6f?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9eb5cc155c6f</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[gitflow]]></category>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Tue, 06 May 2025 15:19:59 GMT</pubDate>
            <atom:updated>2025-05-06T15:19:59.614Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*89W44eEbMD9dfJfe.jpeg" /></figure><h3>1. CVS: Awal Mula Sistem Version Control</h3><p>CVS (Concurrent Versions System) adalah salah satu sistem kontrol versi pertama yang digunakan secara luas, terutama pada tahun 1990-an. CVS bekerja dengan model <em>centralized version control system</em> (CVCS), artinya ada satu server pusat tempat seluruh versi kode disimpan, dan semua developer harus terhubung ke server tersebut untuk melakukan commit atau update.</p><p><strong>Kelebihan CVS pada zamannya:</strong></p><ul><li>Memungkinkan kolaborasi banyak developer secara bersamaan.</li><li>Mendukung pencatatan perubahan (<em>change history</em>) untuk setiap file.</li><li>Memiliki konsep tag dan branch dasar.</li></ul><p>Namun, CVS memiliki banyak keterbatasan:</p><ul><li>Tidak mendukung perubahan <em>atomic commit</em>, sehingga satu commit bisa saja meninggalkan kode dalam kondisi setengah jalan.</li><li>Branching dan merging sangat tidak efisien.</li><li>Bergantung pada koneksi ke server pusat, sehingga menyulitkan developer yang bekerja secara offline.</li></ul><p>Dengan keterbatasan ini, banyak komunitas open-source mulai beralih ke sistem yang lebih canggih.</p><h3>2. Git: Sistem Kontrol Versi Modern</h3><p>Git diperkenalkan oleh Linus Torvalds (pencipta Linux) pada tahun 2005. Berbeda dengan CVS, Git menggunakan model <strong>Distributed Version Control System (DVCS)</strong>. Ini berarti setiap developer memiliki salinan lengkap dari repositori, termasuk seluruh histori perubahan.</p><p><strong>Keunggulan utama Git dibanding CVS dan sistem lama lainnya:</strong></p><ul><li><strong>Distribusi penuh</strong>: Developer bisa bekerja secara offline dan melakukan commit lokal, baru melakukan <em>push</em> ke repositori pusat saat online.</li><li><strong>Kecepatan tinggi</strong>: Operasi seperti commit, diff, merge, dan branch jauh lebih cepat karena dilakukan secara lokal.</li><li><strong>Branching fleksibel dan ringan</strong>: Membuat dan berpindah branch sangat mudah dan cepat di Git.</li><li><strong>Integrity check</strong>: Git menggunakan SHA-1 checksum untuk memastikan integritas data.</li><li><strong>Open-source dan lintas platform</strong>: Didukung oleh hampir semua layanan pengembangan perangkat lunak saat ini (GitHub, GitLab, Bitbucket, dsb).</li></ul><h3>3. Gitflow: Alur Kerja Git yang Terstruktur</h3><p>Untuk mengatasi tantangan pengelolaan kode dalam tim yang besar dan kompleks, muncullah konsep <strong>Gitflow</strong>, sebuah alur kerja (workflow) yang diusulkan oleh Vincent Driessen.</p><p>Gitflow memperkenalkan struktur cabang yang rapi dan jelas:</p><ul><li>main: branch utama yang selalu berisi kode stabil dan siap produksi.</li><li>develop: tempat utama pengembangan fitur; semua fitur baru bercabang dari sini.</li><li>feature/*: setiap fitur baru dikembangkan di cabang terpisah dari develop.</li><li>release/*: digunakan untuk mempersiapkan rilis; di-merge ke main dan develop setelah selesai.</li><li>hotfix/*: untuk perbaikan darurat terhadap rilis yang sudah di-<em>deploy</em>.</li></ul><p><strong>Manfaat Gitflow:</strong></p><ul><li>Alur kerja terstruktur dan mudah diikuti dalam tim.</li><li>Mencegah campur aduk antara fitur yang sedang dikembangkan dan kode produksi.</li><li>Memudahkan rollback jika terjadi kesalahan.</li></ul><p>Memahami sistem kontrol versi dan alur kerja seperti Git dan Gitflow adalah keterampilan fundamental bagi setiap developer modern. Di era kolaborasi global, <em>remote working</em>, dan open-source, kemampuan mengelola versi kode dengan benar tidak hanya membuat pekerjaan lebih rapi, tapi juga meningkatkan produktivitas dan kualitas perangkat lunak.</p><p>Bagi mahasiswa, startup, atau tim pengembangan profesional, menggunakan Git dengan alur kerja yang sesuai (misalnya Gitflow) adalah pondasi penting menuju pengembangan perangkat lunak yang berkelanjutan, aman, dan terorganisir.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9eb5cc155c6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering React Hooks: Revolutionizing State Management in Functional Components]]></title>
            <link>https://medium.com/@adlanmuammar9/mastering-react-hooks-revolutionizing-state-management-in-functional-components-cb3087a9a4f8?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb3087a9a4f8</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 18:39:32 GMT</pubDate>
            <atom:updated>2025-04-12T18:39:32.137Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VcEu8bIzpaXopvNk.jpeg" /></figure><p>In the dynamic world of React development, staying updated with the latest advancements is crucial. One such groundbreaking evolution is the introduction of React Hooks. Whether you’re a seasoned developer or just starting with React, understanding Hooks can significantly enhance your ability to write cleaner, more maintainable code.</p><h4>What are React Hooks?</h4><p>React Hooks are functions that allow you to use state and other React features in functional components without writing a class. Introduced in React 16.8, Hooks offer a more direct API to React’s features, previously only available in class components. They aim to simplify component logic and promote reuse of stateful logic across components.</p><h4>Key Hooks Explained</h4><p><strong>useState</strong></p><p>useState is the most commonly used Hook and replaces this.state in class components. It lets you add state to functional components:</p><pre>import React, { useState } from &#39;react&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useState(0);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>useEffect performs side effects in functional components, such as data fetching, subscriptions, or manually changing the DOM:</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function Example() {<br>  const [count, setCount] = useState(0);<br><br>  useEffect(() =&gt; {<br>    document.title = `You clicked ${count} times`;<br>  }, [count]); // Only re-run the effect if count changes<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h4>Additional Hooks</h4><p><strong>useContext</strong></p><p>useContext allows functional components to consume context that has been established by a Provider higher up in the component tree.</p><pre>import React, { useContext } from &#39;react&#39;;<br>import ThemeContext from &#39;./ThemeContext&#39;;<br><br>function ThemedButton() {<br>  const theme = useContext(ThemeContext);<br><br>  return &lt;button style={{ background: theme.background, color: theme.foreground }}&gt;I am styled by theme context!&lt;/button&gt;;<br>}</pre><p><strong>useRef</strong></p><p>useRef gives you a way to keep mutable values around similar to instance properties on class instances.</p><pre>import React, { useRef } from &#39;react&#39;;<br><br>function TextInputWithFocusButton() {<br>  const inputEl = useRef(null);<br>  const onButtonClick = () =&gt; {<br>    // `current` points to the mounted text input element<br>    inputEl.current.focus();<br>  };<br><br>  return (<br>    &lt;&gt;<br>      &lt;input ref={inputEl} type=&quot;text&quot; /&gt;<br>      &lt;button onClick={onButtonClick}&gt;Focus the input&lt;/button&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><h4>Custom Hooks</h4><p>Custom Hooks are a way to reuse stateful logic across different components. They are more of a convention than a feature, so there’s no functional difference between a custom Hook and a built-in Hook.</p><pre>import { useState, useEffect } from &#39;react&#39;;<br><br>function useDocumentTitle(title) {<br>  useEffect(() =&gt; {<br>    document.title = title;<br>  }, [title]);<br>}<br><br>function Example() {<br>  const [count, setCount] = useState(0);<br><br>  useDocumentTitle(`You clicked ${count} times`);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Click me&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h4>Benefits of React Hooks</h4><ul><li><strong>Simplicity</strong>: Hooks reduce the complexity of managing state and side effects compared to class components.</li><li><strong>Code Reuse</strong>: Encapsulate logic in custom Hooks for easy reuse across components.</li><li><strong>Performance Optimizations</strong>: Hooks optimize performance by allowing React to skip unnecessary re-renders.</li></ul><p>React Hooks have transformed React development, offering a modern and efficient way to manage state and side effects in functional components. By embracing Hooks, developers can write cleaner, more maintainable code and enhance productivity. Start integrating Hooks into your projects today and experience the benefits firsthand!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb3087a9a4f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Menghidupkan Website dengan JavaScript Animation]]></title>
            <link>https://medium.com/@adlanmuammar9/menghidupkan-website-dengan-javascript-animation-bff22b114402?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bff22b114402</guid>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 19:55:24 GMT</pubDate>
            <atom:updated>2025-04-06T19:55:24.476Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*wyObATqIuVC4a7uo.jpg" /></figure><p>Website yang statis bisa saja fungsional, tapi sering kali terasa hambar. Di era digital saat ini, <strong>animasi adalah kunci untuk menciptakan pengalaman pengguna yang menyenangkan</strong>. JavaScript memungkinkan kita menambahkan animasi yang dinamis, interaktif, dan responsif tanpa harus bergantung penuh pada CSS atau library berat.</p><h4><strong>Kenapa Harus Menggunakan Animasi di Website?</strong></h4><ul><li>Menarik perhatian user</li><li>Meningkatkan UX (user experience)</li><li>Menjelaskan alur proses (contoh: animasi loading, progress, atau transisi halaman)</li><li>Memperkuat identitas visual brand</li></ul><h4><strong>Jenis-Jenis Animasi di Website</strong></h4><ul><li>Scroll animation</li><li>Hover animation</li><li>Click / tap animation</li><li>Page transition animation</li><li>Micro-interaction</li></ul><h4>Mengenal JavaScript untuk Animasi</h4><p>JavaScript bisa digunakan untuk membuat animasi dengan beberapa cara:</p><ul><li><strong>Native JavaScript</strong>: requestAnimationFrame(), setInterval()</li><li><strong>CSS Manipulation</strong> via JavaScript</li><li><strong>Library</strong> seperti:</li></ul><ol><li>GSAP (GreenSock)</li><li>Anime.js</li><li>Three.js (untuk animasi 3D)</li><li>ScrollReveal, Locomotive Scroll</li><li>Framer Motion (React)</li></ol><pre>let box = document.getElementById(&quot;box&quot;);<br>let position = 0;<br><br>function moveBox() {<br>  position += 1;<br>  box.style.left = position + &quot;px&quot;;<br>  <br>  if (position &lt; 300) {<br>    requestAnimationFrame(moveBox);<br>  }<br>}<br><br>moveBox();</pre><h4>Library Paling Populer: GSAP &amp; Anime.js</h4><ul><li>Powerfull</li><li>Cross-browser</li><li>Animasi kompleks dan chaining mudah</li></ul><pre>gsap.to(&quot;.box&quot;, { duration: 2, x: 300, rotation: 360 });</pre><pre>anime({<br>  targets: &#39;.letter&#39;,<br>  translateY: [-100, 0],<br>  delay: anime.stagger(100),<br>  easing: &#39;easeOutExpo&#39;<br>});</pre><h4>Scroll Animation: Buat Website Terlihat Premium</h4><p>Scroll animation membuat elemen muncul saat halaman di-scroll, menciptakan pengalaman yang sinematik.</p><pre>ScrollReveal().reveal(&#39;.card&#39;, { <br>  distance: &#39;50px&#39;,<br>  duration: 1000,<br>  origin: &#39;bottom&#39;,<br>  interval: 200<br>});</pre><h4>Kesimpulan</h4><p>Animasi bukan cuma “hiasan”, tapi bagian penting dari storytelling di web modern. Dengan JavaScript, kamu punya fleksibilitas besar untuk menghidupkan situs kamu. Gunakan animasi dengan bijak agar pengalaman pengguna tetap optimal dan menyenangkan.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bff22b114402" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Membuat Layout Website Responsif dengan CSS Flexbox dan Media Query]]></title>
            <link>https://medium.com/@adlanmuammar9/membuat-layout-website-responsif-dengan-css-flexbox-dan-media-query-77f32a7ea88d?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/77f32a7ea88d</guid>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Wed, 26 Mar 2025 06:48:17 GMT</pubDate>
            <atom:updated>2025-03-26T06:48:17.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*9DdCmeOCRT7Da6Ym.png" /></figure><p>Seorang web developer atau desainer harus membuat layout yang responsif — yakni tampilan yang dapat menyesuaikan diri secara otomatis dengan ukuran layar pengguna — karena pengguna internet saat ini mengakses website dari tablet dan smartphone dengan berbagai ukuran layar.</p><p>Dalam artikel ini, kita akan membahas cara menggunakan HTML5 dan CSS3 untuk membuat layout website responsif, khususnya dengan memanfaatkan Flexbox dan Media Query. Kami akan membuat layout sederhana yang terdiri dari:</p><ul><li>Header</li><li>Navigasi (Nav)</li><li>Main Konten</li><li>Sidebar</li><li>Footer</li></ul><p>Tata letak ini akan tampak sejajar secara horizontal pada layar besar dan akan terakumulasi secara vertikal pada layar kecil. Dengan memanfaatkan CSS standar, kita dapat mencapai hasil ini tanpa perlu menjadi tergantung pada framework seperti Bootstrap atau TailwindCSS.</p><p>Berikut adalah struktur HTML dasar yang kita gunakan untuk membuat tampilan website sederhana yang responsif :</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;id&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;/&gt;<br>  &lt;title&gt;Layout Responsif&lt;/title&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot; /&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;header class=&quot;header&quot;&gt;Header&lt;/header&gt;<br>  &lt;nav class=&quot;nav&quot;&gt;Navigation&lt;/nav&gt;<br>  &lt;main class=&quot;main&quot;&gt;Main Content&lt;/main&gt;<br>  &lt;aside class=&quot;sidebar&quot;&gt;Sidebar&lt;/aside&gt;<br>  &lt;footer class=&quot;footer&quot;&gt;Footer&lt;/footer&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><pre>/* style.css */<br>* {<br>  box-sizing: border-box;<br>  margin: 0;<br>  padding: 0;<br>}<br><br>body {<br>  display: flex;<br>  flex-wrap: wrap;<br>  font-family: sans-serif;<br>  min-height: 100vh;<br>}<br><br>.header, .footer {<br>  width: 100%;<br>  background-color: #3f51b5;<br>  color: white;<br>  padding: 20px;<br>  text-align: center;<br>}<br><br>.nav {<br>  flex: 1 1 200px;<br>  background-color: #f5f5f5;<br>  padding: 20px;<br>}<br><br>.main {<br>  flex: 2 1 400px;<br>  background-color: #e3f2fd;<br>  padding: 20px;<br>}<br><br>.sidebar {<br>  flex: 1 1 200px;<br>  background-color: #bbdefb;<br>  padding: 20px;<br>}<br><br>.footer {<br>  margin-top: auto;<br>}</pre><p>Penjelasan :</p><ul><li>display: flex membuat seluruh &lt;body&gt; menjadi wadah fleksibel.</li><li>flex-wrap: wrap memungkinkan elemen turun ke baris baru jika tidak muat dalam satu baris.</li><li>Properti flex digunakan untuk mengatur lebar relatif antar elemen.</li><li>width: 100% untuk header dan footer agar tetap memenuhi layar.</li><li>Warna dan padding ditambahkan agar layout lebih jelas secara visual.</li></ul><p><strong>Responsif dengan Media Query :</strong></p><pre>@media (max-width: 768px) {<br>  body {<br>    flex-direction: column;<br>  }<br><br>  .nav, .main, .sidebar {<br>    width: 100%;<br>  }<br>}</pre><h3>Kesimpulan</h3><p>Dengan menggabungkan Flexbox dan Media Query, kita bisa menciptakan desain website yang adaptif dan nyaman digunakan tanpa perlu mengandalkan framework yang besar. Mengetahui konsep ini secara mendalam akan sangat membantu saat memasuki dunia pengembangan frontend yang lebih rumit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77f32a7ea88d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript untuk Machine Learning: Mungkinkah?]]></title>
            <link>https://medium.com/@adlanmuammar9/javascript-untuk-machine-learning-mungkinkah-0faa219422f1?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/0faa219422f1</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Sat, 08 Mar 2025 07:58:50 GMT</pubDate>
            <atom:updated>2025-03-08T07:58:50.896Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>JavaScript untuk Machine Learning: Mungkinkah? Mengenal Library Populer di </strong>JavaScript untuk Machine Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*uMjhgUCZGmIpDJu1.png" /></figure><p>Selama ini JavaScript di terkenal sebagai bahasa dominan dalam pemrograman web. Namun, seiring dengan kemajuan teknologi, penggunaan JavaScript mulai merambah ke wilayah baru seperti Machine Learning (ML). Dulu, bahasa pemrograman Python dan R lebih banyak digunakan dalam pengolahan dan pemodelan machine learning. Akan tetapi, sekarang ini para web developer dapat dengan mudah mendankan model AI kedalam aplikasi berbasis browser dengan dihadirkannya berbagai perpustakaan ML berbasis javaScript tanpa perlu mengubah bahasa pemrograman.</p><h3>Mengapa JavaScript untuk Machine Learning?</h3><p>Sebelum melakukan langkah-langkah lebih dalam pada proses implementasi, ada baiknya kita melihat untuk apa JavaScript bisa dipilih menjadi kandidat yang menggiurkan untuk machine learning:</p><ol><li><strong>Bisa Dieksekusi Melalui Browser</strong></li></ol><p>Dengan JavaScript, sebuah model machine learning dapat berjalan secara langsung di dalam browser tanpa memerlukan backend server khusus.</p><p><strong>2. Menjangkau Jangkauan Web</strong></p><p>Dengan Anda yang merupakan seorang developer web menggunakan React, Angular, atau Vue.js, model ML dapat digabungkan tanpa harus beralih ke bahasa lainnya.</p><p><strong>3. Memiliki Support Library Terkini</strong></p><p>Berbagai model machine learning berbasis JavaScript pada umumnya sudah dan dapat digunakan untuk berbagai tugas oleh Google, Facebook, dan komunitas open-source.</p><h3>Library Machine Learning Populer di JavaScript</h3><h4>1. TensorFlow.js</h4><p>TensorFlow.js adalah versi JavaScript dari <strong>TensorFlow</strong>, framework ML paling populer yang dikembangkan oleh Google. Library ini memungkinkan kita untuk <strong>melatih dan menjalankan model ML langsung di browser</strong> atau Node.js.</p><pre>import * as tf from &#39;@tensorflow/tfjs&#39;;<br><br>const model = tf.sequential();<br>model.add(tf.layers.dense({ units: 10, inputShape: [2], activation: &#39;relu&#39; }));<br>model.add(tf.layers.dense({ units: 1, activation: &#39;sigmoid&#39; }));<br><br>model.compile({ optimizer: &#39;sgd&#39;, loss: &#39;meanSquaredError&#39; });</pre><h4>2. Brain.js</h4><p>Jika Anda ingin implementasi machine learning yang lebih <strong>sederhana</strong>, <strong>Brain.js</strong> bisa menjadi pilihan yang lebih ringan dibanding TensorFlow.js. Library ini sangat cocok untuk <strong>model sederhana seperti prediksi angka, klasifikasi teks, dan pengenalan pola</strong>.</p><pre>const brain = require(&#39;brain.js&#39;);<br>const net = new brain.NeuralNetwork();<br><br>net.train([<br>  { input: [0, 0], output: [0] },<br>  { input: [0, 1], output: [1] },<br>  { input: [1, 0], output: [1] },<br>  { input: [1, 1], output: [0] }<br>]);<br><br>console.log(net.run([1, 0])); // Output: sekitar 1</pre><h4>3. ml5.js</h4><p>Apabila Anda ingin lebih mudah menerapkan Machine Learning di JavaScript, Anda dapat menggunakan ml5.js. Library ini dibangun di atas TensorFlow.js tetapi memiliki level abstraksi yang lebih tinggi.</p><p>Contoh implementasi (<em>Image Classification</em> dengan ml5.js):</p><pre>const classifier = ml5.imageClassifier(&#39;MobileNet&#39;, modelReady);<br><br>function modelReady() {<br>  classifier.classify(document.getElementById(&#39;myImage&#39;), (err, results) =&gt; {<br>    console.log(results);<br>  });<br>}</pre><h4>Implementasi Machine Learning di Browser dengan TensorFlow.js</h4><pre>import * as tf from &#39;@tensorflow/tfjs&#39;;<br><br>async function loadModel() {<br>  const model = await tf.loadLayersModel(&#39;https://path-to-your-model/model.json&#39;);<br>  return model;<br>}<br><br>const model = loadModel();<br><br>async function predict(imageData) {<br>  const tensor = tf.browser.fromPixels(imageData).resizeNearestNeighbor([28, 28]).toFloat().expandDims();<br>  const prediction = model.predict(tensor);<br>  console.log(&quot;Prediksi: &quot;, prediction.argMax(1).dataSync());<br>}</pre><p>Kode ini akan mengambil gambar yang diberikan, mengubahnya menjadi <strong>tensor</strong>, dan memprediksi angka yang ada dalam gambar menggunakan model yang dilatih sebelumnya.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0faa219422f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HR Analytics using Machine Learning]]></title>
            <link>https://medium.com/@adlanmuammar9/hr-analytics-using-machine-learning-85dae7cd2ff3?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/85dae7cd2ff3</guid>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 16:55:54 GMT</pubDate>
            <atom:updated>2023-11-25T16:55:54.072Z</atom:updated>
            <content:encoded><![CDATA[<p>Analyze and predict HR data set using machine learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R-9Jmf-YrY5sJV0e.jpg" /></figure><p>In the realm of business management, personnel managers and HR personnel grapple with many challenges. One of the most pressing issues among them is <strong>attrition</strong>, which is a very important issue. For organizations committed to fostering a stable and engaged workforce, it is imperative to understand attrition rates and the underlying drivers of employee turnover.</p><p>Therefore, the main objective of this study was to use HR Analytics techniques to detect and investigate individual-related trends that are closely associated with <strong>attrition</strong>. Through careful examination of the data, we sought to uncover the complex elements associated with attrition rates. These elements cover a wide range of aspects, including <strong><em>employee demographics, performance metrics, job satisfaction levels, and potential indicators of voluntary exit.</em></strong></p><p>This comprehensive analysis is aimed at providing invaluable insights to organizations. These insights empower them to proactively address attrition challenges and implement targeted strategies to reduce employee turnover. By leveraging HR Analytics to uncover trends in the field of human resource management regarding attrition rates and related factors, organizations can strive to achieve better employee retention, increased productivity, and continued success in the business arena.</p><p>To solve a problem statement above we will do several stages are :</p><ol><li>Load Dataset</li><li>Data Cleaning</li><li>EDA &amp; Data Visualization</li><li>Machine Learning Model</li></ol><p>We will start the discussion by starting from Load dataset and data understanding with the aim of understanding more about the data sets we have.</p><h3>Load Dataset</h3><pre>data=pd.read_csv(&quot;https://raw.githubusercontent.com/triangle836/DB61_Python_final_term_project/main/HR-Employee-Attrition.csv&quot;)<br>print(f&quot;Shape of the dataset: {data.shape}&quot;)</pre><p><em>Shape of the dataset: (1470, 35)</em></p><p><strong>Dataset Description</strong></p><p>About the Data</p><p>This dataset was discovered on Kaggle and is openly accessible. There are 35 variables and 1,470 employee records. On the internet, projects involving HR analytics are fairly common with this data collection. The purpose of this data collection is to develop a model to forecast employees who are likely to quit based on the information about these 1,470 employees and the following characteristics:</p><ul><li>Age : Age in years of the employee</li><li>Attrition: People who people leave</li><li>BusinessTravel : How often an employee embark on a job related travel</li><li>DailyRate : Daily rate at which an employee is paid</li><li>Department : Department where the employee works</li><li>DistanceFromHome : Distance an employee travels from home to work</li><li>Education : Level of education of the employee</li><li>EducationField : What field the employee studied in school</li><li>EmployeeCount : Count of employee</li><li>EmployeeNumber : EMployee number</li><li>EnvironmentSatisfaction : Employee environment satisfaction</li><li>Gender : Gender of the employee</li><li>HourlyRate : Hourly rate of pay of the employee</li><li>JobInvolvement : Employee job involvement ratings</li><li>JobLevel : Employee Job level</li><li>JobRole : Employee Job role</li><li>JobSatisfaction : Employee Job Staisfaction</li><li>MaritalStatus : Employee Marital Status</li><li>MonthlyIncome : Employee monthly income</li><li>MonthlyRate : Employee Monthly rate</li><li>NumCompaniesWorked : Number of companies the person have worked in the past</li><li>Over18 : Age over 18 years or not</li><li>OverTime : Work overtime</li><li>PercentSalaryHike : Salary increment in Percentages</li><li>PerformanceRating : Performance rating</li><li>RelationshipSatisfaction : Relationship satisfaction</li><li>StandardHours : Employee standard hours worked</li><li>StockOptionLevel Stock options level</li><li>TotalWorkingYears Total working hours</li><li>TrainingTimesLastYear : Total working years</li><li>WorkLifeBalance : Work life balance rating</li><li>YearsAtCompany : Years at the company</li><li>YearsInCurrentRole : Years in current role</li><li>YearsSinceLastPromotion : Years since last promotion</li><li>YearsWithCurrManager : Years with current manager</li></ul><p>After we do the data understanding or data load stage, we will do the data cleaning stage itself in order to provide accurate statistical analysis results as well as for machine learning modeling.</p><h3>Data Cleaning</h3><p>There are several stages of data cleaning that we do :</p><p><strong>Basic Data Discovery</strong></p><p><strong>Check missing values and Dropping unnecessary columns</strong></p><p>Data is cleaned and have no missing value.<br>Since the number of columns are overwhelming, it is plausible to retain the most crucial valuesets in relation to our analytical purposes.</p><ul><li>“employee_count”, “over18” and “standard_hours” columns consist of 1 value only for all entries, so they can be omitted.</li><li>“employee_number” is employee ID, which is unique for each entry, so it can also be omitted as it provides no characteristic of the employee</li><li>“performance_rating” consists of merely 2 values (3 and 4), suggesting its appreciable value in this analytical process.</li></ul><pre># Drop some column<br>data.drop([&#39;employee_count&#39;,&#39;employee_number&#39;,&#39;standard_hours&#39;,&#39;over18&#39;,&#39;performance_rating&#39;],<br>            axis=1,inplace=True<br>            )</pre><p><strong>Removing Outliers</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjQnsDo_x5cBSSRvsWV1mQ.png" /></figure><p>There are outliers in some columns, but either the number of outliers is small (\&lt;5\%) or the outliers values are in realistic, reasonable range. Except for <strong>monthly_income</strong> column.</p><pre># Removing Outliers<br>drop_outlier_col = [&#39;monthly_income&#39;]<br><br>for col in drop_outlier_col:<br>    Q1 = data[col].quantile(0.25)<br>    Q3 = data[col].quantile(0.75)<br>    IQR = Q3 - Q1<br>    lower_bound = Q1 - 1.5 * IQR<br>    upper_bound = Q3 + 1.5 * IQR<br><br>    new_df = data[(data[col]&gt;=lower_bound)&amp;(data[col]&lt;=upper_bound)]</pre><pre>new_df = new_df.reset_index(drop=True)<br>print(f&quot;Shape of the dataset after cleanning: {new_df.shape}&quot;)</pre><p>Shape of the dataset after cleanning: (1356, 30)</p><h3>EDA &amp; Data Visualization</h3><p>After we do the data cleaning stage, we will do Explorarity Data Analysis and Data Visualization to better understand and analyze the problems of the datasets we have.</p><p><strong>Heatmap Correlations</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxXv7_dfAkiLanxuR0w2uA.png" /></figure><pre>cols = [&#39;total_working_years&#39;,&#39;years_at_company&#39;,&#39;years_in_current_role&#39;,&#39;years_since_last_promotion&#39;,&#39;attrition&#39;,&#39;job_level&#39;]<br>sns.pairplot(new_df[cols], hue=&#39;attrition&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SmwK3bheZkEqGYuVvbUPog.png" /></figure><p><strong>Feature Analysis</strong></p><ul><li>Gender Distribution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpre2og6-5CynYwe7al2Yw.png" /></figure><ul><li>Age Ditribution</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ipBYdkA9tSrv8VU9QYUf5A.png" /></figure><ul><li>attrition vs density</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*YLay_lgh3S_61cLTVsnTIQ.png" /></figure><ul><li>It can be seen that 60% of the research population is male, against 40% females.</li><li>Both groups have the same distribution in age, ranging from 18–60.The rate of attrition between male and female employees stays roughly the same at 15%.This prove the data is not bias.</li></ul><p><strong>Correlation Carrier Background</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HoF2f9l_cUx0FtnL84UXQw.png" /></figure><p>As the graph and correlation heatmap suggest, the employee’s total working years closely correlated to the number of years working at the current company and position. There is little to no difference between male and female counterparts.</p><p><strong>Monthly Income Correlation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueLwtBpwaa1OoUUvisl6hA.png" /></figure><ul><li>It can be inferred that there is a linear correlation between monthly income to total working years and years worked at the company, but only from 0–20 years.</li><li>Income jumps up at the mark of 20 working years or more and fluctuate volatilely from then on.</li><li>However, the data prove that the more one works in 1 role, the more they would earn monthly.</li></ul><p><strong>Attrition Univariate Analysis — Correlation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGlEIWeH0CjsucMkvzmnZQ.png" /></figure><p>It is noticeable that the age range of 25 to 35 stands out with the most remarkable attrition rate, indicating a higher tendency of voluntary exits among all brackets. Conversely, from around 40 onwards, a downtrend was recorded, suggesting a reduced likelihood for departures. Similarly, a declining trend manifests itself starkly from the age of 25 downwards, which can most likely attributed to the probation period or introductory time span for the company.</p><p><strong>ATTRITION — MARITAL STATUS</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*muO7sgt1xUD4yTc1wqpNQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jBXd5CAUw-HbzTBeBtYcg.png" /></figure><p>The employee marital status is split between Married, Single and Divorced. There is no clear trend that marital status affect attrition.</p><p><strong>ATTATTRITION — WORKPLACE ELEMENTS</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EqrgK3rhe_zNDM-dKAoF_w.png" /></figure><p>The attrition rate is consistant between departments, staying around the 80–85\% level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZwbzHi1bzeq1VRq0M6ypA.png" /></figure><p>The attrition rate is specifically lower for the following positions: Research and Manufacturing Directors, Managers, HR and Healthcare representatives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9UxRvo2-Ust10C48POrbDA.png" /></figure><p>From the chart, there is no evidence of job satisfaction affect attrition, which is surprising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_49xC9lf_wdC1QUjExKP0w.png" /></figure><p>It can be seen that the attrition rate is higher for employees who are paid lower, from $2000 to $4000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OYQV9Vn3DhQnppMc0PcMwQ.png" /></figure><p>The majority of employees stay within 10km of their workplace. However, there is no evidence supporting that attrition rate is higher for people living far from work. This can be seen from the following graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0F7542uxPP2c2kJ0ZA56Ag.png" /></figure><p>From the chart, there is no difference in attrition rate between most of the levels of Enviroment satisfaction, apart from that of the lowest level, whose proportion almost doubles that of others</p><h3>Machine Learning Model</h3><p>After we do EDA and Data Visualization, we will continue to the last stage, namely the Machine Learning Modeling stage.</p><p><strong>Feature Engineering</strong></p><ul><li>Encode Non-Numeric Variables</li></ul><pre># Encoding<br>le = LabelEncoder()<br><br>for i in df1.columns:<br>    if df1[i].dtype == &#39;object&#39;:<br>        df1[i] = le.fit_transform(df1[i])</pre><ul><li>Standardize Numeric Variables</li></ul><pre># Scaling<br>scaler = StandardScaler()<br>scaler.fit(df1.drop(&#39;attrition&#39;,axis=1))</pre><ul><li>Create train and test splits</li></ul><pre>X = df1_feat<br>y = df1[&#39;attrition&#39;]<br><br>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)</pre><p><strong>Model 1 : Random Forest</strong></p><ul><li>Model Building &amp; Feature Importance Analysis</li></ul><pre>model = RandomForestClassifier(max_features=&#39;sqrt&#39;, n_estimators=100)<br>model.fit(X_train, y_train)<br>y_pred = model.predict(X_test)<br>y_pred_proba = model.predict_proba(X_test)[:,1]<br>print(f&quot;Accuracy Score: {accuracy_score(y_test, y_pred)}&quot;)<br>print(f&quot;ROC AUC Score: {roc_auc_score(y_test, y_pred_proba)}&quot;)<br><br>feature_importance = pd.DataFrame({&#39;Feature&#39;: X.columns, &#39;Importance&#39;: model.feature_importances_})<br>feature_importance.sort_values(by=&#39;Importance&#39;, ascending=False, inplace=True)<br>feature_importance.reset_index(drop=True, inplace=True)<br>feature_importance<br><br>plt.figure(figsize=(10, 5))<br>fig = px.line(x=feature_importance[&#39;Feature&#39;], y=feature_importance[&#39;Importance&#39;], markers=&quot;o&quot;,title=&quot;Feature Importance&quot;,template=&quot;plotly_dark&quot;,color_discrete_sequence=[&#39;pink&#39;])<br>fig.update_layout(<br>    xaxis_title=&quot;Feature&quot;,<br>    yaxis_title=&quot;Importance&quot;,<br>    font={&quot;family&quot;:&quot;Arial&quot;, &quot;size&quot;:12})<br><br>fig.update_xaxes(tickangle=60)<br><br>fig.show()</pre><p>Accuracy Score: 0.8427518427518428 <br>ROC AUC Score: 0.7882712944332663</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Fl1_sd6ikGg4-lgEwa3PA.png" /></figure><p>Overall, a great number of features have direct yet insignificant influence on the risk of voluntary departure. Most noticeable correlation coefficients range any where below 0.1, with monthly_income taking the lead.</p><ul><li><strong>Model Evaluation</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IDNN-bF48Jbsy09PIEOz2Q.png" /></figure><p>Having a closer look at the ROC AUC index, we can notice the pronounced pattern of trade-off between TPR and FPR at different thresholds of testing, all of which accrue up to a whopping 0.8 in aggregate area.</p><p><strong>Model 2 : Logistic Regression</strong></p><ul><li>Encoding Non-Numeric Features</li></ul><pre># Encoding<br>def dummies(df):<br> list=[]<br> for col in df.select_dtypes(exclude=np.number).columns:<br>  dummy = pd.get_dummies(df[col],prefix=col,drop_first=True)<br>  list.append(dummy)<br><br> df=df.drop([i for i in df.select_dtypes(exclude=np.number).columns],axis=1)<br><br> for dummy_df in list:<br>  df=pd.concat([df,dummy_df],axis=1)<br> return df</pre><ul><li>Standardizing Numeric Variables</li></ul><pre># Scaler <br>scaler = StandardScaler()<br><br># Fitting<br>scaler.fit(df2.drop(&#39;attrition_Yes&#39;,axis=1))<br><br>scaled_features_df2 = scaler.transform(df2.drop(&#39;attrition_Yes&#39;,axis=1))</pre><ul><li>Train Test Split</li></ul><pre>X_train, X_test, y_train, y_test = train_test_split(df2_feat,df2[&#39;attrition_Yes&#39;], test_size=0.3,random_state=101)</pre><ul><li>Training And Predicting</li></ul><pre>logmodel = LogisticRegression()<br>logmodel.fit(X_train,y_train)</pre><ul><li>Analysing Feature Importance</li></ul><pre>feature_importance = logmodel.coef_[0]<br><br>feature_names = X_train.columns<br><br>importance_df = pd.DataFrame({&#39;Feature&#39;: feature_names, &#39;Coefficient&#39;: feature_importance})<br><br>importance_df = importance_df.reindex(importance_df[&#39;Coefficient&#39;].abs().sort_values(ascending=False).index).reset_index(drop=True)<br><br>import plotly.express as px<br><br>fig = px.bar(<br>    importance_df,<br>    x=&#39;Coefficient&#39;,<br>    y=&#39;Feature&#39;,<br>    orientation=&#39;h&#39;,<br>    title=&#39;Feature Coefficients in Logistic Regression&#39;,<br>    #template=&#39;plotly_dark&#39;<br>)<br><br>fig.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dacw2dyU2qBsSAfVSlNR7w.png" /></figure><ul><li>Model Evaluation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2FVHACo21gr0k1Me7iVAA.png" /></figure><h3><strong>Conclusion and Recommendations</strong></h3><p><strong>Conclusion</strong></p><p><strong>Recommendations</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85dae7cd2ff3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classification Gender Through Facial Features: A Decision Tree Approach]]></title>
            <link>https://medium.com/@adlanmuammar9/classification-gender-through-facial-features-a-decision-tree-approach-d3c759970df7?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3c759970df7</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[decision-tree]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 15:28:48 GMT</pubDate>
            <atom:updated>2023-11-24T15:30:29.795Z</atom:updated>
            <content:encoded><![CDATA[<p>Gender Classification through Facial Features</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3_7eUsPufkjob5j4.jpg" /></figure><p>Living in the dynamic era of digital advancements, the integration of machine learning technology presents an exciting avenue for uncovering concealed insights within datasets. Among the intriguing applications is the capacity to forecast an individual’s gender by analyzing distinctive facial features. This discourse aims to delve into the profound realms of gender classification using machine learning, specifically focusing on the utilization of Decision Trees.</p><p>Through the application of machine learning techniques, we can construct classification models proficient in predicting gender (Male/Female) based on the intricate features discernible on an individual’s face.</p><h3>What is a decision tree and how does it work??</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*ZoSgkJi6VB4aCEiv.jpg" /></figure><p>A decision tree is a predictive model in machine learning that is used to perform classification and regression. The model is similar to a tree structure, where each node in the tree represents a decision or test on a particular feature, and each branch of the node represents the outcome of the decision or test. Basically, Decision Tree helps in decision making in a hierarchical manner.</p><p><strong>Structure of a Decision Tree:</strong></p><ul><li><strong>Root</strong>: A representation of the entire dataset or a particular subset to be broken down.</li><li><strong>Decision Node</strong>: Represents testing on a particular attribute/feature. Based on the results of this test, the data is split to the appropriate child nodes.</li><li><strong>Leaf Node</strong>: Represents the predicted result or the given class after performing a series of decisions.</li></ul><p><strong>Basic Formula for Choosing the Best Feature on a Testing Node:</strong></p><p>The Decision Tree algorithm uses methods to select the best features to split at each test node. One commonly used method is “Gini Impurity” for classification. The Gini Impurity formula for a node is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/309/0*F0a_1SCCwpmpg1g2.png" /></figure><ul><li>c is the number of classes/targets</li><li>pi is the proportion of samples from class</li><li>i at that node.</li></ul><p>Some steps that can be taken to use this dataset for machine learning with a decision tree approach are:</p><ol><li>Data Understanding</li><li>Explorarity Data Analysis (EDA)</li><li>Data Analysis</li><li>Modeling</li></ol><p>To better understand gender classification with machine learning, we will do the modeling stage starting with the data understanding.</p><h3><strong>Data Understanding</strong></h3><p>Before we go any further we need to understand the data we have to get an initial understanding of the data needed to solve the given problem.</p><p>This dataset contains 7 features and a label column.</p><ul><li><strong>long_hair : </strong>This column contains 0’s and 1’s where 1 is “long hair” and 0 is “not long hair”.</li><li><strong>forehead_width_cm : </strong>This column is in CM’s. This is the width of the forehead.</li><li><strong>forehead_height_cm : </strong>This is the height of the forehead and it’s in Cm’s.</li><li><strong>nose_wide : </strong>This column contains 0’s and 1’s where 1 is “wide nose” and 0 is “not wide nose”.</li><li><strong>nose_long : </strong>This column contains 0’s and 1’s where 1 is “Long nose” and 0 is “not long nose”.</li><li><strong>lips_thin : </strong>This column contains 0’s and 1’s where 1 represents the “thin lips” while 0 is “Not thin lips”.</li><li><strong>distance_nose_to_lip_long</strong> : This column contains 0’s and 1’s where 1 represents the “long distance between nose and lips” while 0 is “short distance between nose and lips”.</li><li><strong>gender</strong> : This is either “Male” or “Female”.</li></ul><p>We will display the first 5 rows the data set</p><pre>#Load Dataset<br>df = pd.read_csv(&#39;gender_classification_v7.csv&#39;)<br>df.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKtc-DHemAEKIZ-kEp8_YA.png" /></figure><pre># Checking Unique Value<br>listItem = []<br>for col in df.columns :<br>    listItem.append( [col, df[col].nunique(), df[col].unique()])<br><br>unique_values = pd.DataFrame(columns=[&#39;Column Name&#39;, &#39;Number of Unique&#39;, &#39;Unique Sample&#39;], data=listItem)<br>unique_values</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*Jxyj24lJQOmWiOqGgcpRyQ.png" /></figure><pre># concise summary of dataframe<br>df.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*9vRGOpIv9L-V682U4d0XMw.png" /></figure><ul><li>Our data set has 6 categorical columns: <em>long_hair,nose_wide,nose_long,lips_thin,distance_nose_to_lip_long,<br>gender.</em></li><li>And it has 2 numerical columns: <em>forehead_width_cm, forehead_height_cm.</em></li><li>For categorical columns other than gender, they only have unique values, namely 1 and 0.</li></ul><h3><strong>Explorarity Data Analysis (EDA)</strong></h3><pre># proportion of male and female in our target column<br>df[&#39;gender&#39;].plot(kind=&#39;hist&#39;, title=&#39;proportion of Male and Female&#39;)<br>df[&#39;gender&#39;].value_counts()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*HQ-oQ7dGw0V6Jneebt27LQ.png" /></figure><p>Our data set has a balanced proportion therefore we do not need to use a resampler.</p><p><strong>Correlation</strong></p><pre># heatmap correlation<br>plt.figure(figsize=(15,10))<br>sns.heatmap(df.corr(&#39;spearman&#39;,numeric_only=True), annot=True,linewidths=0.5, cmap=&quot;Reds&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MYiWVI-lDHQGomY3MYLing.png" /></figure><pre># Getting Mean Columns with gender<br><br>m_col=[&#39;long_hair&#39;,&#39;forehead_width_cm&#39;,&#39;forehead_height_cm&#39;,&#39;nose_wide&#39;,<br>       &#39;nose_long&#39;,&#39;lips_thin&#39;,&#39;distance_nose_to_lip_long&#39;,&#39;gender&#39;]</pre><pre># Pairplot for mean columns<br>sns.pairplot(df[m_col],hue=&#39;gender&#39;,palette=&#39;Blues&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-jdvoRWuvh2qmFGMwS-0Q.png" /></figure><h3><strong>Data Cleaning</strong></h3><pre># Checking Duplicate and Missing Value<br>display(df.duplicated().sum())<br>display(df.isna().sum())</pre><pre>1768<br><br>long_hair                    0<br>forehead_width_cm            0<br>forehead_height_cm           0<br>nose_wide                    0<br>nose_long                    0<br>lips_thin                    0<br>distance_nose_to_lip_long    0<br>gender                       0<br>dtype: int64</pre><pre># Drop Duplicate Value<br>df = df.drop_duplicated()</pre><h3><strong>Data Analysis</strong></h3><p><strong>Numerical vs Target</strong></p><pre>plt.figure(figsize=(8, 6))<br>plotnumber = 1<br>for feature in numerical_features:<br>    ax = plt.subplot(2, 2, plotnumber)<br>    sns.barplot(x = &#39;gender&#39;, y = feature, data = df, estimator=np.median, errorbar=(&#39;ci&#39;, 0),palette=&#39;rocket&#39;)<br>    plt.ylabel(feature)<br>    ax.bar_label(ax.containers[0], padding= -20, size=8)  <br>    plotnumber += 1<br>    plt.tight_layout()<br><br><br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*7qjQz5b7mYXOEez85FLsTg.png" /></figure><p>From the barplot diagram above we get the information that :</p><ul><li>On average, the forehead width of a woman is larger than that of a man.</li><li>The average forehead height of a man tends to be smaller than that of a woman.</li></ul><p><strong>Categorical vs Target</strong></p><pre>categorical_features = df[[&#39;long_hair&#39;,&#39;nose_wide&#39;,&#39;nose_long&#39;,&#39;lips_thin&#39;,&#39;distance_nose_to_lip_long&#39;]]</pre><pre>plotnumber = 1<br>fig, axes = plt.subplots(2, 3, figsize=(16, 9))<br><br>sns.set_palette(&quot;rocket&quot;)<br><br>for feature, ax in zip(categorical_features[:-1], axes.flatten()):<br>    pd.crosstab(df[feature], df[&#39;gender&#39;], normalize=&#39;index&#39;).plot(kind=&#39;bar&#39;, stacked=True, ax=ax)<br>    ax.set_title(f&#39;{feature}&#39;, size=12)<br>    ax.set_xticklabels(ax.get_xticklabels(), rotation=0)<br>    ax.legend(loc=&#39;upper right&#39;, prop={&#39;size&#39;: 12}, title=&#39;gender&#39;)<br><br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8yl43JabsoSoi5a6wQmvQ.png" /></figure><p>From the results of the above analysis :</p><ul><li>The average hair length of women and men has the same value.</li><li>Men tend to have a larger nose width.</li><li>The average male has a longer nose length</li><li>Women tend to have thicker lips than men.</li><li>Men have a longer distance between lips and nose than women.</li></ul><h3><strong>Modeling</strong></h3><pre># Define Features and Target<br># Features<br>X = df.drop(columns=&#39;gender&#39;)<br><br># Target<br>y = df[&#39;gender&#39;]</pre><pre># Data Splitting<br>X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.2, random_state = 0,stratify=y)</pre><pre># Decission tree Params<br>clf_ent = DecisionTreeClassifier(criterion = &quot;gini&quot;,random_state = 100,max_depth=3, min_samples_leaf=5,min_samples_split=5)</pre><pre># Fitting to train set<br>clf_ent.fit(X_train,y_train)<br><br># Predict to Test Set<br>y_pred = clf_ent.predict(X_test)</pre><pre>accuracy_score(y_test, y_pred)*100</pre><p>95.05409582689336</p><p><strong>Plot Tree</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ieqei95BHd2_7jmFaIpsQ.png" /></figure><p>From the plot tree above, it can be concluded that :</p><ul><li>If a person has lips_thin ≤ 0.5 then it will enter the Male class group for the first level.</li><li>If a person has nose_long ≤ 0.5, it will be classified as female for the first level.</li><li>A person who has forehead_height_cm ≤ 6.55 will be classified as male.</li></ul><h3><strong>Model Limitation</strong></h3><ol><li>This model is only valid when the features/columns of <strong>long_hair,nose_wide,nose_long,lips_thin,distance_nose_to_lip_long</strong> are only 1 and 0.</li><li>The valid range for the <strong>forehead_width_cm</strong> column is in the range of 11.4–15.5.</li><li>And this model is said to be valid when the <strong>forehead_height_cm</strong> feature is in the range of 5.1–7.1</li></ol><h3><strong>Conclusion and Recommendations</strong></h3><p><strong>Conclusion</strong></p><p>From the resulting decision tree plot, we can extract important insights into how the model decides on gender classes. The decision starts by considering key features such as lips_thin, nose_long, and forehead_height_cm. Hierarchically, the model effectively sorts the dataset and produces accurate classification decisions.From our data set we were able to get a very good accuracy score of 95% with the decision tree approach.</p><p><strong>Recommendations</strong></p><ul><li>Can add other features such as height or weight</li><li>For features that have column values of 1 and 0, it can be converted into cm units so that the results are not biased because long or short, or thick or thin are relative because basically humans have various races of tribes that have different physical characteristics.</li><li>We can also try to do hyperparameter tuning to make better accuracy results.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3c759970df7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[POWER BI for Data Visualization]]></title>
            <link>https://medium.com/@adlanmuammar9/power-bi-for-data-visualization-8b17cbd75048?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b17cbd75048</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Fri, 03 Nov 2023 11:53:06 GMT</pubDate>
            <atom:updated>2023-11-03T11:53:06.416Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Microsoft Power BI for Data Visualization</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hcx6wLhmSIbDqHQf" /></figure><p>In the digital age, data has become one of the most valuable assets for individuals and companies. Data can be used for a variety of purposes, whether for making business decisions or solving a problem. However, in order to make the most of data, <em>data visualization</em> is needed.</p><p>Data visualization is the process of transforming data into a visual format that is easy to understand. This can be done using a variety of charts, <em>graphs</em>, <em>maps</em>, and <em>dashboards</em>. Effective data visualization can help us to see trends, patterns, and relationships in data.</p><p><strong>Power BI</strong> is one of the most popular data visualization platforms available today. <strong>Power BI</strong> offers a variety of features that make it easy for us to create interactive, engaging, and informative data visualizations.</p><p>In this article, we will talk about the following topics:</p><ul><li><strong>Advantages and disadvantages of Microsoft Power BI</strong></li><li><strong>Exploring POWER BI Architecture</strong></li><li><strong>Features in POWER BI</strong></li></ul><h3>Why Microsoft PowerBI ?? 😕</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*069gy4CCHiy8n_J3.png" /></figure><p><strong>Advantages of Microsoft Power BI</strong></p><p>Let’s discuss some of the most important advantages of Power BI that play a significant role in making Power BI a successful tool 👌:</p><ol><li><strong>Access to Volumes of Data from Multiple Sources</strong></li></ol><p>Power BI can access vast volumes of data from multiple sources. It allows you to view, analyze, and visualize vast quantities of data that cannot be opened in Excel. Some of the important data sources available for Power BI are Excel, CSV, XML, JSON, pdf, etc.</p><p>2. <strong>User-friendly interface.</strong></p><p>Power BI offers various specialized visualizations, which are visualizations created by developers for specific use. Specialized visuals are available on the Microsoft marketplace. Apart from the collection of common visualizations available, you can use Power BI custom visualizations in your reports and dashboards. The range of specialized visualizations includes KPIs, maps, charts, graphs,etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*qETzl6qhRPkW0fau.png" /><figcaption>Dashboard by <a href="https://medium.com/u/9a9112b64bea">Bespoke Post</a></figcaption></figure><p><strong>3. Excel Integration</strong></p><p>In Power BI, you also have the option to upload and display your data in Excel. You can select/filter/slice data in a Power BI report or dashboard and place it in Excel. You can then open Excel and view the same data in table form on an Excel worksheet. In other words, the Excel integration capability in Power BI helps users view and work with the raw data behind Power BI visualizations.</p><p><strong>4. Shared Datasets</strong></p><p>Power BI partners and other trusted organizations can publish their cleaned, transformed, and verified datasets after ingesting and shaping them with Power BI. This acts as a trusted source of data with which other designers can get started away easily for their content. If the source data is updated, it updates the dashboards and apps of the designers connected to and using those datasets</p><p><strong>Disadvantages of Microsoft Power BI</strong></p><p>Next, Let’s discuss some of the disadvantages of Power BI :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/0*_2LkR7T88jpgMU7d" /></figure><ol><li><strong>Handling Large Data Volumes</strong></li></ol><p>Power BI indeed has a data ingestion limitation of approximately 2 GB of data at a time. If you aim to import and work with larger volumes of data, upgrading from the free version to a paid Power BI version is necessary. Additionally, users have reported that Power BI might take longer than usual or even pause when processing millions of rows and columns of data.</p><p>2. <strong>Visual Configuration</strong></p><p>In most cases, you might not feel the need to configure and optimize visualizations in Power BI. However, even if you do, Power BI doesn’t provide many options for configuring visualizations according to your needs. Therefore, users have limited choices about what they can modify in visuals.</p><p>3. <strong>Data Quality</strong></p><p>Microsoft Power BI does not provide any data cleansing solutions. This means it assumes that the data you retrieve has been cleaned beforehand and is of high quality. So, if you require data cleansing capabilities, you might need to look for an alternative solution to clean your data.</p><p>After learning about the strengths and weaknesses of Microsoft Power BI, before delving deeper into Microsoft Power BI, we need to understand the workflow of how the tool operates. Therefore, we will continue the discussion in the next point, Power BI Architecture :</p><h3>POWER BI Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*C7aBPJRsrBFCygIc.png" /></figure><ol><li><strong>Data ingestion</strong></li></ol><p>Data ingestion is the process of collecting data from various sources and loading it into Power BI. Data can come from various types of sources, such as Excel files, JSON, XML, and databases (<em>SQL, Azure, Google BigQuery, etc</em>). Power BI provides a wide range of connectors to facilitate the data ingestion process.</p><p><strong>2. Data Preparation</strong></p><p>Data preparation is the process of cleaning, transforming, and modeling data so that it is ready for analysis. This process is crucial to ensure that the data maintains a high level of accuracy, making the final analysis results reliable and suitable for making informed business decisions.</p><p>Power BI offers a variety of tools to aid in the data preparation process, such as Power Query and DAX. Power Query is a tool used to extract, transform, and load data from various sources. DAX is a programming language used to create formulas and functions for manipulating data.</p><p><strong>3. Data Warehouse</strong></p><p>Data Warehouse is a centralized storage space for integrated data from various sources. The data warehouse streamlines the data analysis process as data from diverse sources has been structured and standardized. Power BI can connect to various data warehouses such as <em>Azure SQL Database, Amazon Redshift, and Google BigQuery</em>.</p><p><strong>4. Data Visualization and Analysist</strong></p><p>Data visualization is the process of presenting data in the form of charts, graphs, and maps to make it more comprehensible. Power BI provides a variety of tools to create compelling and interactive data visualizations. Data analysis is the process of extracting information from data to uncover patterns and trends. Power BI offers various tools for data analysis, such as filters, slicers, and drill-down functionalities.</p><p>Additionally, here are examples of some visualizations available in Power BI :</p><ul><li>Charts are the most commonly used visualizations. They can display numerical or categorical data</li><li>Graphs are visualizations used to represent numerical data in graphical form.</li><li>Maps are visualizations used to display geographic data.</li><li>Tables are visualizations used to display data in tabular form.</li><li>PivotTables are visualizations used for data analysis in pivot table format.</li></ul><p>Power BI also provides various specialized visualizations for specific data types, such as:</p><ul><li>Area chart to display data that changes over time.</li><li>Bar and column charts to compare data from two or more groups.</li><li>Combo chart to combine two or more visualization types.</li><li>Donut chart to display proportions of a whole.</li><li>Funnel chart to track data flow through a process.</li><li>Gauge chart to display a single numerical data.</li><li>KPI (Key Performance Indicator) to display key performance indicators.</li></ul><p><strong>5. Data Publish</strong></p><p>Once the data has been visualized and analyzed, it can be published to Power BI Service, allowing access and sharing with others. Power BI Service also offers various features to manage and secure data, such as role-based access control and auditing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*e_lqgLFF5_KfdxsO.png" /><figcaption>Artwork by <a href="https://medium.com/u/83d2124e9c8c">Richa Goel</a></figcaption></figure><p>Data from various sources is ingested into Power BI Desktop, where the data can be prepared and modeled. Once the data is ready, it can be published to Power BI Service for access and sharing with others. Users can utilize Power BI Desktop or Power BI Service to create data visualizations and perform data analysis.</p><h3><strong>Features in Microsoft Power BI</strong></h3><p>After understanding the Microsoft Power BI workflow, we will continue to discuss the next topic, namely various features that are often used in Microsoft Power BI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-z0Qwh5hlkCbMQJN.png" /></figure><p><strong>Extract Insights from large datasets [varies by version]</strong></p><p>Excel worksheets come with a standard limit of 1,048,576 rows. Although performance in Excel will slow down well before that row limit, it is a common requirement for users to analyze datasets larger than one million rows. Power BI compresses your data so you can extract insights from large data sets. With a well-built data model, Power BI can help you analyze data sets containing more than 100 million rows.</p><p>Power BI also offers useful features for working with very large data sets of more than several hundred million rows. For example, users can set up aggregation tables in Power BI. Aggregation leverages pre-computed data to speed up queries, reducing the time it takes to render your reports.</p><p><strong>Create custom visualizations with R and Python (available in all versions)</strong></p><p>While Power BI supports many standard data visualizations out of the box, it’s also possible to build your own with custom data visualizations. By adding open-source data-viz libraries from <em>R </em>and <em>Python</em>, analysts can create highly customizable visualizations to add to their next Power BI report.</p><p><strong>Analyze your datasets in Excel (Pro or Premium only)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*XqYVvR8vI3JC7WLwDhKvoQ.jpeg" /></figure><p>The challenge for BI analysts has been how to offer this flexibility in a way that maintains the integrity of the connected reporting environment.</p><p>With that in mind, Microsoft released Analyze in Excel. Excel can connect directly to your underlying Power BI data, so users can do their own tabular and ad-hoc reporting. If you’re comfortable creating PivotTables in Excel, you can use this familiar experience to slice and dice your data, referencing the same datasets used in other Power BI reports.</p><p>Finally, users can get the latest data from Power BI datasets by refreshing their Excel connections. This ease of access is a game-changer for organizations stuck between the two platforms.</p><p><strong>Automatic data refreshes (Pro or Premium only)</strong></p><p>Power BI’s scheduled refresh feature automates the process of refreshing your datasets, freeing you from tedious, manual report updates. By quickly and accurately refreshing your data, insights can be easily surfaced and shared amongst your team.</p><p><strong>Power BI Mobile App (available in all versions)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*nM0CBBmlfDC-bW6F" /></figure><p>Power BI offers a feature-rich set of apps for iOS, Android, and Windows 10 mobile devices. Users can view mobile-optimized reports, share insights with colleagues, and set alerts within the mobile apps.</p><h3>Conclusion</h3><p>From our previous discussions, it can be concluded that Microsoft Power BI is a Business Intelligence tool that excels in analyzing and visualizing data. In this regard, Microsoft Power BI stands as a highly valuable tool for a Data Analyst in effectively visualizing and analyzing data.</p><p>There are several strengths in Microsoft Power BI, such as its capability to access volumes of data from multiple sources, a user-friendly interface, and more. However, users should also consider its drawbacks, including limitations in handling large volumes of data, some features accessible only through paid versions, and others.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b17cbd75048" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing the Right Collection Data Type for CRUD Operations in Python Programming]]></title>
            <link>https://medium.com/@adlanmuammar9/choosing-the-right-collection-data-type-for-crud-operations-in-python-programming-121f433bfb25?source=rss-454f1abc182d------2</link>
            <guid isPermaLink="false">https://medium.com/p/121f433bfb25</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[collection-data-types]]></category>
            <dc:creator><![CDATA[adlanmuammars]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 07:15:56 GMT</pubDate>
            <atom:updated>2023-09-21T07:15:56.969Z</atom:updated>
            <content:encoded><![CDATA[<p>Collection Data Types For CRUD Operations</p><figure><img alt="Artwork by @charleshoskinson" src="https://cdn-images-1.medium.com/max/563/1*QtnzaV_7OA-c-sr1w2K_Bg.jpeg" /><figcaption>Artwork by <a href="https://medium.com/u/d6f1beac3391">adatainment</a></figcaption></figure><p>CRUD stands for Create, Read, Update, and Delete processes, which are utilized to manage data within a data processing system or application. To ensure effective data management within the application we create, it is crucial to select the appropriate collection data type. Choosing the right collection data type can significantly enhance application performance, efficiency, and security.</p><p>The collection data type itself is a data type used to store a group of data. In Python, there are four primary types of collection data types:</p><ol><li><strong>List []</strong></li><li><strong>Tuple ()</strong></li><li><strong>Set {}</strong></li><li><strong>Dictionary {key: value}</strong></li></ol><p>Each collection data type possesses distinct characteristics and applications. In this article, I will explore the four types of collection data types present in Python programming, providing a comparative analysis and describing the advantages and disadvantages of each type for CRUD applications.</p><p>The Python programming language offers a variety of collection data types designed for storing and managing collections of data. Collection Data Types are typically utilized for storing both small and large amounts of data, allowing us to perform operations on this data.</p><h3><strong>Types of Collection Data Types in Python</strong></h3><p>Here are some types of <em>collection data types</em><strong> </strong>available in Python:</p><ol><li><em>List</em> is a collection data type that can store heterogeneous data, meaning data with different data types. Lists are denoted by square brackets <strong>[]</strong>.</li></ol><pre># List Syntax in Phyton<br>my_list = [1, &quot;Alice&quot;, 25]</pre><p>2<em>. Tuple</em> is a collection data type similar to a list, but its data cannot be changed. Tuples are denoted by parentheses <strong>()</strong>.</p><pre># Tuple Syntax in Phyton<br>my_tuple = (1, &quot;Alice&quot;, 25)</pre><p>3.<em> Set</em> is a collection data type that only stores unique data. Sets are denoted by curly braces <strong>{}</strong>.</p><pre># Set Syntax in Phyton<br>my_set = {1, &quot;Alice&quot;, 25}</pre><p>4.<em> Dict (Dictionary)</em> is a collection data type that stores data in the form of key-value pairs. Dictionaries are also denoted by curly braces <strong>{}</strong>.</p><pre># Dictionary Syntax in Phyton<br>my_dict = {<br>    &quot;id&quot;: 1,<br>    &quot;name&quot;: &quot;Alice&quot;,<br>    &quot;age&quot;: 25,<br>}</pre><h3><strong>Characteristics and Usage of Collection Data Types</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*bpKoywIG_fLUv8kxDrVLxw.jpeg" /></figure><p><strong>List[]</strong></p><p><strong>Characteristics </strong>: <br>- Heterogeneous data,<br>- Data can be changed<br><strong>Usage</strong>:<br>- Storing a list of data,<br>- Perform operations on data, such as searching, sorting, and merging</p><p><strong>Tuple()</strong></p><p><strong>Characteristics: </strong><br>- Heterogeneous data <br>- Immutable data<br><strong>Use Cases:</strong><br>- Storing a collection of data that will not change<br>-Use Performing operations on data, such as searching and sorting</p><p><strong>Set{}</strong></p><p><strong>Characteristics: </strong><br>- Unique data <br>- Immutable data<br><strong>Use Cases: </strong><br>- Storing a unique collection of data <br>- Performing operations on data, such as searching and sorting</p><p><strong>Dictionary{key : values}</strong></p><p><strong>Characteristics: </strong><br>- Data in the form of key-value pairs <br>- Mutable data<br><strong>Use Cases: </strong><br>- Storing a collection of data with key-value pairs <br>- Performing operations on data, such as searching, sorting, and merging</p><h3><strong>Comparison of Invocation Speed Among the 4 Collection Data Types</strong></h3><p>Here is a comparison of invocation speed among the 4 collection data types using the ‘import time’ module:</p><pre>import time<br><br>def create_list(data):<br>    start = time.time()<br>    my_list = [i for i in data]<br>    end = time.time()<br>    return end - start<br><br>def create_tuple(data):<br>    start = time.time()<br>    my_tuple = tuple(data)<br>    end = time.time()<br>    return end - start<br><br>def create_set(data):<br>    start = time.time()<br>    my_set = set(data)<br>    end = time.time()<br>    return end - start<br><br>def create_dict(data):<br>    start = time.time()<br>    my_dict = {i: i for i in data}<br>    end = time.time()<br>    return end - start<br><br>data = list(range(100000))<br><br>print(&quot;Membuat list:&quot;, create_list(data))<br>print(&quot;Membuat tuple:&quot;, create_tuple(data))<br>print(&quot;Membuat set:&quot;, create_set(data))<br>print(&quot;Membuat dict:&quot;, create_dict(data))</pre><p>Output :</p><pre>Membuat list: 0.009367942810058594<br>Membuat tuple: 0.0005419254302978516<br>Membuat set: 0.0<br>Membuat dict: 0.01611042022705078</pre><p>From the above output, it can be seen that a <em>set</em> is the fastest collection data type to create, followed by a <em>tuple, list,</em> and <em>dictionary</em>.</p><h3>The Differences in Applying Collection Data Types for CRUD Applications in Python</h3><ol><li><em>List</em> is a good choice for storing mutable data, such as a list of products in a store or a list of customer orders. Lists can be accessed randomly, making it easy to add, remove, or update data.</li><li><em>Tuple</em> is a good choice for storing immutable data, such as configuration data or historical data. Tuples cannot be changed, ensuring data consistency.</li><li><em>Set </em>is a good choice for storing unique data, like a list of usernames or product categories. Sets cannot have duplicates, making them suitable for quickly filtering data.</li><li><em>Dictionary</em> is a good choice for storing related data, such as customer data or product data. Dictionaries use keys to access data, making them suitable for fast data retrieval.</li></ol><p>Here is a simple CRUD program using the 4 collection data types:</p><p><strong>List for CRUD</strong></p><pre># Create Using List<br>products = []<br>products.append({&quot;id&quot;: 1, &quot;name&quot;: &quot;Product 1&quot;, &quot;price&quot;: 100})<br>products.append({&quot;id&quot;: 2, &quot;name&quot;: &quot;Product 2&quot;, &quot;price&quot;: 200})<br>products.append({&quot;id&quot;: 3, &quot;name&quot;: &quot;Product 3&quot;, &quot;price&quot;: 300})<br><br># Read Using List<br>for product in products:<br>    print(product)<br><br># Delete Using List<br>products.remove({&quot;id&quot;: 2})<br><br># Update Using<br>products[0][&quot;price&quot;] = 150<br><br># Print Updated Products<br>for product in products:<br>    print(product)</pre><p>Output :</p><pre>{&#39;id&#39;: 1, &#39;name&#39;: &#39;Product 1&#39;, &#39;price&#39;: 100}<br>{&#39;id&#39;: 3, &#39;name&#39;: &#39;Product 3&#39;, &#39;price&#39;: 300}<br>{&#39;id&#39;: 1, &#39;name&#39;: &#39;Product 1&#39;, &#39;price&#39;: 150}</pre><p><strong>Tuple for CRUD</strong></p><pre># Create Using Tuple<br>configuration = (&quot;production&quot;, &quot;database&quot;, &quot;localhost&quot;)<br><br># Read Using Tuple<br>print(configuration)<br><br># Update Using Tuple<br>configuration = (&quot;development&quot;, &quot;database&quot;, &quot;127.0.0.1&quot;)<br><br># Print updated configuration<br>print(configuration)</pre><p>Output :</p><pre>(&#39;production&#39;, &#39;database&#39;, &#39;localhost&#39;)<br>(&#39;development&#39;, &#39;database&#39;, &#39;127.0.0.1&#39;)</pre><p><strong>Set for CRUD</strong></p><pre># Create Using Set<br>users = {&quot;johndoe&quot;, &quot;janedoe&quot;, &quot;marysmith&quot;}<br><br># Read Using Set<br>print(users)<br><br># Add<br>users.add(&quot;peterjones&quot;)<br><br># Remove<br>users.remove(&quot;johndoe&quot;)<br><br># Print updated users<br>print(users)</pre><p>Output :</p><pre>{&#39;johndoe&#39;, &#39;janedoe&#39;, &#39;marysmith&#39;}<br>{&#39;janedoe&#39;, &#39;marysmith&#39;, &#39;peterjones&#39;}</pre><p><strong>Dictionary for CRUD</strong></p><pre># Create Using Dictionary<br>customers = {<br>    &quot;johndoe&quot;: {&quot;id&quot;: 1, &quot;name&quot;: &quot;John Doe&quot;, &quot;email&quot;: &quot;johndoe@example.com&quot;},<br>    &quot;janedoe&quot;: {&quot;id&quot;: 2, &quot;name&quot;: &quot;Jane Doe&quot;, &quot;email&quot;: &quot;janedoe@example.com&quot;},<br>    &quot;marysmith&quot;: {&quot;id&quot;: 3, &quot;name&quot;: &quot;Mary Smith&quot;, &quot;email&quot;: &quot;marysmith@example.com&quot;},<br>}<br><br># Read Using Dictionary<br>customer = customers[&quot;johndoe&quot;]<br>print(customer)<br><br># Add<br>customers[&quot;peterjones&quot;] = {&quot;id&quot;: 4, &quot;name&quot;: &quot;Peter Jones&quot;, &quot;email&quot;: &quot;peterjones@example.com&quot;}<br><br># Update Using Dictionary<br>customers[&quot;johndoe&quot;][&quot;email&quot;] = &quot;johndoe@newdomain.com&quot;<br><br># Print updated customers<br>print(customers)</pre><p>Output :</p><pre>{&#39;id&#39;: 1, &#39;name&#39;: &#39;John Doe&#39;, &#39;email&#39;: &#39;johndoe@example.com&#39;}<br>{&#39;id&#39;: 1, &#39;name&#39;: &#39;John Doe&#39;, &#39;email&#39;: &#39;johndoe@newdomain.com&#39;,<br> &#39;id&#39;: 2, &#39;name&#39;: &#39;Jane Doe&#39;, &#39;email&#39;: &#39;janedoe@example.com&#39;,<br> &#39;id&#39;: 3, &#39;name&#39;: &#39;Mary Smith&#39;, &#39;email&#39;: &#39;marysmith@example.com&#39;,<br> &#39;id&#39;: 4, &#39;name&#39;: &#39;Peter Jones&#39;, &#39;email&#39;: &#39;peterjones@example.com&#39;}</pre><h3>Conclusion</h3><p>Collection data types in Python are vital for managing data efficiently. For CRUD tasks, sets are the quickest to create, while list and tuple are easy to use. Reading data is versatile across list, tuple, set, and dictionary. List and dictionary are ideal for updates, and data deletion can be done using list, tuple, or set. In terms of creation speed, sets rank highest, followed by dictionary, list, and tuple. Understanding these data types and CRUD operations facilitates efficient Python programming, with import time helping choose the right data type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*cYcLkw6ZE9SU8g5C3Lis6w.png" /></figure><p><strong>Explanation:</strong></p><p>• <em>Effectiveness</em> refers to the ability of collection data types to meet the needs of an application. <br>• <em>Speed</em> refers to the time it takes to perform CRUD operations on collection data types. <br>• <em>Application</em> in CRUD refers to the collection data types’ capability to be used for various CRUD features.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=121f433bfb25" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>