Extend MissingVelueReplenishment with median calculations

der_maik81
der_maik81 New Altair Community Member
edited November 5 in Community Q&A
Hello Folks,

I want to extend the operator "mssingValueReplenishment" with the possibility to calculate the median of a given attribute. I dont't really know how to start my coding.

Here the steps i did so far:

1) Extend the cases in
                                        MissingValueReplenishment.public double getReplenishmentValue(int functionIndex, ExampleSet exampleSet, Attribute                attribute, double currentValue, String valueString)  with

case MEDIAN:
return exampleSet.getStatistics(attribute, Statistics.MEDIAN);

2) In addition to that in the interface "statistics"  i'have added

public static final String MEDIAN  = "median"

The attributes in my exampleSet are numerical by nature, so i think the key to solving my problem belongs to

3) NumericalStatistics.count(Attribute a) - Here the variance and the mean are calculated for the given attribute.
But now I don't know to go on.

I would be glad if someone has a tip how to proceed.

Thanks very much an best wishes,
Maik


Answers

  • TobiasMalbrecht
    TobiasMalbrecht New Altair Community Member
    Hello Maik,

    in principal, you could extend the NumericalStatistics to calculate the median as well. But from my point of view, I think for you it would be easier to simply calculate the median in the method getReplenishmentValue(...) from the data. Everything you need (example set, attribute) is available in that method, so no new methods etc. have to be added. This way however has the disadvantage of an additional data scan, but it is much easier to implement.

    Hope that helps,
    Tobias