Q:

ExtraTreesClassifier with sparse training data?

I am trying to use an ExtraTreesClassifier with sparse data, as per the documentation, however I do get a run time TypeError asking for dense data. This is on scikit-learn 0.17.1, and below I am quoting from the documentation: 

Parameters: 
X : array-like or sparse matrix of shape = [n_samples, n_features]

The code is quite simple: 
import pandas as pd
from scipy.sparse import coo_matrix, csr_matrix, hstack
from sklearn.ensemble import ExtraTreesClassifier
import numpy as np
from scipy import *

features = array([[1, 0], [0, 1], [3, 4]])
sparse_features = csr_matrix(features)
labels = array([0, 1, 0])

classifier = ExtraTreesClassifier()
classifier.fit(sparse_features, labels)

And here the exception: TypeError: A sparse matrix was passed, but dense data is required. Use X.toarray() to convert to a dense numpy array.. This works fine when passing in features.
Looks like the documentation is out of date or is there something wrong with the above code?
Any help will be greatly appreciated. Thank you. 

A:

Quoting the documentation:

Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.

So I expect that passing a csc_matrix should help. 
On my setup both version work normally (csc and csr, sklearn 0.17.1), I assume that problems could be with older versions of scipy.

