Author Archives: jamesdmccaffrey

Naive Bayes Classification Example Using the scikit Library

Naive Bayes classification is a classical machine learning technique. It is best used when the predictor variables are all non-numeric. Naive Bayes works for both binary classification and multi-class classification. And naive Bayes works well when you don’t have very … Continue reading

Posted in Scikit | Leave a comment

Understanding the PyTorch Linear Layer Default Weight and Bias Initialization

When a PyTorch neural network is instantiated, it’s common practice to use implicit weight and bias initialization. In the case of a Linear layer, the PyTorch documentation is not clear, and the source code is surprisingly complicated. I spent several … Continue reading

Posted in PyTorch | 1 Comment

A Simplified Version of the scikit Library make_circles() Function

I was looking at spectral clustering with the scikit-learn library. Standard k-means clustering doesn’t work well for data that has weird geometry. A standard example is data that when graphed looks like two concentric circles. Spectral clustering connects data into … Continue reading

Posted in Machine Learning | Leave a comment

“Researchers Evaluate the Top Four AI Stories of 2022” on the Pure AI Web Site

I contributed to an article titled “Researchers Evaluate the Top Four AI Stories of 2022” in the January 2023 edition of the Pure AI web site. See https://pureai.com/articles/2023/01/05/top-ai-stories-of-2022.aspx. I am a regular contributing editor for the Pure AI site. For … Continue reading

Posted in Machine Learning | Leave a comment

What Are Correct Values for Precision and Recall When the Denominators Are Zero?

I did an Internet search for “What are correct values for precision and recall when the denominators equal 0?” and was pointed to a StackExchange page which had been up for over 11 years — and which was somewhat ambiguous. … Continue reading

Posted in Machine Learning | 1 Comment

NFL 2022 Season Super Bowl LVII Prediction – Zoltar Predicts the Chiefs Will Beat the Eagles

Zoltar is my NFL football prediction computer program. It uses reinforcement learning and a neural network. Here are Zoltar’s predictions for week #22 (Super Bowl LVII) of the 2022 season. Zoltar: chiefs by 3 dog = eagles Vegas: eagles by … Continue reading

Posted in Zoltar | Leave a comment

“Logistic Regression from Scratch Using Raw Python” in Visual Studio Magazine

I wrote an article titled “Logistic Regression from Scratch Using Raw Python” in the January 2023 edition of Microsoft Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2023/01/18/logistic-regression.aspx. Logistic regression is a machine learning technique for binary classification. For example, you might want to … Continue reading

Posted in Machine Learning | Leave a comment

Solving the Traveling Salesman Problem (TSP) Using an Epsilon-Greedy Algorithm

An epsilon-greedy algorithm is a general approach that can be used for many different problems. I recently devised a nice evolutionary algorithm for the Traveling Salesman Problem (TSP) that seems to work very well. Just for fun, I spent one … Continue reading

Posted in Machine Learning | Leave a comment

Another Look at GPT-3 / Codex / GitHub Copilot – I Have Mixed Opinions

GPT-3 (“Generative Pre-trained Transformer”) is a large language model that can generate text, such as a response to, “Write two paragraphs about the history of computer programming.” GPT3 was trained on an enormous corpus of text — Wikipedia, books, blogs, … Continue reading

Posted in Machine Learning | Leave a comment

Binary Classification Using a scikit Decision Tree

I hadn’t looked at using a decision tree from the scikit-learn (scikit for short) library for several months, so I figured to do an example. Before I go any further: I am not a big fan of decision trees and … Continue reading

Posted in Scikit | Leave a comment