From c13e19ac8227a422b7565caa228353312ead5013 Mon Sep 17 00:00:00 2001 From: feiyun0112 Date: Wed, 26 May 2021 20:09:14 +0800 Subject: [PATCH 1/2] Remove never executed codes --- src/Microsoft.Data.Analysis/GroupBy.cs | 2 +- src/Microsoft.Data.Analysis/StringDataFrameColumn.cs | 2 +- .../DataLoadSave/MultiFileSource.cs | 12 ++++-------- .../Scorers/BinaryClassifierScorer.cs | 2 +- src/Microsoft.ML.Maml/MAML.cs | 12 +----------- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.Data.Analysis/GroupBy.cs b/src/Microsoft.Data.Analysis/GroupBy.cs index 5d8013e9b6..7572e01a9a 100644 --- a/src/Microsoft.Data.Analysis/GroupBy.cs +++ b/src/Microsoft.Data.Analysis/GroupBy.cs @@ -82,7 +82,7 @@ public GroupBy(DataFrame dataFrame, int groupByColumnIndex, IDictionary rows, TKey key, bool firstGroup); diff --git a/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs b/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs index 4faea0ee58..e249f21557 100644 --- a/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs +++ b/src/Microsoft.Data.Analysis/StringDataFrameColumn.cs @@ -374,7 +374,7 @@ private StringDataFrameColumn Clone(PrimitiveDataFrameColumn mapIndices = { if (mapIndices is null) { - StringDataFrameColumn ret = new StringDataFrameColumn(Name, mapIndices is null ? Length : mapIndices.Length); + StringDataFrameColumn ret = new StringDataFrameColumn(Name, Length); for (long i = 0; i < Length; i++) { ret[i] = this[i]; diff --git a/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs b/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs index 3399978f9c..190ee18616 100644 --- a/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs +++ b/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs @@ -45,14 +45,10 @@ public MultiFileSource(params string[] paths) } List concatenated = new List(); - if (paths != null) - { - foreach (string path in paths) - foreach (string rPath in StreamUtils.ExpandWildCards(path)) - concatenated.Add(rPath); - } - else - concatenated = null; + + foreach (string path in paths) + foreach (string rPath in StreamUtils.ExpandWildCards(path)) + concatenated.Add(rPath); if (concatenated != null && concatenated.Count > 0) { diff --git a/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs b/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs index 4ddf832782..336d9daa56 100644 --- a/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs +++ b/src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs @@ -277,7 +277,7 @@ private void GetPredictedLabelCore(float score, ref bool value) private void GetPredictedLabelCoreAsKey(float score, ref uint value) { - value = (uint)(score > _threshold ? 2 : score <= _threshold ? 1 : 0); + value = (uint)(score > _threshold ? 2 : 1); } private protected override JToken PredictedLabelPfa(string[] mapperOutputs) diff --git a/src/Microsoft.ML.Maml/MAML.cs b/src/Microsoft.ML.Maml/MAML.cs index bf342f9014..5d071682ad 100644 --- a/src/Microsoft.ML.Maml/MAML.cs +++ b/src/Microsoft.ML.Maml/MAML.cs @@ -82,18 +82,8 @@ private static int MainWithProgress(string args) private static ConsoleEnvironment CreateEnvironment() { - string sensitivityString = null; MessageSensitivity sensitivity = MessageSensitivity.All; - if (!string.IsNullOrWhiteSpace(sensitivityString)) - { - // Cannot use host or channels since the environment isn't even - // created yet. - if (!Enum.TryParse(sensitivityString, out sensitivity)) - { - Console.Error.WriteLine("Cannot parse '{0}' as {1}", sensitivityString, nameof(MessageSensitivity)); - sensitivity = MessageSensitivity.All; - } - } + return new ConsoleEnvironment(sensitivity: sensitivity); } From 624f422ae0dd04c866eeb042fe0fb7e9f487955d Mon Sep 17 00:00:00 2001 From: feiyun0112 Date: Tue, 8 Jun 2021 15:18:38 +0800 Subject: [PATCH 2/2] Update MultiFileSource.cs --- .../DataLoadSave/MultiFileSource.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs b/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs index 190ee18616..3399978f9c 100644 --- a/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs +++ b/src/Microsoft.ML.Data/DataLoadSave/MultiFileSource.cs @@ -45,10 +45,14 @@ public MultiFileSource(params string[] paths) } List concatenated = new List(); - - foreach (string path in paths) - foreach (string rPath in StreamUtils.ExpandWildCards(path)) - concatenated.Add(rPath); + if (paths != null) + { + foreach (string path in paths) + foreach (string rPath in StreamUtils.ExpandWildCards(path)) + concatenated.Add(rPath); + } + else + concatenated = null; if (concatenated != null && concatenated.Count > 0) {