package protection of attribute constructor

dirk120
dirk120 New Altair Community Member
edited November 5 in Community Q&A
Hi,
I would like to extent some of the attribute classes (e.g  NumericalAttribute) but the constructors are package protected. Even if  I define the extension in the same package (but in my plug-in jar) I get an access exception at run time calling the constructor (may be some issue with the class loader?).
Does anyone has a solution for that problem?

Thanks,
Dirk 

Answers

  • steffen
    steffen New Altair Community Member
    Hello Dirk

    I cannot explain why this (i.e. the difference between compile- and runtime) happens, but I have a feeling in my stomach that renaming one's own package to get access to package-proctected constructors is ... hm ... evil or at least wrong.

    My "solution": NumericalAttribute does not do that much complicated stuff, hence I would extend AbstractAttribute instead and do some copy & pasting if necessary.

    hope this was helpful,

    steffen

    edit: edited the source of confusion
  • fischer
    fischer New Altair Community Member
    Hi,

    the behaviour you are describing is just as expected for package private methods. Actually, these classes are protected is because some operators assume that there is only a well-defined universe of attribute types. Why exactly do you need a new one?

    Best,
    Simon
  • dirk120
    dirk120 New Altair Community Member
    In principle the attributes are sufficient except that I would like to extent it to hold some addition information. The information will be later used in some customized operator. In between I would like to use the standard RapidMiner operators to manipulate the example set data. I also considered to put  these additional attribute information in the annotations of the AttributeMetaData, but strings are not really suitable to hold the information. Meanwhile I thing I might be best to create an additional IoObject to hold the information and passed as input to the custom operator. Can you think of some other options?

    Thanks,
    Dirk
  • steffen
    steffen New Altair Community Member
    on a side note: Your description is rather vague. What do you plan to process, documents to release on wiki-leaks ;) ?

    An idea from my side ...

    Once I wrote a plugin to do some kind of image classification. Since I also wanted to do the preprocessing and feature generation steps in rapidminer, I was in a similar situation. I did the following ...
    • During the loading of the images I created a map which hold all images (i.e. their current state). The object was assigned to a static field. Additionally I created an ExampleSet where the id of the set correspond to the id of the mentioned map.
    • Whenever a custom operator needed to process images, it read the id from the set and loaded the image from the map.
    • If an operator has changed an image, the map was updated accordingly
    • By listening to the process (as far as I remember), I have ensured that the image-data is dropped when a process finishes
    This way I could use e.g. crossvalidation to optimize the preprocessing of images according to the defined label.

    greetings,

    steffen
  • dirk120
    dirk120 New Altair Community Member
    You are right the problem statement is not quite detailed. I will try to illustrate the issue on a simple example.:
    Let’s take the aggregation operator. It creates new attributes like average(att2), standard_deviation(att3).  Later on another operator will create a report that structures the data based on the use aggregation function. The only way to get the information about the aggregation function is by parsing the attribute name.  If you have more complex information than the aggregation function in this simple example it gets impossible to encode this information in the attribute name. So I was searching for a way to enrich the current attribute implementation.
    Creating a map to hold the information outside the example set / attributes sounds also like a good approach since I only need the information to create the report at the end.
  • fischer
    fischer New Altair Community Member
    Hi,

    a warning: Be careful with static references. RM 6 will probably allow multiple processes opened, and RapidAnalytics certainly does. Static references will not be thread safe.

    Best,
    Simon