seg1d.processing.Features.gen_weights¶
-
static
Features.
gen_weights
(dataset)[source]¶ Create weight table from reference data
Parameters: - dataset: List[Dict{feature:value}]
sets of references to be correlated against eachother to generate an importance score of each feature
Returns: - weightsDict{feature:score}
normalized sum of weights over all segments
See also
match_len
- match length of all features
Notes
All features should be of same length.
Examples
>>> import numpy as np >>> import seg1d.processing as process >>> e10 = np.linspace(-np.pi*2, np.pi*2, 10) >>> s1 = {'f1': np.sin(e10) , 'f2': np.sin(e10), 'f3': np.linspace(0,9,10) } >>> s2 = {'f1': np.sin(e10) , 'f2': np.cos(e10), 'f3': -1*np.linspace(0,9,10) } >>> s3 = {'f1': np.sin(e10) , 'f2': np.tan(e10), 'f3': np.ones((10))} >>> d = [s1, s2, s3] >>> r = process.Features.gen_weights(d) >>> print([np.around(r[x], 3) for x in sorted(r)]) [array([1.]), array([-0.25]), array([-1.])]