Updates and Node.

OK, I see that if I make more than one blog post in the same day Jekyll posts them in descending alphabetical order by title. So this post was meant to go before Creating a server with Node. Update (11 Jul 2024): Turns out I can just add a timestamp to get the multiple posts on the same day in the right order!

Turns out to display my 538 code all I had to do was export my Jupyter notebook to .html.

Since then I’ve done one other project, which I actually finished over a month ago (I’ve been very busy since then). The project is called “Do-nothing” Congress. With Python, I used the Legiscan API to gather data on all 15,000+ bills introduced in the 118th (current) Congress as of 1 June 2024, then trained that data to predict whether a bill would become law. Basic logistic regression problem, I thought. The hardest part turned out to be the class imbalance – only 64 bills actually became law, so a baseline algorithm that always predicts a bill won’t become law would be accurate 99.6% of the time! Ultimately my model was accurate 99.8% of the time with a precision (fraction of true positives out of all identified positives) of 100% and a recall (fraction of true positives identified) of 57.1%. The other challenge was feature selection. I learned that with data with a lot of binary or categorical variables PCA is not effective. The categorical data analog to PCA is MCA, or multiple correspondence analysis. Since my data frame still had some numerical data I found that I could use the prince package. From the flow chart in the package’s github repository, I concluded that FAMD, factor analysis of mixed data, would be the best way to reduce dimensions. Unfortunately I didn’t really get to do it due to the project deadline. I managed a tiny bit of dimension reduction using PCA, anyway, but I know the model would’ve worked better if I’d done more. Oh well, the project got me the Data Science Boot Camp certificate (finally)! And, Steven said it was a hard problem, and I made “admirable” progress.

So now the new project. It started as a SQL database of Husband’s video games. After hours of reading on the web, I finally saw a 13 minute video and learned how to install and use MySQL. Now I have a little database with 10 of Husband’s games. But I realized, I don’t really know how to exploit the “relational” part of SQL to make this database useful to Husband. I thought relational means there are multiple tables in the database with keys that link to each other. I couldn’t think of more than one table in this case. It’s also possible to query with SQL. I spent some time exploring a sample database about DVD rentals. Some of the queries included which stores have a certain DVD title, what a customer’s balance is, and which DVDs are rented out. I wondered, what kind of query could I make with Husband’s games? At this point I have one idea, which is to find out how much the entire collection is worth.

I got into my mind that I was also going to use JavaScript to make a GUI for Husband to access the database himself. And maybe even use JS to automatically scrape the values of the games from Ebay or some other site. I had in mind some kind of interface where Husband can make queries in a user-friendly way, then JavaScript will call on MySQL in the background. I’ve done some browsing on the web and it looks like this is possible with Node.js. I already suspected Node would be worth learning, I think I first learned about it awhile back when I bought a definitive guide on JavaScript. At that time I learned what frontend/client-side and backend/server-side development are, and that most of my programming experience is frontend. I think what I’m coming up with now is a web application for Husband to use to keep his game collection organized. And the other day, when I was applying for jobs, I learned that React is a desirable skill to have, and it is another JS library that does more frontend. So what I’m hoping is with this project I will learn Node, React, and SQL. But probably not as much SQL as I was expecting.

Awhile back I tried to learn about Node in my JavaScript book but I couldn’t get into it because it was too technical. But since watching that video about MySQL I decided it would be easier to watch some videos on Node, then maybe try to read that book. I watched one video today, paused a couple of times to look up some vocabulary words. Synchronous and asynchronous development, I’m still not sure what that is, but I know Node is asynchronous. I learned about Express, which I saw in a tutorial about setting up a backend with Node, MySQL, Express, and Sequelize. Turns out Express is just a Node module. My goal today is to do all the steps in the video I watched, and then write about what I learned. Stay tuned.

Written on July 3, 2024