|
7 | 7 | using System.Globalization;
|
8 | 8 | using System.IO;
|
9 | 9 | using System.Linq;
|
10 |
| -using System.Runtime.Serialization.Formatters.Binary; |
11 | 10 | using System.Text.RegularExpressions;
|
12 | 11 | using Microsoft.ML.Command;
|
13 | 12 | using Microsoft.ML.CommandLine;
|
@@ -1001,166 +1000,14 @@ protected static KeyValuePair<int, Dictionary<string, float>> AddFoldResults(ILi
|
1001 | 1000 | return new KeyValuePair<int, Dictionary<string, float>>(foldIdx, valuesDict);
|
1002 | 1001 | }
|
1003 | 1002 |
|
1004 |
| - /// <summary> |
1005 |
| - /// Makes a deep clone of the list of PredictorResultList Object |
1006 |
| - /// </summary> |
1007 |
| - /// <param name="predictorResultList">List of PredictorResult Object</param> |
1008 |
| - /// <returns>A new instance of List of PredictorResult</returns> |
1009 |
| - public static List<PredictorResult> ClonePredictorResultList(List<PredictorResult> predictorResultList) |
1010 |
| - { |
1011 |
| - MemoryStream ms = new MemoryStream(); |
1012 |
| - Save(predictorResultList, ms); //save the object in Memory stream |
1013 |
| - ms.Seek(0, SeekOrigin.Begin); |
1014 |
| - return Load(ms) as List<PredictorResult>; // load the object from memory stream |
1015 |
| - } |
1016 |
| - |
1017 |
| - /// <summary> |
1018 |
| - /// Makes a deep clone of the list of PredictorResult Object |
1019 |
| - /// </summary> |
1020 |
| - /// <param name="predictorItem"></param> |
1021 |
| - /// <returns></returns> |
1022 |
| - public static PredictorResult ClonePredictorResult(PredictorResult predictorItem) |
1023 |
| - { |
1024 |
| - MemoryStream ms = new MemoryStream(); |
1025 |
| - Save(predictorItem, ms); //save the object in Memory stream |
1026 |
| - ms.Seek(0, SeekOrigin.Begin); |
1027 |
| - return Load(ms) as PredictorResult; |
1028 |
| - } |
1029 |
| - |
1030 |
| - /// <summary> |
1031 |
| - /// Save the List of Predictor object in Memory |
1032 |
| - /// </summary> |
1033 |
| - /// <param name="predictor">List of PredictorResult Object</param> |
1034 |
| - /// <param name="stream">Memory stream object</param> |
1035 |
| - private static void Save(List<PredictorResult> predictor, Stream stream) |
1036 |
| - { |
1037 |
| - BinaryFormatter bf = new BinaryFormatter(); |
1038 |
| - bf.Serialize(stream, predictor); |
1039 |
| - if (stream is MemoryStream) |
1040 |
| - stream.Flush(); |
1041 |
| - else |
1042 |
| - stream.Close(); |
1043 |
| - } |
1044 |
| - |
1045 |
| - /// <summary> |
1046 |
| - /// Save the List of Predictor object in Memory |
1047 |
| - /// </summary> |
1048 |
| - /// <param name="predictor">List of PredictorResult Object</param> |
1049 |
| - /// <param name="stream">Memory stream object</param> |
1050 |
| - private static void Save(PredictorResult predictor, Stream stream) |
1051 |
| - { |
1052 |
| - BinaryFormatter bf = new BinaryFormatter(); |
1053 |
| - bf.Serialize(stream, predictor); |
1054 |
| - if (stream is MemoryStream) |
1055 |
| - stream.Flush(); |
1056 |
| - else |
1057 |
| - stream.Close(); |
1058 |
| - } |
1059 |
| - |
1060 |
| -#if TLCFULLBUILD |
1061 |
| - /// <summary> |
1062 |
| - /// Create a experiment visualization object from experiment result. |
1063 |
| - /// </summary> |
1064 |
| - private static Experiment CreateVisualizationExperiment(ExperimentItemResult result, int index) |
1065 |
| - { |
1066 |
| - var experiment = new ML.Runtime.ExperimentVisualization.Experiment |
1067 |
| - { |
1068 |
| - Key = index.ToString(), |
1069 |
| - CompareGroup = string.IsNullOrEmpty(result.CustomizedTag) ? result.TrainerKind : result.CustomizedTag, |
1070 |
| - Trainer = new ML.Runtime.ExperimentVisualization.Trainer |
1071 |
| - { |
1072 |
| - Name = result.TrainerKind, |
1073 |
| - ParameterSets = new List<ML.Runtime.ExperimentVisualization.Item>() |
1074 |
| - }, |
1075 |
| - DataSet = new ML.Runtime.ExperimentVisualization.DataSet { File = result.Datafile }, |
1076 |
| - TestDataSet = new ML.Runtime.ExperimentVisualization.DataSet { File = result.TestDatafile }, |
1077 |
| - Tool = "TLC", |
1078 |
| - RawCommandLine = result.Commandline, |
1079 |
| - Results = new List<ML.Runtime.ExperimentVisualization.ExperimentResult>() |
1080 |
| - }; |
1081 |
| - |
1082 |
| - // Propagate metrics to the report. |
1083 |
| - ML.Runtime.ExperimentVisualization.ExperimentResult metrics = new ML.Runtime.ExperimentVisualization.ExperimentResult |
1084 |
| - { |
1085 |
| - Metrics = new List<ML.Runtime.ExperimentVisualization.MetricValue>(), |
1086 |
| - Build = "TLC" |
1087 |
| - }; |
1088 |
| - foreach (KeyValuePair<string, ResultMetric> resultEntity in result.Results) |
1089 |
| - { |
1090 |
| - metrics.Metrics.Add(new ML.Runtime.ExperimentVisualization.MetricValue |
1091 |
| - { |
1092 |
| - Name = resultEntity.Key, |
1093 |
| - Value = resultEntity.Value.MetricValue, |
1094 |
| - StandardDeviation = resultEntity.Value.Deviation |
1095 |
| - }); |
1096 |
| - } |
1097 |
| - |
1098 |
| - metrics.Metrics.Add(new ML.Runtime.ExperimentVisualization.MetricValue |
1099 |
| - { |
1100 |
| - Name = "Time Elapsed(s)", |
1101 |
| - Value = result.Time |
1102 |
| - }); |
1103 |
| - |
1104 |
| - metrics.Metrics.Add(new ML.Runtime.ExperimentVisualization.MetricValue |
1105 |
| - { |
1106 |
| - Name = "Physical Memory Usage(MB)", |
1107 |
| - Value = result.PhysicalMemory |
1108 |
| - }); |
1109 |
| - |
1110 |
| - metrics.Metrics.Add(new ML.Runtime.ExperimentVisualization.MetricValue |
1111 |
| - { |
1112 |
| - Name = "Virtual Memory Usage(MB)", |
1113 |
| - Value = result.VirtualMemory |
1114 |
| - }); |
1115 |
| - |
1116 |
| - // Propagate experiment arguments to the report. |
1117 |
| - foreach (KeyValuePair<string, string> setting in result.Settings) |
1118 |
| - { |
1119 |
| - string val; |
1120 |
| - if (result.Settings.TryGetValue(setting.Key, out val)) |
1121 |
| - { |
1122 |
| - experiment.Trainer.ParameterSets.Add(new ML.Runtime.ExperimentVisualization.Item |
1123 |
| - { |
1124 |
| - Name = setting.Key.Substring(1), |
1125 |
| - Value = val |
1126 |
| - }); |
1127 |
| - double doubleVal; |
1128 |
| - if (Double.TryParse(val, out doubleVal)) |
1129 |
| - { |
1130 |
| - metrics.Metrics.Add(new ML.Runtime.ExperimentVisualization.MetricValue |
1131 |
| - { |
1132 |
| - Name = setting.Key, |
1133 |
| - Value = doubleVal |
1134 |
| - }); |
1135 |
| - } |
1136 |
| - } |
1137 |
| - } |
1138 |
| - |
1139 |
| - experiment.Results.Add(metrics); |
1140 |
| - |
1141 |
| - return experiment; |
1142 |
| - } |
1143 |
| -#endif |
1144 |
| - |
1145 |
| - /// <summary> |
1146 |
| - /// Deserialize a predictor, returning as an object |
1147 |
| - /// </summary> |
1148 |
| - private static object Load(Stream stream) |
1149 |
| - { |
1150 |
| - BinaryFormatter bf = new BinaryFormatter(); |
1151 |
| - object o = bf.Deserialize(stream); |
1152 |
| - stream.Close(); |
1153 |
| - return o; |
1154 |
| - } |
1155 |
| - |
1156 | 1003 | public static int Main(string[] args)
|
1157 | 1004 | {
|
1158 | 1005 | string currentDirectory = Path.GetDirectoryName(typeof(ResultProcessor).Module.FullyQualifiedName);
|
1159 | 1006 | var env = new ConsoleEnvironment(42);
|
1160 | 1007 | #pragma warning disable CS0618 // The result processor is an internal command line processing utility anyway, so this is, while not great, OK.
|
1161 | 1008 | using (AssemblyLoadingUtils.CreateAssemblyRegistrar(env, currentDirectory))
|
1162 | 1009 | #pragma warning restore CS0618
|
1163 |
| - return Main(env, args); |
| 1010 | + return Main(env, args); |
1164 | 1011 | }
|
1165 | 1012 |
|
1166 | 1013 | public static int Main(IHostEnvironment env, string[] args)
|
|
0 commit comments