You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: samples/fsharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/GitHubLabeler.fsproj
Copy file name to clipboardexpand all lines: samples/fsharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/Labeler.fs
Copy file name to clipboardexpand all lines: samples/fsharp/end-to-end-apps/MulticlassClassification-GitHubLabeler/GitHubLabeler/GitHubLabelerConsoleApp/Program.fs
+7-13
Original file line number
Diff line number
Diff line change
@@ -76,17 +76,11 @@ let buildAndTrainModel dataSetLocation modelPath selectedStrategy =
This is a simple prototype application to demonstrate how to use [ML.NET](https://www.nuget.org/packages/Microsoft.ML/) APIs. The main focus is on creating, training, and using ML (Machine Learning) model that is implemented in Predictor.cs class.
Copy file name to clipboardexpand all lines: samples/fsharp/getting-started/BinaryClassification_CreditCardFraudDetection/CreditCardFraudDetection/CreditCardFraudDetection.fsproj
Copy file name to clipboardexpand all lines: samples/fsharp/getting-started/BinaryClassification_CreditCardFraudDetection/CreditCardFraudDetection/Program.fs
In this introductory sample, you'll see how to use ML.NET to predict a credit card fraud. In the world of machine learning, this type of prediction is known as binary classification.
8
8
@@ -69,38 +69,40 @@ The initial code is similar to the following:
69
69
[...]
70
70
71
71
let trainData, testData =
72
-
let y = mlContext.BinaryClassification.TrainTestSplit(data, 0.2, seed = Nullable 1u)
73
-
y.TrainSet, y.TestSet
72
+
printfn "Reading train and test data"
73
+
let trainData = mlContext.Data.LoadFromTextFile<TransactionObservation>(trainFile, separatorChar = ',', hasHeader = true)
74
+
let testData = mlContext.Data.LoadFromTextFile<TransactionObservation>(testFile, separatorChar = ',', hasHeader = true)
75
+
trainData, testData
74
76
75
77
[...]
76
78
77
79
let featureColumnNames =
78
80
trainData.Schema
79
81
|> Seq.map (fun column -> column.Name)
82
+
|> Seq.filter (fun name -> name <> "Time")
80
83
|> Seq.filter (fun name -> name <> "Label")
81
-
|> Seq.filter (fun name -> name <> "StratificationColumn")
84
+
|> Seq.filter (fun name -> name <> "IdPreservationColumn")
82
85
|> Seq.toArray
83
86
84
87
let pipeline =
85
88
EstimatorChain()
86
-
|> fun x -> x.Append(mlContext.Transforms.Concatenate(DefaultColumnNames.Features, featureColumnNames))
89
+
|> fun x -> x.Append(mlContext.Transforms.Concatenate("Features", featureColumnNames))
87
90
|> fun x -> x.Append(mlContext.Transforms.DropColumns [|"Time"|])
88
91
|> fun x ->
89
92
x.Append (
90
-
mlContext.Transforms.Normalize (
93
+
mlContext.Transforms.NormalizeMeanVariance (
91
94
"FeaturesNormalizedByMeanVar",
92
-
"Features",
93
-
NormalizingEstimator.NormalizerMode.MeanVariance
95
+
"Features"
94
96
)
95
97
)
96
98
|> fun x ->
97
99
x.Append (
98
100
mlContext.BinaryClassification.Trainers.FastTree(
99
101
"Label",
100
102
"FeaturesNormalizedByMeanVar",
101
-
numLeaves = 20,
102
-
numTrees = 100,
103
-
minDatapointsInLeaves = 10,
103
+
numberOfLeaves = 20,
104
+
numberOfTrees = 100,
105
+
minimumExampleCountPerLeaf = 10,
104
106
learningRate = 0.2
105
107
)
106
108
)
@@ -130,12 +132,13 @@ After the model is trained, you can use the `Predict()` API to predict if a tran
0 commit comments