Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] New feature extraction mechanism #72

Merged
merged 18 commits into from
Mar 20, 2020
Merged

Conversation

MaximeBouton
Copy link
Member

@MaximeBouton MaximeBouton commented Mar 10, 2020

This PR implements a new feature extraction mechanism and interface.
#70

  • Users can extract features from a list of scenes using the extract_features function.
dfs = extract_features((posgx, posfs, vel), scenes, roadway, ids) 
  • possibility to have parameter in the feature type (e.g. DistanceTo(:bob), CollisionWith(:alice), ...). This is conflicting with the use of symbols and needs to be discussed.

Most of the features from the previous version are implemented

@MaximeBouton
Copy link
Member Author

I have a first draft of the feature extraction working all the way. You can see the example in test/new_test_features.jl.

My implementation is using a lot of broadcasting. Some stuff is not efficient, like constructing a dictionary all the times. If we only want to keep extract_features as user facing, there might be some optimization possible in the lower level functions.

I decided to use dictionary instead of NamedTuples because it is a bit more flexible in terms of key types. If the ids are integer we cannot do df.1 .

cc @wbrannon @mattuntergassmair

@coveralls
Copy link

coveralls commented Mar 17, 2020

Coverage Status

Coverage increased (+4.4%) to 79.154% when pulling 5be7210 on feature-extraction into 94a1dd8 on master.

@MaximeBouton MaximeBouton mentioned this pull request Mar 19, 2020
17 tasks
@MaximeBouton MaximeBouton merged commit 9ea672e into master Mar 20, 2020
else
@assert(a.dir == DIR_RIGHT)
convert(Float64, get(LANEOFFSETRIGHT, scene, roadway, vehicle_index))
return lane_offset_right(roadway, scene[vehicle_index])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could be giving a more informative error message here if a.dir has an invalid value, such as

if a.dir == DIR_MIDDLE
    ...
elseif a.dir == DIR_LEFT
    ...
elseif a.dir == DIR_RIGHT
    ...
else
    throw(ErrorException("invalid direction"))
end

or similar instead of the assertion (a message like assertion a.dir == DIR_RIGHT failed may be confusing for users).

# feature(actions, veh)
# struct TemporalActionFeature <: AbstractFeature end
# feature(action, veh)
# struct ActionFeature <: AbstractFeature end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we already support action features now, out of the box? I think they are expected to occur very soon (in fact, if I want to port my DenseTrafficMerging repo to the new feature extraction interface, I would already need it).

featuretype(f::Function)
function used for dispatching feature types depending on the method of the feature function
"""
function featuretype(f::Function)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If users want to add their own new type of feature, will they have to edit the featuretype function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No! :D just implement their function with one of the supported method.
The trait is determined at compile time so there should be no overhead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is a new FeatureType, such as ActionFeature?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes then, you would need to add a check for the new method.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is that it's not easy right now to add actions to the interface (from the user side), so our callbacks effectively don't support actions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the callbacks do support actions, the feature extraction does not for now.

I think it would require extending the top level function extract_features to have a list of actions as inputs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough we can still use callbacks for collecting action related metrics, that should be good enough - didn't think about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants