Skip to content

Strava for Intellectual Pursuits

I use Strava to track my progress and record personal reflections about my workouts. Through it, I can observe my training progress over time. Why not do the same with my thoughts?

Supervised Machine Learning Basics

After taking Machine Learning for Trading (ML4T) this spring, where I built a trading bot using machine learning principles, I was curious about applying the algorithms to areas outside of finance. In the course, I built a few machine learning algorithms from scratch in Python. It would pretty tedious to build the algorithms from scratch or tweak them to every use case ~~ain't nobody got time for that~~, however, and I wanted to focus more on their applications in new domains. Andrew Ng's Supervised Machine Learning course seemed like a great way to dip my toe in the water and use some modern-day frameworks, so I started the course.

Within the first few minutes of the course, I was presented with a few examples of supervised learning in practice: spam filtering, speech recognition, machine translation, online advertising, self-driving cars, and defect detection in manufacturing. Online advertising was the most illustrative example: features would be the ad and user info, and the output would be whether the user clicks on the ad. In the case of

Unsupervised learning received some coverage as well. An example of an unsupervised learning algorithm is in Google's news aggregation tile, where similar stories from different news outlets are clustered together. This is an example of a clustering algorithm. A clustering algorithm ~~finds structure in data without being explicitly told what that structure should look like~~ groups similar data together. So in the case of the google tile, it finds similar news articles based on several keywords that they share - these keywords are discovered by the algorithm itself!

More generally, an unsupervised learning algorithm receives data with labeled inputs and unlabeled outputs. Clustering is one example. Anomaly detection is another. An example of anomaly detection is detecting fraud in the financial systems, such as unusual transactions. Another example of unsupervised learning is dimensionality compression, where the resulting dataset is much smaller.

I was curious why mean squared error was used in ML4T. This course addresses a few reasons why MSE is a useful cost function: - taking the mean of the errors prevents the cost function from unboundedly increasing as the training set increases in size - the shape of a squared function is convex. in other words, the cost function will always have a minimum which gradient descent can exploit in all dimensions

Gradient descent

\(\omega = \omega - \alpha \frac{\partial J(\omega)}{\partial \omega}\) - with respect to model weights, Ng cautions against using non simultaneous updates in gradient descent because this is not how gradient descent is typically implemented, which means the non simultaenous update may have different characteristics. instead, all weights should be updated before the next iteration

gradient descent is described as an interative update to a parameter. the updated parameter gets the result of the product of (a learning rate factor and [partial] derivative) subtracted from the previous parameter value.

In the ML community, a "batch" gradient descent algorithm is one that is used to tune the model on the "batch" - that is, the whole - of training data.

Learning rate

If the learning rate \(\alpha\) is too small, gradient descent makes tiny updates and takes a long time to reach the minimum. If \(\alpha\) is too large, the updates can overshoot the minimum, bounce around, or even fail to converge.

The main idea is that \(\alpha\) controls the step size of each gradient-descent update. The best learning rate is large enough to make progress efficiently, but small enough that the cost keeps moving downward instead of oscillating or diverging. In practice, a dynamically-adjusted alpha could yield better results. For example, alpha can be relatively large at the outset, but iteratively diminished the closer the GD function gets to the local minima.

Ng notes that even with a fixed learning rate, it is still possible for GD to converge on the local minimum. Imagining a simple quadratic curve: as the iterative updates to the parameter approach the minimum, the magnitude of the gradient decreases such that the magnitude of the parameter's updates reduce over time.

Convex function

The quadratic mean squared error (MSE) function is a convex function. The GD algorithm will always converge to its global minimum. This is in contrast to functions that have multiple local minima. The GD algorithm is not guaranteed to converge to the global minimum because it ultimately depends on where the initial guess of the parameters is.

Databases

For my first summer term in OMSCS, I completed the Database Systems Concepts and Design course! I was curious about backend data management after taking Machine Learning for Trading in the spring. This class definitely delivered on that front and provided me with a solid foundation in databases and database management systems. In this post, I'll describe how I designed an application database from scratch. I undertook this task in 3 phases: analysis, design, and implementation. Along the way, I learned how to think about building a consistent database application from first principles, how to work with teammates from different countries and time zones, built my first ever web application, and gained experience designing the full stack.

The Customer

PowerShare is a nonprofit organization that wishes to accumulate data regarding households in the United States, specifically around alternative power sources and other household properties.

The Requirements

The requirements document contained descriptions of data that PowerShare wanted to collect from users, as well as mockups of the web application. Household, appliance, and power generation data was collected from the user and displayed in reports. The data collected was “open” in the sense that any user of the application was able to submit their data. Conversely, any user could browse the selected set of reports available on the PowerShare website.

In industry, this document is generated with the help of various stakeholders: product managers, architects, developers, QA, UX/UI designers, and DevOps, among other roles. Luckily for us, the requirements document abstracted away countless meetings and change requests, freeing up valuable summertime hours. :)

Analysis

I used several tools to capture the results of our analysis: an information flow diagram, extended entity relationship (EER) diagram, attribute tables, task decompositions, and abstract code. It's quite a mouthful, but the main point of these tools is to help organize the planning before any code has been written. The information flow diagram is the highest-level diagram and maps each application functionality with the type(s) of database interaction. The EER diagram captures all entities associated with the database and describes their attributes and relationships with each other. Attribute tables summarize the data types and business constraints for attributes associated with each entity. Finally, the task decomposition associates each spoke of the information flow diagram with a piece of abstract code. The abstract code is a language-agnostic representation of the application's functionality. It captures the core logic of teh application code, so its intent can be implemented in any language or framework.

The analyis is useful for distilling the functionality of the web application from a database perspective. It is also easier to further refine requirements with stakeholders by using a common language, such as these tools. The implementation phase adds a level of complexity that is best tackled after analysis has been conducted. Most importantly about the three-phase process is that it is quite iterative. I found myself amending previous diagrams/tables as we went deeper towards the implementation.

Collected data could be ingested in several formats such as decimals, integers, and strings. Some data had additional constraints, such as zip codes being limited to five digits or latitude/longitude values being limited to their respective measurements in degrees. Validating the input data before it was added to the database was important, as incompatible data could seriously affect the quality and accuracy of the reports. This analysis process is rigorous, and is best suited towards applications that depend on database management systems. These types of applications tend to manage large volumes of data, provide access to multiple users concurrently, enforce constraints

Design

With most of the high-level thinking completed in the analysis phase, I refined these ideas in the design phase. The abstract code was updated with syntactical SQL queries. I replaced the attribute tables with entity relationship maps, which is just a fancy way of describing a diagram of schemas connected by their foreign keys.

The most significant deliverable in the design phase was a .sql script containing definitions of schemas and constraints in the DBMS. Each table had its own CREATE statement. It also contained DROP statements preceding the CREATE statements, so it could be used to completely wipe an existing database. For our project, I chose PostgreSQL due to its popularity, which would invariably enable us to use the ample documentation, forum posts, and Youtube tutorials to our advantage. Going forward, I think this is a great way to go about building a personal project from scratch. I'd recommend using more niche/bespoke solutions when the problem calls for it and when there is quality developer support. This could come in the form of thorough documentation or having access to the developers of the solution.

Implementation

Now, my favorite part. This was where the rubber hit the road. I had never built a web application before, so I was curious to see how the process would unfold. The teaching staff had suggested some popular stacks, such as LAMP or WAMP. We decided that a Linux-Flask-Python-PostgreSQL (LFPP) would allow us to build out the core functionality while reducing uneeded complexity. The app would be demo'ed by one of us at the final presentation, so a beefier framework was not necessary.

Some important context that I considered at the onset was that each developer would be contributing to the application from their own development environment. Between the four of us, we used Linux, Mac, and Windows operating systems. So configuration management was important. I also considered the idea of extending functionality in the future. It's certainly easier to do that when less time is spent fiddling around with software packages. To this end, I used a Poetry package manager, although a simple pip package manager could have been used as well. To bundle up the entire application (including Postgres), I could have used a Docker container, but this also would have added complexity that wasn't necessary. The application used basic Postgres functionality, so pretty much any Postgres version that was available for download as of July 2026 would have been fine.

For version control, we used git and a shared github repo. The tried and true combination.

With configuration out of the way, I

On blogging

I kept a blog when I was younger. I approached it as a highly polished portfolio of my thoughts. Posts were infrequent and daunting to write. I wrote for others, not myself. Years later, I realized that nourishing this craft through regular practice was more important to me than publishing a 'finished' product every time.

Why write on a personal website? Why not use another service, like Substack?

Many people seem to document their projects/lives using YouTube, Instagram, Substack, etc. However, these companies own their platforms and thus exert influence on the means of creation. They essentially behave as content incubators. I currently have no plans to make writing a career, and I'm not writing for a broad audience. I want my creativity to flourish without the pressure to commercialize, and I want to keep it exclusive, like a walled garden. I believe I can achieve this by creating and hosting a static website on Github Pages. If I ever want to release my works to a broader audience, I can publish them on a platform.

Why write on digital?

The digital world is always at my fingertips. I can access my work from anywhere, and so can the people I share with.

Why writing and not filming?

Writing can be parsed/skimmed easily and doesn't require high activation energy: I simply fire up a Codespaces instance, create a file, and push it to the Github repo. I don't have to think about how I look or sound. Writing puts the ideas at center stage. I chose the mkdocs website as a template for my blog because it makes writing even easier. I need only write in markdown - the plugin automatically converts it to HTML/CSS. I can also go back in time and easily edit my posts. If I'm away from my computer and have recorded ideas in my notes app, I can easily copy and paste them into markdown on my Mac. For these reasons, I think writing digitally is the perfect medium for experimentation. In the future, I may explore voice dictation to reduce friction and save myself some time. I also enjoy hearing my own voice.

Who am I, the writer?

A learner and a sharer.

Who am I writing for?

Primarily future me. I would like to look back at all the progress I've made.

What kind of writing am I posting here?

As this site is always a work in progress (much like myself!), some pieces are in their nascent stages and others are closer to being fully developed. This is a place where I document my experiments. I will call it the Strava for Intellectual Pursuits. Similarly to how my athletic pursuits have shifted over the years, I can quickly try things and move on when it's time.

Housekeeping

Housekeeping

After being away from the digital sharing space for quite some time, I have decided to return!

What have I been up to these past few years?

Well, to put it simply, I've been living and developing as a human being!

Where have I been?

After growing up in Phoenix and graduating college in Somerville, MA, I lived in various cities in the Greater Boston Area. I also moved across the country twice to live in the Bay Area, which is where I currently am. I am extremely privileged to have visited several countries, which include, in no particular order: Canada, Denmark, Sweden, Italy, England, France, Mexico, The Netherlands, Kingdom of Saudi Arabia, Japan, Republic of Korea, and Vietnam. I traveled to some of these countries for work, and managed to find time for play in all of them. More on play in a minute. I seem to enjoy adventuring in large cities. In Amsterdam, I walked an entire day around the city to hunt for the best pie. In Hanoi, I discovered some amazing street food and restaurants by moped, and even took it on a countryside road trip. In Seoul, I ran along the Cheonggyecheon stream and the Han River - a great way to get a long run in and see the sights. I have so many stories to share, which I may include in future posts!

What have I done?

Extracurricularly, I've mostly dabbled in the world of sports. I took up fishing for a few weeks when COVID initially broke out as a way to spend quality time social distancing. I managed to overcome my disgust of hooking worms and even caught a juvenile largemouth bass. I ultimately discovered that I desired a little more stimulation, so I stored my rod and lures and headed over to the local rock climbing gyms, where I spent a good many hours enjoying the company of people and thinking about colorful plastic rocks. As I accumulated friends and tendon strength, I eventually began projecting V7's until I caught the running bug and decided to devote my time away from work to getting faster. As my upper body muscular definition faded, my lower body muscles increasingly became adept at running longer distances. Running is fun, but not in the same way climbing is. Running is fun because

What's next?

More time devoted to pursuing my interests and passions, and continued growth and learning!