this function is quite long at around 90 lines of code. it could benefit from being decomposed, one possible easy way to do so is for each if/elif section to be a separate function which makes it easier to verify the functionality of each branch. something like:

```python
feature_functions = {'TN': _process_tn, 'RF': _process_rf, ...}
for feature, value in foo.iteritems():
    feature_functions[feature](value, and, other, things)
```