class_docstr: Class for learning a locally linear sparse model from perturbed data
class_docstr_tok: ["Class","for","learning","a","locally","linear","sparse","model","from","perturbed","data"]
docstr: Iteratively adds features to the model
docstr_tok: ["Iteratively","adds","features","to","the","model"]
code: def forward_selection(self, data, labels, weights, num_features):
      """Iteratively adds features to the model"""
      clf = Ridge(
          alpha=0, fit_intercept=True, random_state=self.random_state
      )
      used_features = []
      for _ in range(min(num_features, data.shape[1])):
          max_ = -100000000
          best = 0
          for feature in range(data.shape[1]):
              if feature in used_features:
                  continue
              clf.fit(
                  data[:, used_features + [feature]],
                  labels,
                  sample_weight=weights,
              )
              score = clf.score(
                  data[:, used_features + [feature]],
                  labels,
                  sample_weight=weights,
              )
              if score > max_:
                  best = feature
                  max_ = score
          used_features.append(best)
      return np.array(used_features)
  
file_path: tensorwatch/tensorwatch/saliency/lime/lime_base.py
imports: from __future__ import print_function
  import numpy
  from sklearn.linear_model import Ridge, lars_path
  from sklearn.utils import check_random_state
label_desc: Use image node_id 3 for calling the LimeBase obj's underlying member method code with example usage: obj.forward_selection(data, labels, weights, num_features) and returns: np