docstr: FeatureGradientSelector is a class that selects features for a machine
  learning model using a gradient based search.
  
  Parameters
  ----------
  order : int
      What order of interactions to include. Higher orders
      may be more accurate but increase the run time. 12 is the maximum allowed order.
  penatly : int
      Constant that multiplies the regularization term.
  n_features: int
      If None, will automatically choose number of features based on search.
      Otherwise, number of top features to select.
  max_features : int
      If not None, will use the 'elbow method' to determine the number of features
      with max_features as the upper limit.
  learning_rate : float
  init : str
      How to initialize the vector of scores. 'zero' is the default.
      Options: {'zero', 'on', 'off', 'onhigh', 'offhigh', 'sklearn'}
  n_epochs : int
      number of epochs to run
  shuffle : bool
      Shuffle "rows" prior to an epoch.
  batch_size : int
      Nnumber of "rows" to process at a time
  target_batch_size : int
      Number of "rows" to accumulate gradients over.
      Useful when many rows will not fit into memory but are needed for accurate estimation.
  classification : bool
      If True, problem is classification, else regression.
  ordinal : bool
      If True, problem is ordinal classification. Requires classification to be True.
  balanced : bool
      If true, each class is weighted equally in optimization, otherwise
      weighted is done via support of each class. Requires classification to be True.
  prerocess : str
      'zscore' which refers to centering and normalizing data to unit variance or
      'center' which only centers the data to 0 mean
  soft_grouping : bool
      if True, groups represent features that come from the same source.
      Used to encourage sparsity of groups and features within groups.
  verbose : int
      Controls the verbosity when fitting. Set to 0 for no printing
      1 or higher for printing every verbose number of gradient steps.
  device : str
      'cpu' to run on CPU and 'cuda' to run on GPU. Runs much faster on GPU
docstr_tok: ["FeatureGradientSelector","is","a","class","that","selects","features","for","a","machine","learning","model","using","a","gradient","based","search",".","Parameters","--","--","--","--","--","order",":","int","What","order","of","interactions","to","include",".","Higher","orders","may","be","more","accurate","but","increase","the","run","time",".","12","is","the","maximum","allowed","order",".","penatly",":","int","Constant","that","multiplies","the","regularization","term",".","n_features",":","int","If","None",",","will","automatically","choose","number","of","features","based","on","search",".","Otherwise",",","number","of","top","features","to","select",".","max_features",":","int","If","not","None",",","will","use","the","'elbow","method","'","to","determine","the","number","of","features","with","max_features","as","the","upper","limit",".","learning_rate",":","float","init",":","str","How","to","initialize","the","vector","of","scores",".","'zero","'","is","the","default",".","Options",":","{","'zero","'",",","'on","'",",","'off","'",",","'onhigh","'",",","'offhigh","'",",","'sklearn","'","}","n_epochs",":","int","number","of","epochs","to","run","shuffle",":","bool","Shuffle","``","rows","''","prior","to","an","epoch",".","batch_size",":","int","Nnumber","of","``","rows","''","to","process","at","a","time","target_batch_size",":","int","Number","of","``","rows","''","to","accumulate","gradients","over",".","Useful","when","many","rows","will","not","fit","into","memory","but","are","needed","for","accurate","estimation",".","classification",":","bool","If","True",",","problem","is","classification",",","else","regression",".","ordinal",":","bool","If","True",",","problem","is","ordinal","classification",".","Requires","classification","to","be","True",".","balanced",":","bool","If","true",",","each","class","is","weighted","equally","in","optimization",",","otherwise","weighted","is","done","via","support","of","each","class",".","Requires","classification","to","be","True",".","prerocess",":","str","'zscore","'","which","refers","to","centering","and","normalizing","data","to","unit","variance","or","'center","'","which","only","centers","the","data","to","0","mean","soft_grouping",":","bool","if","True",",","groups","represent","features","that","come","from","the","same","source",".","Used","to","encourage","sparsity","of","groups","and","features","within","groups",".","verbose",":","int","Controls","the","verbosity","when","fitting",".","Set","to","0","for","no","printing","1","or","higher","for","printing","every","verbose","number","of","gradient","steps",".","device",":","str","'cpu","'","to","run","on","CPU","and","'cuda","'","to","run","on","GPU",".","Runs","much","faster","on","GPU"]
code: def __init__(
      self,
      order=4,
      penalty=1,
      n_features=None,
      max_features=None,
      learning_rate=1e-1,
      init="zero",
      n_epochs=1,
      shuffle=True,
      batch_size=1000,
      target_batch_size=1000,
      max_time=np.inf,
      classification=True,
      ordinal=False,
      balanced=True,
      preprocess="zscore",
      soft_grouping=False,
      verbose=0,
      device="cpu",
  ):
      """
      FeatureGradientSelector is a class that selects features for a machine
      learning model using a gradient based search.
  
      Parameters
      ----------
      order : int
          What order of interactions to include. Higher orders
          may be more accurate but increase the run time. 12 is the maximum allowed order.
      penatly : int
          Constant that multiplies the regularization term.
      n_features: int
          If None, will automatically choose number of features based on search.
          Otherwise, number of top features to select.
      max_features : int
          If not None, will use the 'elbow method' to determine the number of features
          with max_features as the upper limit.
      learning_rate : float
      init : str
          How to initialize the vector of scores. 'zero' is the default.
          Options: {'zero', 'on', 'off', 'onhigh', 'offhigh', 'sklearn'}
      n_epochs : int
          number of epochs to run
      shuffle : bool
          Shuffle "rows" prior to an epoch.
      batch_size : int
          Nnumber of "rows" to process at a time
      target_batch_size : int
          Number of "rows" to accumulate gradients over.
          Useful when many rows will not fit into memory but are needed for accurate estimation.
      classification : bool
          If True, problem is classification, else regression.
      ordinal : bool
          If True, problem is ordinal classification. Requires classification to be True.
      balanced : bool
          If true, each class is weighted equally in optimization, otherwise
          weighted is done via support of each class. Requires classification to be True.
      prerocess : str
          'zscore' which refers to centering and normalizing data to unit variance or
          'center' which only centers the data to 0 mean
      soft_grouping : bool
          if True, groups represent features that come from the same source.
          Used to encourage sparsity of groups and features within groups.
      verbose : int
          Controls the verbosity when fitting. Set to 0 for no printing
          1 or higher for printing every verbose number of gradient steps.
      device : str
          'cpu' to run on CPU and 'cuda' to run on GPU. Runs much faster on GPU
      """
      assert (
          order <= 12 and order >= 1
      ), "order must be an integer between 1 and 12, inclusive"
      assert (
          n_features is None or max_features is None
      ), "only specify one of n_features and max_features at a time"
  
      self.order = order
      self.penalty = penalty
      self.n_features = n_features
      self.max_features = max_features
      self.learning_rate = learning_rate
      self.init = init
      self.n_epochs = n_epochs
      self.shuffle = shuffle
      self.batch_size = batch_size
      self.target_batch_size = target_batch_size
      self.max_time = max_time
      self.dftol_stop = -1
      self.freltol_stop = -1
      self.classification = classification
      self.ordinal = ordinal
      self.balanced = balanced
      self.preprocess = preprocess
      self.soft_grouping = soft_grouping
      self.verbose = verbose
      self.device = device
  
      self.model_ = None
      self.scores_ = None
      self._prev_checkpoint = None
      self._data_train = None
  
imports: import time
  import numpy
  import pandas
  from sklearn.base import BaseEstimator
  from sklearn.feature_selection import SelectorMixin
  from sklearn.utils.validation import check_is_fitted
  import torch
  from nni.feature_engineering.feature_selector import FeatureSelector
  from .None import constants
  from .fginitialize import PrepareData
  from .fgtrain import _train
label_desc: Use image node_id 1 to create a new FeatureGradientSelector object from inherited base classes: FeatureSelector, BaseEstimator, SelectorMixin with example: obj = FeatureGradientSelector(order, penalty, n_features, max_features, learning_rate, init, n_epochs, shuffle, batch_size, target_batch_size, max_time, classification, ordinal, balanced, preprocess, soft_grouping, verbose, device)