def _transform_selected(X, transform, selected='all', copy=True):
 X = check_array(X, accept_sparse='csc', copy=copy, dtype=FLOAT_DTYPES)
 if (isinstance(selected, six.string_types) and (selected == 'all')):
  return transform(X)
 if (len(selected) == 0):
  return X
 n_features = X.shape[1]
 ind = np.arange(n_features)
 sel = np.zeros(n_features, dtype=bool)
 sel[np.asarray(selected)] = True
 not_sel = np.logical_not(sel)
 n_selected = np.sum(sel)
 if (n_selected == 0):
  return X
 elif (n_selected == n_features):
  return transform(X)
 else:
  X_sel = transform(X[:, ind[sel]])
  X_not_sel = X[:, ind[not_sel]]
  if (sparse.issparse(X_sel) or sparse.issparse(X_not_sel)):
   return sparse.hstack((X_sel, X_not_sel))
  else:
   return np.hstack((X_sel, X_not_sel))

def _transform_selected ( X , transform , selected = 'all' , copy = True ) : X = check_array ( X , accept_sparse = 'csc' , copy = copy , dtype = FLOAT_DTYPES ) if ( isinstance ( selected , six . string_types ) and ( selected == 'all' ) ) : return transform ( X ) if ( len ( selected ) == 0 ) : return X n_features = X . shape [ 1 ] ind = np . arange ( n_features ) sel = np . zeros ( n_features , dtype = bool ) sel [ np . asarray ( selected ) ] = True not_sel = np . logical_not ( sel ) n_selected = np . sum ( sel ) if ( n_selected == 0 ) : return X elif ( n_selected == n_features ) : return transform ( X ) else : X_sel = transform ( X [ : , ind [ sel ] ] ) X_not_sel = X [ : , ind [ not_sel ] ] if ( sparse . issparse ( X_sel ) or sparse . issparse ( X_not_sel ) ) : return sparse . hstack ( ( X_sel , X_not_sel ) ) else : return np . hstack ( ( X_sel , X_not_sel ) )
apply a transform function to portion of selected features parameters x : {array-like .