Exemplo n.º 1
0
 def fit(self, X, y=None):
     X = infer_feature_types(X)
     if not is_all_numeric(X):
         raise ValueError("PCA input must be all numeric")
     X = _convert_woodwork_types_wrapper(X.to_dataframe())
     self._component_obj.fit(X)
     return self
Exemplo n.º 2
0
 def transform(self, X, y=None):
     X_ww = infer_feature_types(X)
     if not is_all_numeric(X_ww):
         raise ValueError("LDA input must be all numeric")
     X = _convert_woodwork_types_wrapper(X_ww.to_dataframe())
     X_t = self._component_obj.transform(X)
     X_t = pd.DataFrame(X_t, index=X.index, columns=[f"component_{i}" for i in range(X_t.shape[1])])
     return _retain_custom_types_and_initalize_woodwork(X_ww, X_t)
Exemplo n.º 3
0
    def fit(self, X, y):
        X = infer_feature_types(X)
        if not is_all_numeric(X):
            raise ValueError("LDA input must be all numeric")
        y = infer_feature_types(y)
        X = _convert_woodwork_types_wrapper(X.to_dataframe())
        y = _convert_woodwork_types_wrapper(y.to_series())
        n_features = X.shape[1]
        n_classes = y.nunique()
        n_components = self.parameters['n_components']
        if n_components is not None and n_components > min(n_classes, n_features):
            raise ValueError(f"n_components value {n_components} is too large")

        self._component_obj.fit(X, y)
        return self