Example #1
0
        protected override void CreateMappedDataset()
        {
            foreach (List <string> row in DataSet)
            {
                int columns = row.Count;

                Line data = new Line();
                MappedDataSet.Add(data);

                data.AddEntry(new LineEntry(row[0], Double.Parse(row[0]), 0));

                for (int i = 1; i < columns; i++)
                {
                    if (i > columns - 1)
                    {
                        throw new Exception("The column is out of bounds. "
                                            + "The wine dataset contains " + columns + " columns. "
                                            + "Tried to access the " + (i + 1) + "th column!");
                    }
                    else
                    {
                        data.AddEntry(new LineEntry("column " + i, Double.Parse(row[i], CultureInfo.InvariantCulture), i));
                    }
                }
            }
        }
Example #2
0
        protected override void CreateMappedDataset()
        {
            foreach (List <string> stringLine in DataSet)
            {
                int cols = stringLine.Count;

                Line l = new Line();
                MappedDataSet.Add(l);

                for (int i = 0; i < cols; i++)
                {
                    switch (i)
                    {
                    case 0:
                    case 1:
                    case 2:
                    case 3:
                        l.AddEntry(new LineEntry("Col " + i, Double.Parse(stringLine[i], CultureInfo.InvariantCulture), i));
                        break;

                    case 4:
                        l.AddEntry(new LineEntry(stringLine[i], IrisMap(stringLine[i]), i));
                        break;

                    default:
                        throw new Exception("Row too long");
                    }
                }
            }
        }
Example #3
0
        protected override void CreateMappedDataset()
        {
            foreach (List <string> row in DataSet)
            {
                int columns = row.Count;

                Line data = new Line();
                MappedDataSet.Add(data);

                for (int i = 0; i < columns - 1; i++)
                {
                    if (i > 5)
                    {
                        throw new Exception("The column is out of bounds. "
                                            + "The bankruptcy dataset contains 5 input columns. "
                                            + "Tried to access the " + i + "th column!");
                    }
                    else
                    {
                        data.AddEntry(new LineEntry("column " + i, InputMap(row[i]), i));
                    }
                }

                data.AddEntry(new LineEntry(row[6], OutputMap(row[6]), 6));
            }
        }
        protected override void CreateMappedDataset()
        {
            int count = 0;

            foreach (List <string> row in DataSet)
            {
                count++;
                if (count % 500 != 0)
                {
                    continue;
                }

                int  columns = row.Count;
                Line data    = new Line();
                MappedDataSet.Add(data);
                double x = 0;

                // inputs
                data.AddEntry(new LineEntry("day", DayMap(row[3]), 3));
                data.AddEntry(new LineEntry("time", TimeMap(row[4]), 4));
                data.AddEntry(new LineEntry("state", StateMap(row[5]), 5));
                data.AddEntry(new LineEntry("group size", GroupSizeMap(row[7]), 7));
                data.AddEntry(new LineEntry("homeowner", HomeownerMap(row[8]), 8));
                data.AddEntry(new LineEntry("car age", CarAgeMap(row[9]), 9));
                data.AddEntry(new LineEntry("car value", CarValueMap(row[10]), 10));
                data.AddEntry(new LineEntry("risk factor", RiskFactorMap(row[11]), 11));
                data.AddEntry(new LineEntry("age, oldest", AgeOldestMap(row[12]), 12));
                data.AddEntry(new LineEntry("age, youngest", AgeYoungestMap(row[13]), 13));
                data.AddEntry(new LineEntry("married couple", MarriedCoupleMap(row[14]), 14));
                data.AddEntry(new LineEntry("C previous", CPreviousMap(row[15]), 15));
                data.AddEntry(new LineEntry("duration previous", DurationPreviousMap(row[16]), 16));

                // outputs
                for (int i = 17; i < 24; i++)
                {
                    if (Double.TryParse(row[i], out x))
                    {
                        data.AddEntry(new LineEntry(row[i], x, i));
                    }
                    else
                    {
                        throw new Exception("Was expecting a double, but got " + row[i] + "."
                                            + "This was encountered in column " + i + "!"
                                            + "The index of the row is: " + DataSet.IndexOf(row));
                    }
                }
                // final output
                data.AddEntry(new LineEntry("cost", CostMap(row[24]), 24));
            }
            System.Console.WriteLine("MappedDataset: " + MappedDataSet.Count);
        }
        protected override void CreateMappedDataset()
        {
            foreach (List <string> stringLine in DataSet)
            {
                int cols = stringLine.Count;

                Line line = new Line();
                MappedDataSet.Add(line);

                for (int i = 0; i < cols; i++)
                {
                    string value = stringLine[i];

                    //if(line.IndexOf("?") != -1)
                    //  continue;
                    switch (i)
                    {
                    case 0:
                        line.AddEntry(new LineEntry("age", IncomeDataset.AgeMap(value), i));
                        break;

                    case 1:
                        line.AddEntry(new LineEntry("workclass", IncomeDataset.WorkClassMap(value), i));
                        break;

                    case 2:
                        // Fitting weight, not needed
                        break;

                    case 3:
                        // Education in words, case 4 is the same in years
                        break;

                    case 4:
                        line.AddEntry(new LineEntry("education-num", IncomeDataset.EducationNumMap(value), i));
                        break;

                    case 5:
                        line.AddEntry(new LineEntry("marital-status", IncomeDataset.MaritalStatusMap(value), i));
                        break;

                    case 6:
                        line.AddEntry(new LineEntry("occupation", IncomeDataset.OccupationMap(value), i));
                        break;

                    case 7:
                        line.AddEntry(new LineEntry("relationship", IncomeDataset.RelationshipMap(value), i));
                        break;

                    case 8:
                        line.AddEntry(new LineEntry("race", IncomeDataset.RaceMap(value), i));
                        break;

                    case 9:
                        line.AddEntry(new LineEntry("sex", IncomeDataset.SexMap(value), i));
                        break;

                    case 10:
                        line.AddEntry(new LineEntry("capital-gain", IncomeDataset.CapitalGainMap(value, GainMedian), i));
                        break;

                    case 11:
                        line.AddEntry(new LineEntry("capital-loss", IncomeDataset.CapitalLossMap(value, LossMedian), i));
                        break;

                    case 12:
                        line.AddEntry(new LineEntry("hours-per-week", IncomeDataset.HoursPerWeekMap(value), i));
                        break;

                    case 13:
                        line.AddEntry(new LineEntry("native-country", IncomeDataset.NativeCountryMap(value), i));
                        break;

                    case 14:
                        line.AddEntry(new LineEntry("salary >50K?", IncomeDataset.IncomeMap(value[0]), i));
                        break;

                    default:
                        throw new Exception("No mapping of inputs");
                    }
                }
            }
        }