-
-
Save Belgian-Coder/2fae84093101af1654cb35d4492b1a05 to your computer and use it in GitHub Desktop.
Ordina-ML.Net_Recommender_System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BookRecommenderShared.Configuration; | |
using Microsoft.ML; | |
using Microsoft.ML.Data; | |
using System; | |
using System.IO; | |
namespace BookRecommenderTrainer | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var mlContext = new MLContext(); | |
var reader = mlContext.Data.CreateTextReader(new TextLoader.Arguments() | |
{ | |
Separator = ",", | |
HasHeader = true, | |
/* | |
* Define the columns to read be from the csv. | |
* The indeces are based on the position in the csv file and will receive a new index. | |
* DataKind is defined as R4 (floating point) instead of integer | |
* Computers are optimized for processing floating point calculations | |
* so this will not create performance issues but mitigates some possible issues | |
*/ | |
Column = new[] | |
{ | |
new TextLoader.Column(Labels.Label, DataKind.R4, 1), // new index 0 | |
new TextLoader.Column(Labels.User, DataKind.R4, 2), // new index 1 | |
new TextLoader.Column(Labels.BookId, DataKind.R4, 3) // new index 2 | |
} | |
}); | |
var data = reader.Read(Path.Combine(Environment.CurrentDirectory, Filenames.DataFolder, Filenames.RatingsDataset)); | |
// Split our dataset in 80% training data and 20% testing data to evaluate our model | |
var (trainData, testData) = mlContext.BinaryClassification.TrainTestSplit(data, testFraction: 0.2); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment