public VectorData GetVector(IProcessingTextBlock normalBlock, NormalizationType normalization) { var normal = styleFactory.ConstructTextBlock(normalBlock.Sentences); DataTree tree; switch (anomalyVectorType) { case AnomalyVectorType.Full: tree = new DataTree(normal, MapFull); break; case AnomalyVectorType.Inquirer: tree = normal.InquirerFinger.InquirerProbabilities; break; case AnomalyVectorType.SentimentCategory: tree = GetTree(normal); break; default: throw new ArgumentOutOfRangeException("AnomalyVectorType"); } VectorData vector = tree.CreateVector(normalization); return(vector); }
public static List <string> NormalizeSentence(string sentence, NormalizationType type = NormalizationType.SEARCH) { return(Normaliser.GetService <List <string> >(new NormalizeRequest() { sentence = sentence, type = type })); }
/// <summary> /// Сгенерировать нейроны сети. /// </summary> /// <param name="attributes">Количество параметров входящего вектора.</param> /// <param name="neuronsCount">Количество нейронов.</param> public void GenerateNeurons(List <NetworkAttribute> attributes, int neuronsCount) { Neurons.Clear(); Weights.Clear(); InputAttributes.Clear(); InputAttributes.AddRange(attributes.Select(a => new InputAttributeBase { InputAttributeNumber = a.OrderNumber, Name = a.Name }) .ToList()); for (int i = 0; i < neuronsCount; i++) { Neurons.Add(new NeuronBase { NeuronNumber = i }); } foreach (var inputAttribute in InputAttributes) { foreach (var neuron in Neurons) { var randomWeight = NormalizationType.GetNeuronWeight(attributes.Count); Weights.Add(new WeightBase { InputAttributeNumber = inputAttribute.InputAttributeNumber, NeuronNumber = neuron.NeuronNumber, Value = randomWeight }); } } }
public static List <string> NormalizeWords(string[] words, NormalizationType type = NormalizationType.SEARCH) { return(Normaliser.GetService <List <string> >(new NormalizeRequest() { words = words, type = type })); }
public static List <List <string> > NormalizeText(string text, NormalizationType type = NormalizationType.SEARCH) { return(Normaliser.GetService <List <List <string> > >(new NormalizeRequest() { text = text })); }
private double[,] NormalizeData(double[,] datSetToNormalize, NormalizationType normalizationType, int numberOfInputs) { _normalizationStrategy = _normalizationStrategyFactory.CreateNormalizationStrategy(normalizationType); var normalizedDataSet = _normalizationStrategy.NormalizeData(datSetToNormalize, numberOfInputs); return(normalizedDataSet); }
/// <summary> /// Create DAISY descriptor extractor /// </summary> /// <param name="radius">Radius of the descriptor at the initial scale.</param> /// <param name="qRadius">Amount of radial range division quantity.</param> /// <param name="qTheta">Amount of angular range division quantity.</param> /// <param name="qHist">Amount of gradient orientations range division quantity.</param> /// <param name="norm">Descriptors normalization type.</param> /// <param name="H">optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image</param> /// <param name="interpolation">Switch to disable interpolation for speed improvement at minor quality loss</param> /// <param name="useOrientation">Sample patterns using keypoints orientation, disabled by default.</param> public DAISY(float radius = 15, int qRadius = 3, int qTheta = 8, int qHist = 8, NormalizationType norm = NormalizationType.None, IInputArray H = null, bool interpolation = true, bool useOrientation = false) { using (InputArray iaH = H == null ? InputArray.GetEmpty() : H.GetInputArray()) _ptr = XFeatures2DInvoke.cveDAISYCreate(radius, qRadius, qTheta, qHist, norm, iaH, interpolation, useOrientation, ref _feature2D); }
/// <summary> /// Create DAISY descriptor extractor /// </summary> /// <param name="radius">Radius of the descriptor at the initial scale.</param> /// <param name="qRadius">Amount of radial range division quantity.</param> /// <param name="qTheta">Amount of angular range division quantity.</param> /// <param name="qHist">Amount of gradient orientations range division quantity.</param> /// <param name="norm">Descriptors normalization type.</param> /// <param name="H">optional 3x3 homography matrix used to warp the grid of daisy but sampling keypoints remains unwarped on image</param> /// <param name="interpolation">Switch to disable interpolation for speed improvement at minor quality loss</param> /// <param name="useOrientation">Sample patterns using keypoints orientation, disabled by default.</param> public DAISY(float radius = 15, int qRadius = 3, int qTheta = 8, int qHist = 8, NormalizationType norm = NormalizationType.None, IInputArray H = null, bool interpolation = true, bool useOrientation = false) { using (InputArray iaH = H == null ? InputArray.GetEmpty() : H.GetInputArray()) _ptr = ContribInvoke.cveDAISYCreate(radius, qRadius, qTheta, qHist, norm, iaH, interpolation, useOrientation, ref _feature2D); }
} // serialization only public SelfOrganizingMap(int inputCount, int outputCount, NormalizationType normalizationType) : this() { InputNeuronCount = inputCount; OutputNeuronCount = outputCount; OutputWeights = new Matrix(OutputNeuronCount, InputNeuronCount + 1); Output = new double[OutputNeuronCount]; NormalizationType = normalizationType; }
/// <summary> /// The constructor. /// </summary> /// <param name="inputCount">Number of input neurons.</param> /// <param name="outputCount">Number of output neurons.</param> /// <param name="normalizationType">The normalization type.</param> public SelfOrganizingMap(int inputCount, int outputCount, NormalizationType normalizationType) { this.inputNeuronCount = inputCount; this.outputNeuronCount = outputCount; this.outputWeights = new Matrix.Matrix(this.outputNeuronCount, this.inputNeuronCount + 1); this.output = new double[this.outputNeuronCount]; this.normalizationType = normalizationType; }
internal SelfOrganizingMap() { } // serialization only public SelfOrganizingMap(int inputCount, int outputCount, NormalizationType normalizationType) : this() { InputNeuronCount = inputCount; OutputNeuronCount = outputCount; OutputWeights = new Matrix(OutputNeuronCount, InputNeuronCount + 1); Output = new double[OutputNeuronCount]; NormalizationType = normalizationType; }
public double[,] PreProcessData(string[,] rawDataSet, NormalizationType normalizationType, int numberOfInputs, EncodingType encodingType, int[] columnIndexesToEncode) { var rawEncodedDataSet = EncodeData(rawDataSet, encodingType, columnIndexesToEncode); var encodedDataSet = ParseDataSetToDouble(rawEncodedDataSet); var normalizedAndEncodedDataSet = NormalizeData(encodedDataSet, normalizationType, numberOfInputs); return(normalizedAndEncodedDataSet); }
public static VectorData CreateVector(this IDataTree tree, NormalizationType normalization) { if (tree is null) { throw new ArgumentNullException(nameof(tree)); } List <SimpleCell> vectors = new List <SimpleCell>(); CreateVector("Data", tree, vectors); vectors = vectors.OrderBy(item => item.Name).ToList(); return(new VectorDataFactory().CreateSimple(normalization, vectors.Select(item => (ICell)item).ToArray())); }
public ANNParameters() { // m_LearningAlgo = LearningAlgoritm.BP; m_PSOParameters = new PSOParameters(); m_IsClasificationProblem = false; m_Momentum = 0.4; m_inputNormalization = NormalizationType.MinMax; m_outputNormalization = NormalizationType.MinMax; m_ActFunction = new Sigmoid(1.0); m_ActFuncParam1 = 1.0; m_LearningRate = 0.1; m_NumHiddenLayers = 1; m_NeuronsInHiddenLayer = 50; }
public IDataNormalizationStrategy CreateNormalizationStrategy(NormalizationType normalizationType) { switch (normalizationType) { case NormalizationType.None: return(new NoNormalization()); case NormalizationType.Gaussian: return(new Gaussian()); case NormalizationType.MinMax: return(new MinMax()); case NormalizationType.NegativePositiveMinMax: return(new NegativePositiveMinMax()); default: return(new NoNormalization()); } }
//glennj 6/21/2013 /// <summary> /// Set the normalized type for imported waveforms. /// </summary> /// <param name="awg">specific awg object</param> /// <param name="type">Normalize type</param> public void SetTheNormalizationValueOfDataToBeOpened(IAWG awg, NormalizationType type) { string requiredSyntax; switch (type) { case NormalizationType.None: requiredSyntax = "NONE"; awg.SetMemoryOpenNormalize(requiredSyntax); break; case NormalizationType.FullRange: requiredSyntax = "FSC"; awg.SetMemoryOpenNormalize(requiredSyntax); break; case NormalizationType.PreserveOffset: requiredSyntax = "ZREF"; awg.SetMemoryOpenNormalize(requiredSyntax); break; } }
private void PageListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender != null) { ((ChildPage)(((ListBox)sender).Parent)).IsOpen = false; if (((ListBox)sender).Tag != null) { if (((ListBox)sender).Tag.ToString().Equals("ClassificationMethod")) { ClassificationMethod method = (ClassificationMethod)(sender as ListBox).SelectedItem; IntervalButton.IsEnabled = (method == ClassificationMethod.StandardDeviation) ? true : false; BreakCountTB.IsEnabled = (method == ClassificationMethod.StandardDeviation) ? false : true; } else if (((ListBox)sender).Tag.ToString().Equals("NormalizationType")) { NormalizationType normType = (NormalizationType)(sender as ListBox).SelectedItem; NormalizationFieldButton.IsEnabled = (normType == NormalizationType.Field) ? true : false; } } } }
public NormalizeInput(double[] input, NormalizationType type) { Type = type; CalculateFactors(input); InputMatrix = CreateInputMatrix(input, SyntheticInput); }
private static ImageInput[] GetImageInputs(IList<FeatureRecognizer_Image> images, int maxInputs, NormalizationType normalizationType, Func<FeatureRecognizer_Image, double[]> getValueFromImage) { return UtilityCore.RandomOrder(images, maxInputs). AsParallel(). Select(o => { double[] values = getValueFromImage(o); double[] normalized = GetNormalizedVector(values, normalizationType); return new ImageInput(o, values, normalized); }). ToArray(); }
/// <summary> /// Load experiment from file /// </summary> /// <param name="filePath"></param> /// <param name="delimeter"></param> /// <param name="normalizationType"></param> /// <returns></returns> private List <ColumnData> LoadDataFromFile(string filePath, char delimeter = ';', NormalizationType normalizationType = NormalizationType.Gauss) { try { //define the row string[] rows = GetRowsFromText(filePath, delimeter); //Define the columns var colCount = rows[0].Split(delimeter).Count(); var rowCount = rows.Length; string[][] strdata = new string[colCount][]; //Transform experimental data from row->col in to col->ros for (int i = 0; i < colCount; i++) { strdata[i] = new string[rows.Length]; for (int j = 0; j < rowCount; j++) { var row = rows[j].Split(delimeter); strdata[i][j] = row[i]; } } //Contruct exprerimental data var colsData = new List <ColumnData>(); for (int i = 0; i < colCount; i++) { var isOutput = i + 1 >= colCount; ColumnData col = new ColumnData(isOutput); col.SetData(strdata[i], normalizationType); colsData.Add(col); } return(colsData); } catch (Exception) { throw; } }
/// <summary> /// Main method for Experiment initialization. It requires train and test data. Test data can be null /// </summary> /// <param name="trainData"></param> /// <param name="testData"></param> /// <param name="normalization"></param> public void InitExperiment(double[][] trainData, double[][] testData, NormalizationType normalization = NormalizationType.Gauss) { try { // m_trainData = new List <ColumnData>(); for (int j = 0; j < trainData[0].Length; j++) { bool isOutput = false; if (j + 1 == trainData[0].Length) { isOutput = true; } ColumnData dat = new ColumnData(isOutput); var col = new string[trainData.Length]; for (int i = 0; i < trainData.Length; i++) { col[i] = trainData[i][j].ToString(); } dat.SetData(col, normalization); m_trainData.Add(dat); } if (testData != null) { m_testData = new List <ColumnData>(); for (int j = 0; j < testData[0].Length; j++) { bool isOutput = false; if (j + 1 == testData[0].Length) { isOutput = true; } ColumnData dat = new ColumnData(isOutput); var col = new string[testData.Length]; for (int i = 0; i < testData.Length; i++) { col[i] = testData[i][j].ToString(); } dat.SetData(col, normalization); m_testData.Add(dat); } } // m_testData = testData; //code data and calculate statistic InitiaizeData(); InitiaizeTestData(); } catch (Exception) { throw; } }
public static string NormalizeWord(string word, NormalizationType type) { return(NormalizeWords(new string[] { word }, type)[0]); }
private static double[] GetNormalizedVector(double[] vector, NormalizationType normalizationType) { switch (normalizationType) { case NormalizationType.None: return vector; case NormalizationType.Normalize: return MathND.Normalize(vector); case NormalizationType.ToUnit: return MathND.ToUnit(vector, false); default: throw new ApplicationException("Unknown NormalizationType: " + normalizationType.ToString()); } }
/// <summary> /// Normalize an input array into a matrix. The resulting matrix will have /// one extra column that will be occupied by the synthetic input. /// </summary> /// <param name="input">The input array to be normalized.</param> /// <param name="type">What type of normalization to use.</param> public NormalizeInput(double[] input, NormalizationType type) { this.type = type; CalculateFactors(input); this.inputMatrix = this.CreateInputMatrix(input, this.synth); }
public double GetDistance(Extractor pattern, NormalizationType normalization) { CalculateLocalDistances(pattern); int signalSize = from.GetFramesCount(); int patternSize = pattern.GetFramesCount(); DtwPoint top = new DtwPoint(); DtwPoint center = new DtwPoint(); DtwPoint bottom = new DtwPoint(); DtwPoint previous = new DtwPoint(); for (int i = 1; i < signalSize; ++i) { for (int j = 1; j < patternSize; ++j) { center = points[i - 1][j - 1]; if (PassType.Neighbors == passType) { top = points[i - 1][j]; bottom = points[i][j - 1]; } else // Diagonals { if (i > 1 && j > 1) { top = points[i - 2][j - 1]; bottom = points[i - 1][j - 2]; } else { top = points[i - 1][j]; bottom = points[i][j - 1]; } } if (top.dAccumulated < center.dAccumulated) { previous = top; } else { previous = center; } if (bottom.dAccumulated < previous.dAccumulated) { previous = bottom; } points[i][j].dAccumulated = points[i][j].dLocal + previous.dAccumulated; points[i][j].previous = previous; } } double distance = points[signalSize - 1][patternSize - 1].dAccumulated; switch (normalization) { case NormalizationType.Diagonal: distance /= Math.Sqrt(signalSize * signalSize + patternSize * patternSize); break; case NormalizationType.SumOfSides: distance /= signalSize + patternSize; break; case NormalizationType.NoNormalization: default: break; } return(distance); }
public double GetDistance(Extractor pattern, NormalizationType normalization) { CalculateLocalDistances(pattern); int signalSize = from.GetFramesCount(); int patternSize = pattern.GetFramesCount(); DtwPoint top = new DtwPoint(); DtwPoint center = new DtwPoint(); DtwPoint bottom = new DtwPoint(); DtwPoint previous = new DtwPoint(); for (int i = 1; i < signalSize; ++i) { for (int j = 1; j < patternSize; ++j) { center = points[i - 1][j - 1]; if (PassType.Neighbors == passType) { top = points[i - 1][j]; bottom = points[i][j - 1]; } else // Diagonals { if (i > 1 && j > 1) { top = points[i - 2][j - 1]; bottom = points[i - 1][j - 2]; } else { top = points[i - 1][j]; bottom = points[i][j - 1]; } } if (top.dAccumulated < center.dAccumulated) previous = top; else previous = center; if (bottom.dAccumulated < previous.dAccumulated) previous = bottom; points[i][j].dAccumulated = points[i][j].dLocal + previous.dAccumulated; points[i][j].previous = previous; } } double distance = points[signalSize - 1][patternSize - 1].dAccumulated; switch (normalization) { case NormalizationType.Diagonal: distance /= Math.Sqrt(signalSize *signalSize + patternSize *patternSize); break; case NormalizationType.SumOfSides: distance /= signalSize + patternSize; break; case NormalizationType.NoNormalization: default: break; } return distance; }
public static double[][] GetVectors(this IDocumentVectorSource source, IProcessingTextBlock[] blocks, NormalizationType normalization) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (blocks == null) { throw new ArgumentNullException(nameof(blocks)); } double[][] observations = new double[blocks.Length][]; Parallel.For(0, blocks.Length, i => { var result = source.GetVector(blocks[i], normalization).FullValues; observations[i] = result; }); return(observations); }
public void PreProcessDataSet(NormalizationType normalizationType, int numberOfInputs, EncodingType encodingType, int[] columnIndicesToEncode) { _dataSet = _dataPreProcessor.PreProcessData(_rawDataSet, normalizationType, numberOfInputs, encodingType, columnIndicesToEncode); }
public VectorData GetVector(IProcessingTextBlock textBlock, NormalizationType normalization) { var currentVector = model.GetParagraphVector(textBlock.Sentences); return(vectorDataFactory.CreateSimple(normalization, Convert(currentVector))); }
/// <summary> /// Set values for the Column in string format, by passing the normalization type /// </summary> /// <param name="cols"></param> /// <param name="normalization"></param> internal void SetData(string[] cols, NormalizationType normalization = NormalizationType.MinMax) { m_normalizationType = normalization; m_RealValues = new string[cols.Length]; Array.Copy(cols, this.m_RealValues, cols.Length); }
private void NormalizationTypeCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { NormalizationType normType = (NormalizationType)(sender as ComboBox).SelectedItem; NormalizationFieldCombo.IsEnabled = (normType == NormalizationType.Field) ? true : false; }
internal void SetNormalization(NormalizationType normalizationType) { m_normalizationType = normalizationType; }
/// <summary> /// Given an expected value, compare it to the updated copy of<para> /// import_parameter_normalize of the given awg</para> /// </summary> /// <param name="awg"></param> /// <param name="command"></param> /// <param name="expectedValue"></param> public void NormalizationValueOfDataTypeShouldBe(IAWG awg, NormalizationCommand command, NormalizationType expectedValue) { string interpretedValue = ""; string awgCopy = (command == NormalizationCommand.Import ? awg.MassMemoryImportParameterNormalize : awg.MassMemoryOpenParameterNormalize); switch (expectedValue) { case NormalizationType.None: interpretedValue = "NONE"; break; case NormalizationType.FullRange: interpretedValue = "FSC"; break; case NormalizationType.PreserveOffset: interpretedValue = "ZREF"; break; } Assert.AreEqual(interpretedValue, awgCopy); }
/// <summary> /// Perform a normalization round on this filter instance /// using the specified normalization method /// </summary> /// <param name="type"> Normalization method </param> public void Normalize(NormalizationType type) { float factor = 0.0f; switch (type) { case NormalizationType.SumDivide: factor = Kernel.Sum(); break; case NormalizationType.AbsSumDivide: factor += Kernel.Sum(k => Math.Abs(k)); break; } if (NeedNormalize(factor)) Multiply(1.0f / factor); }
public static VectorData GetVector(this SentimentVector vector, NormalizationType normalization) { return(vector.GetTree(false).CreateVector(normalization, false)); }