Skip to main content

Posts

Showing posts from February, 2025

Decision Tree

 A Decision Tree Algorithm is a supervised machine learning algorithm used for classification and regression tasks.  It works by recursively splitting the dataset into smaller subsets based on feature values, forming a tree-like structure where each node represents a decision rule. Entropy (Information Gain) (used in classification) Mean Squared Error (MSE) (used in regression) Advantages: ✅ Easy to interpret and visualize. ✅ Handles both numerical and categorical data. ✅ Requires little data preprocessing (e.g., no need for feature scaling). Disadvantages: ❌ Prone to overfitting (if not pruned properly). ❌ Sensitive to noisy data. ❌ Can become biased if one class dominates. Common Decision Tree Algorithms: ID3 (Iterative Dichotomiser 3) – Uses entropy/information gain. C4.5 – An improvement over ID3, supports missing values. CART (Classification and Regression Trees) – Uses Gini impurity and MSE. 1️⃣ Compute Entropy(S) for the entire dataset. 2️⃣ Compute Entropy(A) ...

Hexagonal Architecture (Ports & Adapters Pattern)

Hexagonal Architecture , also known as the Ports and Adapters pattern, is a software design pattern that aims to create a decoupled and maintainable application by separating the core business logic from external concerns (like databases, APIs, and UIs). Structure of Hexagonal Architecture A typical Hexagonal Architecture has three main layers: 1️⃣ Core Domain (Application Logic) This contains the business rules and domain models. It is completely independent of external technologies . Example: If you’re building a banking system , this part would include logic for transactions, withdrawals, and deposits . 2️⃣ Ports (Interfaces) These are interfaces that define how the core interacts with external components. Two types of ports: Inbound Ports (driven by external inputs like APIs, UI, or events) Outbound Ports (used to interact with external services like databases, messaging systems, etc.) 3️⃣ Adapters (Implementation of Ports) These are concrete implementations of the ports, re...