Skip to content
This repository was archived by the owner on Jul 27, 2018. It is now read-only.

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

@sanjeev8988

Description

@sanjeev8988

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions