RSSAmplifier

Blog

The Pleasure of Finding Things Out: A blog by James Triveri

A technical blog by James Triveri"

jtrive.comRSS feed ↗20 posts

Latest posts

Graph Algorithms in the Language of Linear Algebra

GraphBLAS is a framework for expressing graph algorithms through sparse linear algebra. A graph is represented as a sparse adjacency matrix, with nodes represented as sparse vectors. It emerged from a realization that many graph algorithms are fundamentally sparse linear algebra algorithms, and many graph operations could be expressed as matrix operations. For example, many graph algorithms can be…

High Performance Graph Algorithms with cuGraph

For a past project, I was exploring options for a high-performance alternative to NetworkX for large networks. I attended a breakout session at the Scipy conference focusing on cuGraph from the NVIDIA RAPIDS project, and was intrigued. cuGraph is part of NVIDIA’s RAPIDS ecosystem. It is a GPU-accelerated graph analytics library designed to feel familiar to NetworX users while running expensive…

Practical NLP for Risk Modeling, Part III - Narrative Compression vs. Truncation

The notebook version of this post can be downloaded here . In Part II of the Practical NLP for Risk Modeling series, we fine-tuned DistilBERT end-to-end on NOAA tornado narratives and saw significant performance improvement versus the frozen-embedding baseline from Part I. That result is encouraging, but it raises a practical question: How much narrative text do we actually need? Free-form text…

Practical NLP for Risk Modeling, Part II - Fine-tuning DistilBERT End-to-End on Tornado Narratives

The notebook version of this post can be downloaded here . In Part I of the Practical NLP for Risk Modeling series, we walked through how to use a pre-trained transformer model as a frozen feature extractor for classifying tornado severity based on NOAA event narratives. Each narrative was embedded into a 768-dimensional vector, then trained using a regularized Logistic Regression head. That…

Practical NLP for Risk Modeling, Part I - Turning Text into Embeddings with Pretrained Transformers

The notebook version of this post can be downloaded here . Modern NLP workflows increasingly rely on pretrained transformer models such as BERT and its variants. These models are trained on massive text datasets to learn general purpose language representations that can be reused across a wide range of downstream tasks, including classification, information extraction, and document triage. In an…

GPU Acceleration with Polars LazyFrames

In a previous post, I walked through how Polars can be used to process larger-than-memory datasets without needing to setup and maintain a dedicated compute cluster. This was accomplished by taking advantage of the Polars LazyFrame. Unlike a regular DataFrame which executes operations immediately, a LazyFrame builds up a logical query plan and defers execution until you explicitly call a method…

Extracting Fire Station Locations from OpenStreetMap

OpenStreetMap (OSM) is a collaborative project that creates a free, editable map of the world. It’s built and maintained by a global community of contributors who collect and upload geographic data including roads, buildings, parks and more, using GPS devices other public sources. OSM allows anyone to use its data freely under the Open Database License (ODbL), which makes it popular for research…

No API? No Problem - Mapping Coordinates to ZIP Codes for Free

ZIP Codes are widely used in analytics because they serve as a convenient proxy for geographic location, even though they are not true areal units. In the United States, ZIP Codes are created and managed by the United States Postal Service for the purpose of delivering mail. They represent collections of delivery routes (not enclosed polygons), and because these routes can change over time and…

Handling Larger-than-Memory Datasets with Polars LazyFrame

Pandas is the de-facto standard when working with tabular datasets in Python, but it encounters significant challenges when handling large datasets. The core issue stems from Pandas’ architecture, which relies entirely on in-memory processing. This design requires loading the entire dataset into memory, resulting in a hard limit on the size of datasets that Pandas can process. When data volumes…

Streamlining Multi-App Deployment with Docker and NGINX

In this post, we’ll walk through the setup of an application server on a RHEL9 virtual machine to host multiple Dash and Shiny applications. While I found several guides that covered 60-70% of what I was looking to do, none fully matched what I needed. This setup checks all the boxes: Runs on a RHEL9 virtual host. Uses NGINX as a reverse proxy. Hosts both Dash and Shiny apps each in its own Docker…

Up and Running with JAX - Backpropagation and Training Neural Networks

In the third and final installment of the Up and Running with JAX series, we demonstrate the remaining steps required to train and evaluate a simple neural network, specifically the implementation of the loss function, backward pass and training loop. As in Part 2, the focus will be on predicting class labels for the MNIST dataset, which consists of 28x28 pixel images of handwritten digits (0-9).…

Up and Running with JAX - Fully-Connected Network Forward Pass

In a previous post , I introduced JAX with particular emphasis on JIT compilation, vectorizing transformations and automatic differentiation. In this post, we walkthrough an implementation of the forward pass for a fully-connected neural network with the goal of classifying MNIST handwritten digits, incorporating concepts from the first post. We begin by loading MNIST training and validation sets,…

Up and Running with JAX - JIT Compilation, Vectorizing Transformations and autodiff

I first learned about JAX a few years back in an article on functorch. Functorch was a library that brought JAX-like composable function transformations to PyTorch, initially developed as a separate library but has since been fully integrated into PyTorch’s core (as of PyTorch 2.0). I’ve recently invested time in learning JAX, which has proven incredibly worthwhile. The clean functional approach…

Creating Animations with Folium

TimestampedGeoJson is a Folium plugin that facilitates the visualization of geospatial data that evolves over time using the GeoJSON format with timestamps. This is useful for tracking vehicle trajectories, satellites, pedestrian traffic, changes in weather patterns or any other geospatial phenomena with time dependent characteristics. TimestampedGeoJson leverages Leaflet.js’s leaflet-timestamped…

The Bootstrap Chain Ladder from Scratch using Polars

In an earlier post , I provided a step-by-step guide on performing the bootstrap chain ladder using Pandas. This method involves repeatedly resampling residuals from the original chain ladder model to generate a series of simulated datasets, each replicating the original data’s claims development patterns (for more background, refer to the linked article). Here we again walkthrough the bootstrap…

Standing Up Ad-hoc Compute Clusters with Dask

Dask is an open-source parallel computing library for Python that enables the processing of large datasets and complex computations across multiple cores and distributed systems. It provides a flexible and dynamic task scheduling system that allows users to build complex workflows and handle large-scale data processing. Dask is a compelling alternative to PySpark for distributed computing,…

Multimodal Neural Networks for Risk Classification

Multimodal neural networks are a type of model designed to integrate data from multiple modalities, such as text, images, audio, video, or other data types. Multimodal networks aim to learn complex relationships between different kinds of inputs, with the hope of achieving better performance than a model focusing on a single modality. For example, in applications like video captioning, a…

Geohashing for Fun and Profit

I recently became interested in geohashing and wanted to develop an understanding of the algorithm with the aim of implementing it myself. I was surprised to find it to be quite simple and intuitive. In this article, I’ll demonstrate how to generate geohashes for a given latitude and longitude and compare results against pygeohash , a Python library for all things geohash-related. I’ll also…

GIS Algorithms in Python, Part I - Point-to-Point and Point-to-Line Distances

I’ve been spending time exploring Ningchuan Xiao’s excellent book, GIS Algorithms . This text offers a comprehensive dive into fundamental geospatial concepts including geometric algorithms, spatial indexing, and spatial analysis. The author thoroughly explains the theoretical foundations of each concept and provides practical Python implementations as examples. In a series of upcoming posts, I’ll…

The Bootstrap Chain Ladder from Scratch using Pandas

The bootstrap chain ladder is a statistical technique used in actuarial reserving to project future claim liabilities based on historical data. It builds upon the chain ladder method, but the chain ladder method by itself does not provide a measure of the uncertainty in its projections, which is where the bootstrap technique comes in. The bootstrap chain ladder provides an empirical distribution…