-
Notifications
You must be signed in to change notification settings - Fork 104
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
Complex Feature type with Property Path support #39
Comments
In this case it is better to create a custom property. You can inherit from the Property class to do your own multi valued conversion. This can then be added to the feature collection. |
I can give the custom property a try in numlsample and see how that goes.
|
I've been looking into the innards of the descriptor building mechanism for this, and I have a question.
This works for both normal features/properties as well as enumerable ones, because enumerable properties are all of the same type. But if we have a complex type with discrete and non-discrete values, then how would this be resolved? As far as I can tell, I would think the But with the One possible change to address this could be changing the Thoughts? |
Discrete is an interesting artifact of assuming that there would always be a one-to-one correspondence between a property and a single (double) value. Under this assumption there were two categories of numbers (in my original opinion):
This worked well under the above mentioned assumption - not so sure when there is a one-to-many correspondence between a property and the generated numbers. An additional assertion - the descriptor was never intended to be used to flatten object graphs into vectors. My hope was that there would first be a projection onto a flattened structure that would subsequently be described by the descriptor. I initially went down this path but quickly realized I would be re-implementing a lot of what already existed in AutoMapper. This is why I put work into the descriptor working even with anonymous types (it does). You could theoretically flatten into an anonymous type and couple it with a weak descriptor. What do you think? |
Hmm...I think the discrete/everything else split was a good decision. As for your additional assertion, it has been my understanding that the descriptor is the OOP-to-math bridge, enabling the wrapping/consumption/simplification of the ML complexities in object terms (the main reason I chose numl in the first place). As such, I personally like the object graph flattening being encapsulated in the descriptor and I appreciate your distinctions of strong/weak descriptors in the comments of your blog. So I think that was a good decision also. And using those terms, this issue is simply an implementation detail of a strong descriptor, and I think it can be done as you mentioned by creating custom I don't know for sure though, I just wanted to get your thoughts on this before going ahead. I'll go ahead and try to implement this "That should work! 8-O" |
Well I've committed the changes to my local forks (numlsample, and numl itself, but I am unsure how to proceed with the pull request. I say this, because there are actually two would-be pull requests that are related: numlsample and numl itself. I had to slightly tweak |
When using the description method in numl the Descriptor object throws an exception when a Feature or Label attribute is defined on a complex type property. Properties can be complex types from external libraries thus preventing numl attribute usage.
For example given the below type:
public class Foo
{
[Feature]
public Bar One { get; set; }
[Label]
public bool IsOK { get; set; }
}
public class Bar
{
public int A { get; set; }
public int B { get; set; }
public int C { get; set; }
}
The descriptor would throw an error on converting the type Bar to a double. This is the same for nullable type properties also.
A suggested implementation is to use property path(s) in the Feature attribute. This would allow the Descriptor to extract one or more sub properties from the complex type.
Suggested Implementation:
public class Foo
{
[FeatureSelector("Bar.A", Bar.B", "Bar.C")]
public Bar One { get; set; }
[Label]
public bool IsOK { get; set; }
}
The text was updated successfully, but these errors were encountered: