public static IEstimator <ITransformer> _NormalizeLpNorm(this MLContext MLContext, JToken componentObject) { string outputColumn = componentObject.Value <string>("OutputColumnName"); string inputColumn = componentObject.Value <string>("InputColumnName"); NormFunction normFunction = Enum.Parse <NormFunction>(componentObject.Value <string>("NormFunction")); bool ensureZeroMean = componentObject.Value <bool>("EnsureZeroMean"); return(MLContext.Transforms.NormalizeLpNorm(outputColumn, inputColumn, normFunction, ensureZeroMean)); }
public TransformApplierParams(TextFeaturizingEstimator parent) { var host = parent._host; host.Check(Enum.IsDefined(typeof(Language), parent.OptionalSettings.Language)); host.Check(Enum.IsDefined(typeof(CaseMode), parent.OptionalSettings.CaseMode)); WordExtractorFactory = parent._wordFeatureExtractor?.CreateComponent(host, parent._dictionary); CharExtractorFactory = parent._charFeatureExtractor?.CreateComponent(host, parent._dictionary); Norm = parent.OptionalSettings.Norm; Language = parent.OptionalSettings.Language; UsePredefinedStopWordRemover = parent.OptionalSettings.UsePredefinedStopWordRemover; TextCase = parent.OptionalSettings.CaseMode; KeepDiacritics = parent.OptionalSettings.KeepDiacritics; KeepPunctuations = parent.OptionalSettings.KeepPunctuations; KeepNumbers = parent.OptionalSettings.KeepNumbers; OutputTextTokens = parent.OptionalSettings.OutputTokens; Dictionary = parent._dictionary; }
internal static List <List <double> > NormalizeArray(List <List <double> > inArray, NormFunction func, bool DaedalusTrainingSet = true) { if (func == null) { func = MinMaxNorm; } List <List <Double> > ret = new List <List <double> >(inArray.Count); if (DaedalusTrainingSet || Stats == null)///get the stats from the array, and use it for all resulting data (eg, get stats from training set and then apply it to testing set) { Stats = new List <List <double> >(); for (int i = 0; i < inArray[0].Count; ++i) { double[] column = Util.Flatten2dArray(pullColumnFromArray(inArray, i)); Stats.Add(GetStats(column)); } } else { //Testing set- get min and max from testing set for (int i = 0; i < inArray[0].Count; ++i) { double[] column = Util.Flatten2dArray(pullColumnFromArray(inArray, i)); List <Double> temp = GetStats(column); Stats[i][Mins] = Math.Min(temp[Mins], Stats[i][Mins]); Stats[i][Maxes] = Math.Max(temp[Maxes], Stats[i][Maxes]); } } foreach (List <Double> l in inArray) { ret.Add(func(l, Stats)); } return(ret); }