//Initialize by creating random seed centroids and starting the method cascade
    public void Init(int k, List <Vector3> input)
    {
        _simpleDataModel = new SimpleDatamodel();
        Clustering       = true;

        NumberOfClusters();
        NumberOfLoops();

        k = K;

        if (_distanceMatrix != null)
        {
            Array.Clear(_distanceMatrix, 0, _distanceMatrix.Length);
            Array.Clear(_clusterMatrix, 0, _clusterMatrix.Length);
        }

        _distanceMatrix = new float[k + 1, input.Count + 1];
        _clusterMatrix  = new Vector3[k + 1, input.Count + 1];

        //get the range of the input data
        var minVector = Vector3.positiveInfinity;
        var maxVector = Vector3.zero;

        for (var i = 0; i < input.Count; i++)
        {
            minVector = input[i].magnitude < minVector.magnitude ?  input[i] : minVector;
            maxVector = input[i].magnitude > maxVector.magnitude ?  input[i] : maxVector;
        }

        var xMin = minVector.x;
        var yMin = minVector.y;
        var zMin = minVector.z;
        var xMax = maxVector.x;
        var yMax = maxVector.y;
        var zMax = maxVector.z;

        //set the centroids randomly inside the range of the input (minmax)
        for (var i = 0; i < K; i++)
        {
            var randomX = Random.Range(xMin, xMax);
            var randomY = Random.Range(yMin, yMax);
            var randomZ = Random.Range(zMin, zMax);

            var tempRandom = new Vector3(randomX, randomY, randomZ);
            _centroids.Add(tempRandom);
        }

        CalculateDistances();
    }
    public override bool Process()
    {
        float[][] data      = generateData();
        var       dataModel = new SimpleDatamodel(); // ReadCsv().MergeDatamodels(_rawInputData);

        dataModel.addFloatMatrixColwise(data);
        SetOutputData(dataModel);

        // Transform data into dataModel here.

        // add here data generation
        // Analog to Dataloader:
        // var dataModel = ReadCsv().MergeDatamodels(_rawInputData);
        // SetOutputData(dataModel);

        return(true);
    }
        public void SplitDataset()
        {
            for (int i = 0; i < _simpleDataModels.Length; i++)
            {
                _simpleDataModels[i] = new SimpleDatamodel();
            }
            foreach (var dataItem in _dataItems)
            {
                if (axis == "X")
                {
                    if (dataItem.GetfirstThreeNumericColsAsVector().x >= threshold)
                    {
                        _simpleDataModels[0].Add(dataItem);
                    }
                    else
                    {
                        _simpleDataModels[1].Add(dataItem);
                    }
                }
                else if (axis == "Y")
                {
                    if (dataItem.GetfirstThreeNumericColsAsVector().y >= threshold)
                    {
                        _simpleDataModels[0].Add(dataItem);
                    }
                    else
                    {
                        _simpleDataModels[1].Add(dataItem);
                    }
                }
                else if (axis == "Z")
                {
                    if (dataItem.GetfirstThreeNumericColsAsVector().z >= threshold)
                    {
                        _simpleDataModels[0].Add(dataItem);
                    }
                    else
                    {
                        _simpleDataModels[1].Add(dataItem);
                    }
                }
            }
            //get parent operator index for creating
            bool toBreak = false;

            foreach (var op in _observer.GetOperatorPrefabs())
            {
                foreach (var parent in Parents)
                {
                    if (parent.name.Contains(op.name))
                    {
                        toBreak = true;
                        break;
                    }
                }
                if (toBreak)
                {
                    break;
                }
                _parentIndex++;
            }
        }
        private GenericDatamodel ReadCsv()
        {
            GenericDatamodel dataModel = new SimpleDatamodel();

            var pathToData = _path + _filename;

            if (File.Exists(pathToData))
            {
                var fileContent = System.IO.File.ReadAllLines(pathToData);

                if (fileContent.Length == 0)
                {
                    throw new FileLoadException("Empty file!");
                }

                var start           = 0;
                var attributeTitles = TrimStringArray(fileContent[0].Split(_delimiter.ToCharArray()));
                if (!_hasHeader)
                {
                    for (var i = 0; i < attributeTitles.Length; i++)
                    {
                        attributeTitles[i] = "Column_" + (i + 1);
                    }
                }
                else
                {
                    start++;
                }

                var datatypes = new DataAttribute.Valuetype[attributeTitles.Length];
                var firstRow  = TrimStringArray(fileContent[start].Split(_delimiter.ToCharArray()));
                for (var i = 0; i < firstRow.Length; i++)
                {
                    datatypes[i] = DataAttribute.GetDataType(firstRow[i]);
                }

                for (var i = start; i < fileContent.Length; i++)
                {
                    var dataItem   = new DataItem();
                    var attributes = TrimStringArray(fileContent[i].Split(_delimiter.ToCharArray()));
                    if (attributes.Length != attributeTitles.Length)
                    {
                        throw new FileLoadException("Can not load " + pathToData + ". Row " + i + " does not contain the same amount of columns than the first row(" + attributeTitles.Length + ").");
                    }
                    ;

                    for (var j = 0; j < attributes.Length; j++)
                    {
                        var dataAttribute = new DataAttribute();
                        dataAttribute.Init(j, attributeTitles[j], attributes[j], datatypes[j]);
                        dataItem.Add(dataAttribute);
                    }
                    dataModel.Add(dataItem);
                }

                if ((_hasHeader && fileContent.Length - 1 != dataModel.GetDataItems().Count) || (!_hasHeader && fileContent.Length != dataModel.GetDataItems().Count))
                {
                    throw new FileLoadException("Incomplete Parsing! Not all rows were transformed imported as data items!");
                }
                ;

                return(dataModel);
            }
            else
            {
                throw new FileLoadException("Did not find file '" + pathToData + "'.");
            }
        }