Esempio n. 1
0
        private static void AddRelationRow(ArffRelation relation, string row, List <int> ignoredCols)
        {
            string[]      values    = row.Split(',');
            List <double> rowValues = new List <double>();

            int effectiveCol = 0;

            for (int i = 0; i < values.Length; i++)
            {
                if (!ignoredCols.Contains(i))
                {
                    if (values[i] == "?")
                    {
                        rowValues.Add(double.MaxValue);
                    }
                    else if (relation.Columns[effectiveCol].IsReal)
                    {
                        rowValues.Add(double.Parse(values[i]));
                    }
                    else
                    {
                        rowValues.Add(relation.Columns[effectiveCol].NominalValues[values[i]]);
                    }
                    effectiveCol++;
                }
            }

            var toAdd = new ArffRow(relation, rowValues.ToList());

            relation.AddRow(toAdd);
        }
Esempio n. 2
0
        public double GetDistance(ArffRow from)
        {
            double distance = 0;

            for (int col = 0; col < _values.Count; col++)
            {
                if (this.ColumnIsUnkown(col) || from.ColumnIsUnkown(col))
                {
                    distance += 1;
                }
                else if (_relation.Columns[col].IsReal)
                {
                    distance += Math.Pow(from._values[col] - this._values[col], 2);
                }
                else
                {
                    distance += this._values[col] == from._values[col] ? 0 : 1;
                }
            }

            distance = Math.Sqrt(distance);
            return(distance);
        }
Esempio n. 3
0
 public void AddRow(ArffRow row)
 {
     _rows.Add(row);
 }