class_docstr: Classifier wrapper of the StructureModel.
  Implements the sklearn .fit and .predict interface.
  
  Example:
  ::
      >>> from causalnex.sklearn import DAGRegressor
      >>>
      >>> clf = DAGClassifier(threshold=0.1)
      >>> clf.fit(X_train, y_train)
      >>>
      >>> y_preds = clf.predict(X_test)
      >>> type(y_preds)
      np.ndarray
      >>>
      >>> type(clf.feature_importances_)
      np.ndarray
  ::
  
  Attributes:
      feature_importances_ (np.ndarray): An array of edge weights corresponding
      positionally to the feature X.
  
      coef_ (np.ndarray): An array of edge weights corresponding
      positionally to the feature X.
  
      intercept_ (float): The target node bias value.
class_docstr_tok: ["Classifier","wrapper","of","the","StructureModel",".","Implements","the","sklearn",".fit","and",".predict","interface",".","Example",":",":",":",">",">",">","from","causalnex.sklearn","import","DAGRegressor",">",">",">",">",">",">","clf","=","DAGClassifier","(","threshold=0.1",")",">",">",">","clf.fit","(","X_train",",","y_train",")",">",">",">",">",">",">","y_preds","=","clf.predict","(","X_test",")",">",">",">","type","(","y_preds",")","np.ndarray",">",">",">",">",">",">","type","(","clf.feature_importances_",")","np.ndarray",":",":","Attributes",":","feature_importances_","(","np.ndarray",")",":","An","array","of","edge","weights","corresponding","positionally","to","the","feature","X.","coef_","(","np.ndarray",")",":","An","array","of","edge","weights","corresponding","positionally","to","the","feature","X.","intercept_","(","float",")",":","The","target","node","bias","value","."]
docstr: Fits the sm model using the concat of X and y.
  
  Raises:
      NotImplementedError: If unsupported target_dist_type provided.
      ValueError: If less than 2 classes provided.
  
  Returns:
      Instance of DAGClassifier.
docstr_tok: ["Fits","the","sm","model","using","the","concat","of","X","and","y",".","Raises",":","NotImplementedError",":","If","unsupported","target_dist_type","provided",".","ValueError",":","If","less","than","2","classes","provided",".","Returns",":","Instance","of","DAGClassifier","."]
code: def fit(
      self,
      X: Union[pd.DataFrame, np.ndarray],
      y: Union[pd.Series, np.ndarray],
  ) -> "DAGClassifier":
      """
      Fits the sm model using the concat of X and y.
  
      Raises:
          NotImplementedError: If unsupported target_dist_type provided.
          ValueError: If less than 2 classes provided.
  
      Returns:
          Instance of DAGClassifier.
      """
      # clf target check
      check_classification_targets(y)
  
      # encode the categories to be numeric
      enc = LabelEncoder()
      y = y.copy()
      y[:] = enc.fit_transform(y)
      # store the classes from the LabelEncoder
      self.classes_ = enc.classes_
  
      # class number checks
      n_classes = len(self.classes_)
      if n_classes < 2:
          raise ValueError(
              "This solver needs samples of at least 2 classes"
              " in the data, but the data contains only one"
              f" class: {self.classes_[0]}"
          )
  
      # store the protected attr _target_dist_type
      if self.target_dist_type is None:
          self.target_dist_type = "cat" if n_classes > 2 else "bin"
  
      # fit the NOTEARS model
      super().fit(X, y)
      return self
  
file_path: causalnex/causalnex/structure/pytorch/sklearn/clf.py
imports: from typing import List, Union
  import numpy
  import pandas
  from sklearn.base import ClassifierMixin
  from sklearn.preprocessing import LabelEncoder
  from sklearn.utils.multiclass import check_classification_targets
  from causalnex.structure.pytorch.dist_type.categorical import DistTypeCategorical
  from causalnex.structure.pytorch.sklearn._base import DAGBase
label_desc: Use image node_id 1 for calling the DAGClassifier obj's underlying member method code with example usage: obj.fit(X, y) and returns: self