Options

Extend MissingVelueReplenishment with median calculations

der_maik81der_maik81 Member Posts: 2 Contributor I
edited November 2018 in Help
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


Tagged:

Answers

  • Options
    TobiasMalbrechtTobiasMalbrecht Moderator, Employee, Member Posts: 295 RM Product Management
    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
Sign In or Register to comment.