logger.debug("Feature vectorizer: %s", feat_vectorizer)
logger.debug("Features: %s", features)
is_libsvm = os.path.splitext(path)[1].lower() == ".libsvm"
// Check for valid features
if isinstance(features, np.ndarray):
if feat_vectorizer is None:
raise ValueError("If `feat_vectorizer` is unspecified, you must "
"pass a list of dicts for `features`.")
// Convert features to list of dicts if given an array-like & vectorizer
else:
features = feat_vectorizer.inverse_transform(features)
// Create feature vectorizer if unspecified and writing libsvm
elif is_libsvm:
feat_vectorizer = DictVectorizer(sparse=True)
feat_vectorizer.fit(features)
// Create label vectorizer if writing libsvm