@@ -1271,6 +1271,10 @@ class RandomTreesEmbedding(BaseForest):
12711271 If not None then ``max_depth`` will be ignored.
12721272 Note: this parameter is tree-specific.
12731273
1274+ sparse_output: bool, optional (default=True)
1275+ Whether or not to return a sparse CSR matrix, as default behavior,
1276+ or to return a dense array compatible with dense pipeline operators.
1277+
12741278 n_jobs : integer, optional (default=1)
12751279 The number of jobs to run in parallel for both `fit` and `predict`.
12761280 If -1, then the number of jobs is set to the number of cores.
@@ -1305,6 +1309,7 @@ def __init__(self,
13051309 min_samples_split = 2 ,
13061310 min_samples_leaf = 1 ,
13071311 max_leaf_nodes = None ,
1312+ sparse_output = True ,
13081313 n_jobs = 1 ,
13091314 random_state = None ,
13101315 verbose = 0 ,
@@ -1327,6 +1332,7 @@ def __init__(self,
13271332 self .min_samples_leaf = min_samples_leaf
13281333 self .max_features = 1
13291334 self .max_leaf_nodes = max_leaf_nodes
1335+ self .sparse_output = sparse_output
13301336
13311337 if min_density is not None :
13321338 warn ("The min_density parameter is deprecated as of version 0.14 "
@@ -1363,7 +1369,7 @@ def fit_transform(self, X, y=None):
13631369 rnd = check_random_state (self .random_state )
13641370 y = rnd .uniform (size = X .shape [0 ])
13651371 super (RandomTreesEmbedding , self ).fit (X , y )
1366- self .one_hot_encoder_ = OneHotEncoder ()
1372+ self .one_hot_encoder_ = OneHotEncoder (sparse = self . sparse_output )
13671373 return self .one_hot_encoder_ .fit_transform (self .apply (X ))
13681374
13691375 def transform (self , X ):
0 commit comments