<?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 Njoki Mwihaki on Medium]]></title>
        <description><![CDATA[Stories by Njoki Mwihaki on Medium]]></description>
        <link>https://medium.com/@njokim?source=rss-70f9b04daa07------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JB8TlUOYGS58A5hyJOh5AQ.jpeg</url>
            <title>Stories by Njoki Mwihaki on Medium</title>
            <link>https://medium.com/@njokim?source=rss-70f9b04daa07------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 23:47:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@njokim/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[SQL for Geospatial Data:Mastering the Basics:]]></title>
            <link>https://medium.com/@njokim/sql-for-geospatial-data-mastering-the-basics-7ee79d80b6f5?source=rss-70f9b04daa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ee79d80b6f5</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Njoki Mwihaki]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 06:35:16 GMT</pubDate>
            <atom:updated>2026-04-14T13:43:04.668Z</atom:updated>
            <content:encoded><![CDATA[<h4>Pandas to PostgreSQL: A Step-by-Step Guide for geospatial Datasets.</h4><p>While Pandas is the undisputed champion for data exploration in Python, SQL remains the backbone of robust data engineering. We’ve all been there: you discover a high-resolution Sentinel-2 catalog or a massive archive of IoT logs, fire up a Jupyter Notebook and load the CSV. Then, you wait, only for the kernel to hang.<br>As geospatial professionals, our metadata: the coordinates, timestamps, and spectral indices that define our imagery is growing in both scale and complexity. Pandas is excellent for a quick look, but it eventually hits a performance ceiling. To build production-grade pipelines that scale, you don’t just need a script; you need a database.</p><p>Why PostgreSQL?<br>In the world of Earth Observation, PostgreSQL isn’t just a database; it’s the gold standard. It’s the foundation for PostGIS, allowing us to move beyond simple rows and columns to handle geographic shapes, satellite imagery headers and spatial joins with ease.<br>In this new series, Retrieving Spatial Metadata with SQL, I’m breaking down the transition from “clueless” to “querying” using a real-world multispectral dataset from Pakistan that’s been shared on Kaggle. I’ll be following the SQL Cookbook Query Solutions and Techniques for All SQL Users book.</p><p>The first hurdle is often the most frustrating: Environment Setup.<br>In <a href="https://tidbitsgeospatial.wordpress.com/2026/04/05/sql-for-geospatial-datamastering-the-basics/"><strong>Part 1</strong></a> of the series, we get straight to the architecture. We will be doing the following:</p><p>Bridging the Gap: Use a Python bridge (SQLAlchemy and kagglehub) to automate the flow of data from Kaggle directly into one’s local database.<br>Building the Pipeline: Instead of manual CSV downloads, we create a repeatable script that handles our test csv in minutes. This will allow us to work with various other datasets as we move in this series<br>Memory Management: Learn why moving data from RAM (Python) to Disk (SQL) is the secret to handling millions of rows without exhausting your machine.<br>We aren’t just talking theory. We’ll be using several gospatial datasets publicly available on Kaggle. We start with a Sentinel-2 Multispectral Crop Dataset, covering everything from NDVI health indices to precise geographic coordinates.<br>By the end of the first installment, you’ll have a live PostgreSQL instance running locally, populated with thousands of agricultural records, ready for the SQL cookbook recipes in <a href="https://tidbitsgeospatial.wordpress.com/2026/04/06/sql-for-geospatial-datamastering-the-basics-2/">Part 2</a>.</p><p>👉 [<a href="https://tidbitsgeospatial.wordpress.com/2026/04/05/sql-for-geospatial-datamastering-the-basics/">Part 1:Getting started</a>]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_xfjjinGt1hSI2BEhz-SA.png" /><figcaption>Local PostgreSQL instance</figcaption></figure><p>👉 [<a href="https://tidbitsgeospatial.wordpress.com/2026/04/06/sql-for-geospatial-datamastering-the-basics-2/">Part 2: Retrieval-Filtering and Aliases</a>]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUUVJRaRjJ36rqarCsdXog.png" /><figcaption><strong>A sample query screenshot</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ee79d80b6f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Retrieval-Augmented Generation (RAG)]]></title>
            <link>https://medium.com/@njokim/retrieval-augmented-generation-rag-5c3e81e8197e?source=rss-70f9b04daa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c3e81e8197e</guid>
            <dc:creator><![CDATA[Njoki Mwihaki]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 15:59:22 GMT</pubDate>
            <atom:updated>2024-12-20T15:59:22.903Z</atom:updated>
            <content:encoded><![CDATA[<p>RAG is one of those LLMs things I’m yet to learn &amp; understand. Retrieval-Augmented Generation (RAG) is a technique that enhances Large Language Models (LLMs) by incorporating knowledge from external databases. RAG addresses challenges with LLMs, such as hallucination, outdated knowledge &amp; non-transparent reasoning. By referencing external knowledge, RAG reduces the problem of generating factually incorrect content. It combines the LLMs’ existing knowledge with external information.</p><p>Here are some key aspects of RAG:</p><ul><li>How it works: RAG retrieves relevant document chunks from an external knowledge base using semantic similarity calculations. This external information is then combined with the user’s query to generate a well-informed answer from the LLM.</li></ul><p>Key Components: RAG frameworks include three parts:</p><ol><li>Retrieval: This involves indexing documents, encoding them into vectors, and storing them in a vector database. When a query is received, the system retrieves the most relevant chunks based on semantic similarity.</li><li>Generation: The query and retrieved documents are combined into a prompt, which is used by an LLM to generate a response.</li><li>Augmentation: This refers to how the retrieved information is used to enhance the generation process.</li></ol><p>Evolution of RAG: RAG has evolved through 3 main paradigms:</p><ol><li>Naive RAG: This is the earliest form of RAG, following a “retrieve-read” framework, involving indexing, retrieval, and generation. However, it suffers from challenges like imprecise retrieval and hallucination during generation.</li><li>Advanced RAG: This paradigm introduces pre-retrieval &amp; post- retrieval strategies to improve the quality of information retrieval. It optimizes indexing, queries &amp; the use of retrieved context.</li><li>Modular RAG: This approach is more flexible, incorporating diverse modules &amp; allowing for module substitution and reconfiguration. It also supports iterative and adaptive retrieval.</li></ol><h4>RAG vs. Fine-tuning</h4><p>RAG is often compared to fine-tuning. RAG is like providing a model with a textbook for information retrieval, whereas fine-tuning is like having a student internalize knowledge. RAG is better suited for dynamic environments that require real-time knowledge updates. RAG can also be combined with fine-tuning for optimal performance</p><h4>RAG and LLM Context Length</h4><p>While LLMs can now handle very long contexts, RAG remains valuable because it can improve efficiency through chunked retrieval, enables the verification of answers with original references &amp; allows for observation of the retrieval &amp; reasoning processes, unlike generation solely relying on long context which is a “black box”. RAG’s ability to integrate external knowledge into LLMs makes it a key technology for various applications, including chatbots, question-answering systems &amp; other real-world tasks</p><p><strong>The </strong><a href="https://www.tiktok.com/@njo.k.i/video/7450134672895397125?_t=8sMEfXVs4px&amp;_r=1"><strong>TikTok</strong></a><strong> is on</strong>: RAG improves LLMs by incorporating external knowledge bases to address limitations like hallucinations &amp; outdated information. The survey categorizes RAG approaches into Naive, Advanced, and Modular RAG, examining their retrieval, generation, and augmentation techniques</p><p>Reference</p><ol><li><a href="https://arxiv.org/abs/2312.10997">https://arxiv.org/abs/2312.10997</a></li><li><a href="https://www.tiktok.com/@njo.k.i/video/7450134672895397125?_r=1&amp;_t=8sMEfXVs4px">Tiktok podcast</a></li></ol><p>Content generated using Google Notebooklm Deepdive for the tiktok podcast as well as the article text</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c3e81e8197e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Machine Learning and its System Types]]></title>
            <link>https://medium.com/@njokim/what-is-machine-learning-and-its-system-types-87058e823da6?source=rss-70f9b04daa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/87058e823da6</guid>
            <category><![CDATA[hands-on-machine-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Njoki Mwihaki]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 23:21:07 GMT</pubDate>
            <atom:updated>2024-10-29T03:43:05.949Z</atom:updated>
            <content:encoded><![CDATA[<p>Programming computers so that they can learn from data. i.e., giving computers the ability to learnt from data without being explicitly programmed (given code rules). A computer is said to learn in respect to a Task(T) if with Experience(E) and by some measure of performance(P), if its performance on the task improves with experience.</p><h4><strong>Types of Machine Learning Systems</strong></h4><p>Types of machine learning systems can be termed based off the 3 main groups i.e.,</p><ul><li><em>Type of training done on data</em></li><li><em>Type of learning</em></li><li><em>Way of working</em></li></ul><h4>Systems based off type of Training.</h4><p><em>1. Supervised machine learning</em></p><p>Training data set fed to the algorithm includes the desired solutions known as labels. I.e., the training data comprises of features known as input and the desired output is known. An example is a classification task such as a spam filter or a regression task predicting the value of a car given a set of features such as production year, engine capacity etc. Supervised learning algorithms include:</p><ul><li>K Nearest Neighbors</li><li>Linear Regression models</li><li>Logistic Regression models</li><li>Support Vector machine (SVM) models</li><li>Decision trees and random forests models</li><li>Some Neural network models</li></ul><p><em>2. Unsupervised machine learning</em></p><p>Models based off training data that is unlabeled. Unsupervised learning algorithms include:</p><ul><li>Clustering: K means, DBSCAN, Hierarchical Cluster Analysis (HCA)</li><li>Anomaly detection and novelty detection: one class SVM, isolation forest</li><li>Visualization and dimension reduction models like: Principal Component Analysis (PCA), Kernel PCA, locally linear embedding (LLE), T distributed</li><li>Stochastic Neighbor Embedding (T-SNE), Association Rule Learning (Apriori &amp; Eclat)</li></ul><p><em>3. Semi-supervised machine learning</em></p><p>Algorithms whose training data is partially labelled. An example algorithm is:</p><ul><li><em>Deep belief networks (DBN) — based off Boltzmann machines</em></li></ul><p><em>4. Reinforcement machine learning</em></p><p>Algorithms that train agents (such as bots) to pick the actions that will maximize their rewards over time, within a given environment. e.g., a bot in a game may get a reward every time the opponent player loses some life points</p><p>The learning system referred to as an agent can observe the environment, select and perform actions and get rewarded/penalized</p><p>It thus learns by itself the best strategy i.e., the policy to get most rewards over time.</p><h4>Systems based off type of Learning (learning on the fly or not from incoming data)</h4><ol><li><em>Online learning</em></li></ol><p>Systems that can learn about new data on the fly, as it arrives which is normally cheap and fast. The systems learn data instances sequentially, either individually or in small groups called mini-batches. It also includes out of core learning where a system is trained on huge datasets that cannot fit in one’s machine main memory</p><p>In out of core learning, the algorithm loads part of the data, runs a training step on it and repeats the process until it has run out of all the data. Online learning systems adapt fast to changing data and this adapting to data is called the learning rate.</p><p><em>2. Batch learning</em></p><p>Also known as offline learning. The system is trained on all available data and cannot learn incrementally. Learning is done offline as it uses a lot of time and computing resources.</p><h4>Systems based off way of working (way of generalization)</h4><ol><li><em>Instance based learning</em></li></ol><p>Systems that learn by heart and generalize to new cases based off a similarity measure by comparing new instances with learned examples</p><p><em>2. Model based learning</em></p><p>Generalization from building a model from training examples and using the model to make predictions.</p><p>Steps involved include:</p><ul><li>Model selection</li><li>Definition of model parameters</li><li>Specifying a performance measure for the model which can be either:</li></ul><p><strong><em>Performance measures</em></strong></p><ol><li>A utility function (fitness function) that measures how well a model generalizes</li><li>A cost function that measures how badly the model generalizes</li></ol><p><strong>References:</strong></p><ol><li>Geron, A. (2019). Hands-on machine learning with Scikit-Learn, Keras and TensorFlow: concepts, tools, and techniques to build intelligent systems (2nd ed.). O’Reilly.</li></ol><p>Article also published as: <a href="https://tidbitsgeospatial.wordpress.com/2023/09/28/what-is-machine-learning-and-its-system-types/"><em>https://tidbitsgeospatial.wordpress.com/2023/09/28/what-is-machine-learning-and-its-system-types/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87058e823da6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Loss Functions in Machine Learning-(1)Multi class SVM loss]]></title>
            <link>https://medium.com/@njokim/loss-functions-in-machine-learning-1-multi-class-svm-loss-67c043e6a3bb?source=rss-70f9b04daa07------2</link>
            <guid isPermaLink="false">https://medium.com/p/67c043e6a3bb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Njoki Mwihaki]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 18:43:24 GMT</pubDate>
            <atom:updated>2021-07-23T02:56:24.437Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://tidbitsgeospatial.wordpress.com/2021/07/15/loss-functions-in-machine-learning-1multi-class-svm-loss/"><strong>Loss Functions in Machine Learning-(1)Multi class SVM loss</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*_z_x4q-qsqVaLUxu-EpDAQ@2x.jpeg" /></figure><p>Loss function is a component that gives the deviation of a predicted score against the true value. The predicted score is the result a machine learning model gives on mapping raw data to class scores</p><p>Support Vector machine loss needs the correct score for each image to have a higher value than the incorrect scores by a certain fixed margin. This thus results in a lower loss</p><p>Sj is the score value of a predicted value of other classes</p><p>Syi is the predicted score of the true class.</p><p>Thus the SVM loss is the maximum value comparison between zero and the difference of the two</p><p>if Sj-Syi + a fixed margin say 1 in the image is higher than zero, that shows the classifier is doing poorly</p><p>if less than zero, the SVM loss become zero and the classifier is performing well</p><p><a href="https://cs231n.github.io/linear-classify/">Reference</a></p><p>Stanford CS231n</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67c043e6a3bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>