public static bool[] AccordDecide(LogisticRegression lrModel, IDataView input, double threshold) { var convertedInput = IDataViewToAccord(input).inputs; var lrProbability = lrModel.Probabilities(convertedInput); bool[] output = new bool[lrProbability.Length]; for (int i = 0; i < lrProbability.Length; i++) { output[i] = lrProbability[i][1] >= threshold; } return(output); }
private static List <ROCDataPoint> ROCCurve(LogisticRegression accordModel, IDataView data) { var convertedInput = IDataViewToAccord(data).inputs; var lrProbability = accordModel.Probabilities(convertedInput); double[] probabilities = new double[lrProbability.Length]; for (int i = 0; i < probabilities.Length; i++) { probabilities[i] = lrProbability[i][1]; } double[] correctLabels = IDataViewToAccord(data).labels; return(ROCCurve(correctLabels, probabilities)); }
private static void ShowAccordIntermediateData(IDataView input, LogisticRegression accordModel) { var convertedInput = IDataViewToAccord(input).inputs; bool[] lrOutput = accordModel.Decide(convertedInput); var lrScore = accordModel.Scores(convertedInput); var lrProbability = accordModel.Probabilities(convertedInput); var inputEnumerable = mlContext.Data.CreateEnumerable <IDataViewWrapper>(input, true); sw.WriteLine("Label\tScore\tProbability\tPrediction"); int count = 0; foreach (IDataViewWrapper pp in inputEnumerable) { int label = pp.Label ? 1 : 0; int prediction = lrOutput[count] ? 1 : 0; double score = lrScore[count][1]; double probability = lrProbability[count][1]; sw.WriteLine("{0}\t{1}\t{2}\t{3}", label, score, probability, prediction); count++; } sw.Flush(); }