MCPcopy Create free account
hub / github.com/modAL-python/modAL / enumerate_data

Function enumerate_data

modAL/utils/data.py:151–169  ·  view source on GitHub ↗

for i, x in enumerate_data(X): Depending on the data type of X, returns: * A 1xM matrix in case of scipy sparse NxM matrix X * pandas series in case of a pandas data frame X * row in case of list or numpy format

(X: modALinput)

Source from the content-addressed store, hash-verified

149
150
151def enumerate_data(X: modALinput):
152 """
153 for i, x in enumerate_data(X):
154
155 Depending on the data type of X, returns:
156
157 * A 1xM matrix in case of scipy sparse NxM matrix X
158 * pandas series in case of a pandas data frame X
159 * row in case of list or numpy format
160 """
161 if sp.issparse(X):
162 return enumerate(X.tocsr())
163 elif isinstance(X, pd.DataFrame):
164 return X.iterrows()
165 elif isinstance(X, np.ndarray) or isinstance(X, list):
166 # numpy arrays and lists can readily be enumerated
167 return enumerate(X)
168
169 raise TypeError("%s datatype is not supported" % type(X))
170
171
172def data_shape(X: modALinput):

Callers 1

expected_error_reductionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…