Ejemplo n.º 1
0
    public FloatColumn normalizeFrequencyMinMax()
    {
        float[] newValues   = new float[values.Count];
        float[] frequencies = Functions.map((x => (float)x), ((StringValueSet)valueSet).valueOccurences.ToArray());
        float   max         = (float)Functions.max(frequencies);
        float   min         = (float)Functions.min(frequencies);
        float   mid         = (max + min) / 2.0f;

        max = max - mid;

        if (max != 0.0f)
        {
            frequencies = Functions.map((x => (x - mid) / max), frequencies);
        }
        else
        {
            frequencies = Functions.initArray(frequencies.Length, 0.0f);
        }

        newValues = Functions.map((x => frequencies[((StringValueSet)valueSet).values.IndexOf(x)]), values.ToArray());

        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        normalizedValueSet.max   = 1.0f;
        normalizedValueSet.mid   = 0.0f;
        normalizedValueSet.min   = -1.0f;
        normalizedValueSet.range = 2.0f;
        return(new FloatColumn(attributeName, newValues, normalizedValueSet));
    }
Ejemplo n.º 2
0
    public override FloatColumn normalizeMinMax()
    {
        float[]       newValues    = new float[values.Count];
        List <string> columnValues = ((StringValueSet)valueSet).values;
        float         max          = columnValues.Count - 1;
        float         mid          = max / 2.0f;

        max = max - mid;

        newValues = Functions.map((x => (float)columnValues.IndexOf(x)), values.ToArray());
        if (max != 0.0f)
        {
            newValues = Functions.map((x => (x - mid) / max), newValues);
        }
        else
        {
            newValues = Functions.initArray(newValues.Length, 0.0f);
        }

        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        normalizedValueSet.max   = 1.0f;
        normalizedValueSet.mid   = 0.0f;
        normalizedValueSet.min   = -1.0f;
        normalizedValueSet.range = 2.0f;
        return(new FloatColumn(attributeName, newValues, normalizedValueSet));
    }
Ejemplo n.º 3
0
    public override FloatColumn normalizeZScore()
    {
        float[]       newValues          = Functions.map((x => x ? 1.0f : -1.0f), values.ToArray());
        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        normalizedValueSet.mean = Functions.mean(newValues);
        normalizedValueSet.standardDeviation = Functions.standardDeviation(newValues, normalizedValueSet.mean);
        float trueZscore  = (1.0f - normalizedValueSet.mean) / normalizedValueSet.standardDeviation;
        float falseZscore = (-1.0f - normalizedValueSet.mean) / normalizedValueSet.standardDeviation;

        newValues = Functions.map((x => (x) ? trueZscore : falseZscore), values.ToArray());
        return(new FloatColumn(attributeName, newValues, normalizedValueSet));
    }
Ejemplo n.º 4
0
    public FloatColumn(string attributeName, float[] values)
    {
        this.attributeName = attributeName;
        FloatValueSet arrayValueSet = new FloatValueSet(attributeName);

        arrayValueSet.max               = Functions.max(values);
        arrayValueSet.min               = Functions.min(values);
        arrayValueSet.mid               = (arrayValueSet.max + arrayValueSet.min) / 2.0f;
        arrayValueSet.range             = arrayValueSet.max - arrayValueSet.min;
        arrayValueSet.mean              = Functions.mean(values);
        arrayValueSet.standardDeviation = Functions.standardDeviation(values, arrayValueSet.mean);
        this.valueSet = arrayValueSet;
        this.values   = Vector <float> .Build.DenseOfArray(values);
    }
Ejemplo n.º 5
0
    public override FloatColumn normalizeMinMax()
    {
        float[]       newValues          = Functions.map((x => x ? 1.0f : -1.0f), values.ToArray());
        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        normalizedValueSet.max               = 1.0f;
        normalizedValueSet.mid               = 0.0f;
        normalizedValueSet.min               = -1.0f;
        normalizedValueSet.range             = 2.0f;
        normalizedValueSet.mean              = Functions.mean(newValues);
        normalizedValueSet.standardDeviation = Functions.standardDeviation(newValues, normalizedValueSet.mean);

        return(new FloatColumn(attributeName, newValues, normalizedValueSet));
    }
Ejemplo n.º 6
0
    public override FloatColumn normalizeZScore()
    {
        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        normalizedValueSet.mean = Functions.mean(values.ToArray());
        normalizedValueSet.standardDeviation = Functions.standardDeviation(values.ToArray(), normalizedValueSet.mean);

        float[] newValues = Functions.map((x => (x - normalizedValueSet.mean) / normalizedValueSet.standardDeviation), values.ToArray());

        normalizedValueSet.max   = Functions.max(newValues);
        normalizedValueSet.min   = Functions.min(newValues);
        normalizedValueSet.mid   = (normalizedValueSet.max + normalizedValueSet.min) / 2.0f;
        normalizedValueSet.range = normalizedValueSet.max - normalizedValueSet.min;

        return(new FloatColumn(attributeName, newValues, normalizedValueSet));
    }
Ejemplo n.º 7
0
    public override FloatColumn normalizeZScore()
    {
        List <string> columnValues = ((StringValueSet)valueSet).values;

        float[] frequencies       = Functions.map((x => (float)x), (((StringValueSet)valueSet).valueOccurences.ToArray()));
        float   mean              = Functions.mean(frequencies);
        float   standardDeviation = Functions.standardDeviation(frequencies, mean);

        float[] zscores = Functions.map((x => (x - mean) / standardDeviation), frequencies);

        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        normalizedValueSet.max               = Functions.max(zscores);
        normalizedValueSet.min               = Functions.min(zscores);
        normalizedValueSet.mid               = (normalizedValueSet.max + normalizedValueSet.min) / 2.0f;
        normalizedValueSet.range             = normalizedValueSet.max - normalizedValueSet.min;
        normalizedValueSet.mean              = mean;
        normalizedValueSet.standardDeviation = standardDeviation;
        return(new FloatColumn(attributeName, Functions.map((x => zscores[columnValues.IndexOf(x)]), values.ToArray()), normalizedValueSet));
    }
Ejemplo n.º 8
0
    public override FloatColumn normalizeMinMax()
    {
        FloatValueSet normalizedValueSet = new FloatValueSet(attributeName);

        float[] newValues = values.ToArray();
        float   max       = Functions.max(newValues);
        float   min       = Functions.min(newValues);
        float   mid       = (max + min) / 2.0f;

        max = max - mid;

        newValues = Functions.map((x => (x - mid) / max), newValues);

        normalizedValueSet.max               = 1.0f;
        normalizedValueSet.min               = -1.0f;
        normalizedValueSet.mid               = 0.0f;
        normalizedValueSet.range             = 2.0f;
        normalizedValueSet.mean              = Functions.mean(newValues);
        normalizedValueSet.standardDeviation = Functions.standardDeviation(newValues, normalizedValueSet.mean);
        return(new FloatColumn(attributeName, newValues, normalizedValueSet));
    }
Ejemplo n.º 9
0
 public FloatColumn(string attributeName, float[] values, FloatValueSet valueSet)
 {
     this.attributeName = attributeName;
     this.valueSet      = valueSet;
     this.values        = Vector <float> .Build.DenseOfArray(values);
 }