Machine Learning Guide

MLA 003 Storage: HDF, Pickle, Postgres

Machine Learning Guide

Show Notes

Practical workflow of loading, cleaning, and storing large datasets for machine learning, moving from ingesting raw CSVs or JSON files with pandas to saving processed datasets and neural network weights using HDF5 for efficient numerical storage. It clearly distinguishes among storage options—explaining when to use HDF5, pickle files, or SQL databases—while highlighting how libraries like pandas, TensorFlow, and Keras interact with these formats and why these choices matter for production pipelines. Links Notes and resources at ocdevel.com/mlg/mla-3 Try a walking desk stay healthy & sharp while you learn & code

Data Ingestion and Preprocessing Data Sources and Formats: Datasets commonly originate as CSV (comma-separated values), TSV (tab-separated values), fixed-width files (FWF), JSON from APIs, or directly from databases. Typical applications include structured data (e.g., real estate features) or unstructured data (e.g., natural language corpora for sentiment analysis).

Pandas as the Core Ingestion Tool: Pandas provides versatile functions such as read_csv, read_json, and others to load various file formats with robust options for handling edge cases (e.g., file encodings, missing values). After loading, data cleaning is performed using pandas: dropping or imputing missing values, converting booleans and categorical columns to numeric form.

Data Encoding for Machine Learning: All features must be numerical before being supplied to machine learning models like TensorFlow or Keras. Categorical data is one-hot encoded using pandas.get_dummies, converting strings to binary indicator columns. The underlying NumPy array of a DataFrame is accessed via df.values for direct integration with modeling libraries.

Numerical Data Storage Options HDF5 for Storing Processed Arrays: HDF5 (Hierarchical Data Format version 5) enables efficient storage of large multidimensional NumPy arrays. Libraries like h5py and built-in pandas functions (to_hdf) allow seamless saving and retrieval of arrays or DataFrames. TensorFlow and Keras use HDF5 by default to store neural network weights as multi-dimensional arrays for model checkpointing and early stopping, accommodating robust recovery and rollback.

Pickle for Python Objects: Python's pickle protocol serializes arbitrary objects, including machine learning models and arrays, into files for later retrieval. While convenient for quick iterations or heterogeneous data, pickle is less efficient with NDarrays compared to HDF5, lacks significant compression, and poses security risks if not properly safeguarded.

SQL Databases and Spreadsheets: For mixed or heterogeneous data, or when producing results for sharing and collaboration, relational databases like PostgreSQL or spreadsheets such as CSVs are used. Databases serve as the endpoint for production systems, where model outputs—such as generated recommendations or reports—are published for downstream use.

Storage Workflow in Machine Learning Pipelines Typical Process: Data is initially loaded and processed with pandas, then converted to numerical arrays suitable for model training. Intermediate states and model weights are saved using HDF5 during model development and training, ensuring recovery from interruptions and facilitating early stopping. Final outputs, especially those requiring sharing or production use, are published to SQL databases or shared as spreadsheet files.

Best Practices and Progression: Quick project starts may involve pickle for accessible storage during early experimentation. For large-scale, high-performance applications, migration to HDF5 for numerical data and SQL for production-grade results is recommended. Alternative options like Feather and PyTables (an interface on top of HDF5) exist for specialized needs.

Summary HDF5 is optimal for numerical array storage due to its efficiency, built-in compression, and integration with major machine learning frameworks. Pickle accommodates

More from Machine Learning Guide

Feb 26, 2026

The aggregate job market held, the entry-level door narrowed, and software postings sit a quarter below pre-pandemic. Why cheap implementation made specification, verification and domain scarce, how ML roles split five ways, and how to position. Links Try a walking desk - stay healthy & sharp while you learn & code More OCDevel shows - this one has siblings, each on its own subject and produced the same way

Feb 22, 2026

OpenClaw as the worked example of the always-on personal agent: gateway, markdown memory, heartbeats, skills, coding agents from your phone, hosted vs local models, and the 2026 security record (exposed instances, two critical CVEs, ClawHavoc) with the posture that makes it survivable. Links Try a walking desk - stay healthy & sharp while you learn & code More OCDevel shows - this one has siblings, each on its own subject and produced the same way

Feb 22, 2026

What an AI agent actually is, why coding agents got good first, how memory really works, what MCP and A2A standardize, which SDKs are alive, how to evaluate on trajectories, and where the products stand after browser agents contracted. Links Try a walking desk - stay healthy & sharp while you learn & code More OCDevel shows - this one has siblings, each on its own subject and produced the same way

Jul 14, 2025

How to automate AI media end to end: clone your own voice on open TTS, pick music that's actually licensed, run ComfyUI graphs headless, design around fal, Replicate and provider queues, finish with ffmpeg, and stay inside licensing at every layer. Links More OCDevel shows - this one has siblings, each on its own subject and produced the same way Companion show. This episode is the overview of the media pipeline. For weekly, hands-on coverage of the video half, from a first usable clip to scenes that cut together, listen to AI Video Generation on Gnothi. Try a walking desk - stay healthy & sharp while you learn & code

Jul 12, 2025

Sora is shut down, Google runs two video models, Kling 3 does lip-synced dialogue, and open-weight MiniMax H3 is what you can actually fine-tune. What a usable clip costs, which models do native audio, how reference consistency works, and why the unit of work is the shot. Links Notes and resources at ocdevel.com/mlg/mla-26 More OCDevel shows - this one has siblings, each on its own subject and produced the same way. Companion show: for weekly, hands-on coverage of the AI video pipeline, from a first usable clip to scenes that cut together, listen to AI Video Generation. Try a walking desk - stay healthy & sharp while you learn & code

See all episodes →