Evolving Through Machine Learning

8/13/2024

Introduction

One day while reading about machine learning (ML) online, I had found ML.NET.  ML.NET is an open source and cross-platform machine learning framework. It provides a way for .NET developers to integrate ML into .NET apps without any prior ML experience. The framework comes with a simple UI tool called the Model Builder. The Model Builder provides an easy to understand visual interface to build, train, and deploy custom machine learning models. It supports AutoML, which automatically explores different machine learning algorithms and settings to help you find the one that best suits your scenario. All you have to do is load your data, and AutoML takes care of the rest of the model building process. It looked easy to use and I wanted to try it out on my computer.

I had installed the Model Builder extension in my Visual Studio but I wasn't able to get it to show. After some searching, I found a report of someone else experiencing this issue on the dotnet/machinelearning-modelbuilder GitHub page. After I commented on the issue, someone was thankfully able to provide a workaround so that I could start using the Model Builder.

Upgrade to .NET

Once I understood how to use the Model Builder, I was excited to implement the machine learning code into SingularAgent. However when I tried to use ML.NET in SingularAgent, I ran into another issue. I was getting a "Unable to load DLL" error which was confusing at first because I could run the code generated by Model Builder just fine. Then I realized that the issue could be because SingularAgent was using the .NET Framework 4.7.2 instead of .NET. I noticed in the FAQ that it supported the .NET Framework. I decided to report my issue in GitHub but wasn't able to get any response. I decided that it was worthwhile to see if I could successfully upgrade SingularAgent from the .NET Framework to .NET.

I found a Visual Studio extension called .NET Upgrade Assistant and installed it. It was really useful and I was able to complete an in-place project upgrade with minimal issues. I did have to temporarily comment out some code and install some new NuGet packages. A few small bugs crept in as a result of the upgrade but they were quickly stamped out. After updating all of my NuGet packages to the latest version, I found out that I still wasn't able to use machine learning yet because of a new and different error that I was receiving. After reporting this issue to the TorchSharp repository in GitHub, I was alerted to the fact that TorchSharp is in preview. This means that in order to use TorchSharp with ML.NET, you have to use the right version since breaking binary compatibility is possible.  With this in mind, I downgraded TorchSharp to the correct version and was successfully able to use machine learning in SingularAgent.

Machine Learning in SingularAgent

SingularAgent is now able to use these types of machine learning:

Other types of machine learning that the Model Builder supports:

Demo

Recently, I scraped the Indeed website for job postings using SingularAgent. The data that I had scraped included the following columns: Position Name, Salary, Job Type, Company, Rating, Number of Reviews, Location, and Description. I decided that it would be fun to use machine learning to predict the salary of a job solely based on the information in the aforementioned columns.

Before I could use the data for the value prediction, I had to clean the data. This involved doing the following:

Once I had cleaned the data, I separated a random 10 job listings of the data to be my test set and left the remaining to be used for training. Listed below is my demo of the training and prediction process using SingularAgent.

https://www.youtube.com/watch?v=c7W0kktP9rw