viisar / brew

⛔️ DEPRECATED brew: Python Ensemble Learning API
MIT License
301 stars 70 forks source link

trying to use bagging, not working with document-term-matrix #38

Open sanjeev8988 opened 6 years ago

sanjeev8988 commented 6 years ago

Using bagging for text classification, trying to work with document-term-matrix,

in () 7 tree = DecisionTreeClassifier(max_depth=1, min_samples_leaf=1) 8 bag = Bagging(base_classifier=tree, n_classifiers=10) ----> 9 bag.fit(X_train_dtm, y_train) 10 11 div = Diversity(metric='q') C:\Anaconda3\lib\site-packages\brew-0.1.4-py3.5.egg\brew\generation\bagging.py in fit(self, X, y) 27 # bootstrap 28 idx = np.random.choice(X.shape[0], X.shape[0], replace=True) ---> 29 data, target = X[idx, :], y[idx] 30 31 classifier = sklearn.base.clone(self.base_classifier) TypeError: only integer scalar arrays can be converted to a scalar index In this, X_train_dtm is a document-term-matrix, which is a sparse matrix, Is there any way to solve this problem.