Skip to content

Datasets cached pre-#548 can no longer be used for run_model_on_task #646

Closed

Description

@PGijsbers

It looks like pre-#548 pickled data was in np.array format, where now the default is pandas.dataframe. When I now try to use run_model_on_task for which I still have a cached dataset with np.array as data instead of pd.DataFrame, this line is called with (data, dataset_format=="array", [some list of attribute names). This raises an error because as far as I can tell _convert_array_format assumes that the input data is pd.DataFrame if specified dataformat is "array", which makes this line raise an error because np.array does not have an attribute columns.

The fix seems easy enough, just check if data is already of the preferred type, e.g. start the function with

def _convert_array_format(data, array_format, attribute_names):
    if array_format == "array" and not scipy.sparse.issparse(data):
        if isinstance(data, np.ndarray):
            return data
        ...

Does this make sense? Shall I set up a PR?
@glemaitre @mfeurer

Activity

  1. mfeurer commented on Mar 18, 2019

    @mfeurer
    Collaborator

    Thanks for raising this issue. I would suggest that we use an aggressive updating strategy and re-download the data in case the pickle file cannot be read. What do you think?

  2. PGijsbers commented on Mar 18, 2019

    @PGijsbers
    CollaboratorAuthor

    Not sure, on the one hand I am currently performing some runs with this hack and it seems pretty stable (so far on 90+ different tasks already done). It's not that the pickle file can't be read. It can be and seems to be done correctly. It is just after loading the data, run_model_on_task wants to have it in np.ndarray format and in the conversion assumes it is not yet in np.ndarray format which causes the problem.
    So I don't think there is anything inherently wrong/breaking with not invalidating peoples cache, which makes the 'hack' ok.

    On the other hand, we probably don't want to worry about this scenario anymore later. And writing code that locally changes the stored data (I think it should be possible without redownloading? I didn't look too closely) probably takes more time than just forcing a cache refresh.

  3. mfeurer commented on Mar 19, 2019

    @mfeurer
    Collaborator

    The reason why I proposed this rather aggressive strategy is that new features (such as string support in datasets) will only be available if the data is stored as a pandas array.

    I also wouldn't like to reformat the data locally and therefore suggest to either download it again or re-read the arff file to create the pickle of a pandas dataframe.

    Would you like to work on this @PGijsbers ?

  4. PGijsbers commented on Mar 19, 2019

    @PGijsbers
    CollaboratorAuthor

    That makes sense. I can work on this.

  5. self-assigned this
    on Mar 19, 2019
  6. added a commit that references this issue on Mar 30, 2019
  7. added a commit that references this issue on Apr 1, 2019
  8. mfeurer commented on Apr 1, 2019

    @mfeurer
    Collaborator

    Fixed via #646.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions