Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SeedRandom[0];
- n = 10000;
- X = RandomReal[{-1, 1}, {n, 100, 5}];
- Y = RandomInteger[{0, 1}, n];
- SeedRandom[0];
- netT = NetTrain[
- net,
- X -> Y,
- All,
- LossFunction -> CrossEntropyLossLayer["Index"],
- BatchSize -> 64, MaxTrainingRounds -> 10, TargetDevice -> "GPU"
- ]
- SeedRandom[0];
- netT = NetTrain[
- net,
- X -> Y,
- All,
- LossFunction -> CrossEntropyLossLayer["Index"],
- BatchSize -> 64, MaxTrainingRounds -> 10, TargetDevice -> "GPU"
- ]
- cm = ClassifierMeasurements[netT["TrainedNet"], X -> Y]
- cm["ConfusionMatrixPlot"]
- cm["Precision"]
- cm["Recall"]
- proba = netT["TrainedNet"][X, "Probabilities"];
- proba0 = Lookup[proba, 0];
- proba1 = Lookup[proba, 1];
- Table[
- {
- Select[Pick[proba0, Y, 0], # >= i &] // Length,
- Select[Pick[proba0, Y, 1], # >= i &] // Length
- } // {i, ##, N[#[[1]]/(#[[1]] + #[[2]])]} &,
- {i, 0.5, 0.7, 0.01}
- ] // MatrixForm
- Table[
- {
- Select[Pick[proba0, Y, 0], # >= i &] // Length,
- Select[Pick[proba0, Y, 1], # >= i &] // Length
- } // {i, ##, N[#[[1]]/(#[[1]] + #[[2]])]} &,
- {i, 0.5, 0.7, 0.01}
- ] // MatrixForm
- PairedHistogram[Pick[proba1, Y, 1], Pick[proba1, Y, 0]]
- Table[
- {
- Select[Pick[proba1, Y, 1], # >= i &] // Length,
- Select[Pick[proba1, Y, 0], # >= i &] // Length
- } // {i, ##, N[#[[1]]/(#[[1]] + #[[2]])]} &,
- {i, 0.5, 0.7, 0.01}
- ] // MatrixForm
- EV[p_] := p*80 - (1 - p)*100 - 4
- Plot[
- {
- Select[Pick[proba1, Y, 1], # >= x &] // Length,
- Select[Pick[proba1, Y, 0], # >= x &] // Length
- } // EV[#[[1]]/(#[[1]] + #[[2]])]*(#[[1]] + #[[2]]) &,
- {x, 0.5, 0.7}
- ]
- Plot[
- {
- Select[Pick[proba1, Y, 1], # >= x &] // Length,
- Select[Pick[proba1, Y, 0], # >= x &] // Length
- } // EV[#[[1]]/(#[[1]] + #[[2]])]*(#[[1]] + #[[2]]) &,
- {x, 0.5, 0.7}
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement