Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _features(indices, feature_names, coef, x):
names = mask(feature_names, indices)
weights = mask(coef, indices)
if x is not None:
values = mask(x, indices)
return [FeatureWeight(name, weight, value=value)
for name, weight, value in zip(names, weights, values)]
else:
return [FeatureWeight(name, weight)
for name, weight in zip(names, weights)]
def _features(indices, feature_names, coef, x):
names = mask(feature_names, indices)
weights = mask(coef, indices)
if x is not None:
values = mask(x, indices)
return [FeatureWeight(name, weight, value=value)
for name, weight, value in zip(names, weights, values)]
else:
return [FeatureWeight(name, weight)
for name, weight in zip(names, weights)]
def _features(indices, feature_names, coef, x):
names = mask(feature_names, indices)
weights = mask(coef, indices)
if x is not None:
values = mask(x, indices)
return [FeatureWeight(name, weight, value=value)
for name, weight, value in zip(names, weights, values)]
else:
return [FeatureWeight(name, weight)
for name, weight in zip(names, weights)]
def get_top_features_filtered(x, flt_feature_names, flt_indices,
weights, top, scale=1.0):
if flt_indices is not None:
_x = mask(x, flt_indices)
weights = mask(weights, flt_indices)
else:
_x = x
return get_top_features(flt_feature_names, weights * scale, top, _x)