ML.NET: Credit Card Fraud Detection
The starting point for any ML.NET app is a class named MLContext. It begins by creating a new instance of MLContext class, and when you do so, you have the option to seed for a random number generator.
If you don't specify a seed, you'll get different results each time you train and score the model.
Loading a data set and creating a data pipeline
Preprocessing data in ML.NET is unique and different from other frameworks because it requires an explicit class of our data structure. To do so, we create a class called InputModel, and we will state all the columns of our data set.
For this article, we have used the Credit Card Fraud Detection data set from Kaggle. This data set contains 31 columns. The class of the transaction, either 0 or 1, the amount of the transaction, the time the transaction occurred, and 28 other columns.
Now that we have our data modeled, we need also to model what our output should look like; The below script can achieve this.
The next step should be loading downloaded .csv data; Having defined model input and datafile path, and other constructor options.
Afterward, we will define the data process configuration with pipeline data transformations.
Training and saving the Model
Next, setting the training algorithm and evaluating the quality of the Model.
Usage of the saved model and prediction of credit card fraud are included in program.cs on Github page.