librosa.util.FeatureExtractor¶
-
class
librosa.util.
FeatureExtractor
(function, target=None, iterate=True, **kwargs)[source]¶ Sci-kit learn wrapper class for feature extraction methods.
This class acts as a bridge between feature extraction functions and scikit-learn pipelines.
Warning
The
FeatureExtractor
object is deprecated as of 0.4.2, and will be removed in 0.5. Instead, usesklearn.preprocessing.FunctionTransformer
.Examples
>>> import sklearn.pipeline >>> # Build a mel-spectrogram extractor >>> MS = librosa.util.FeatureExtractor(librosa.feature.melspectrogram, ... sr=22050, n_fft=2048, ... n_mels=128, fmax=8000) >>> # And a log-amplitude extractor >>> LA = librosa.util.FeatureExtractor(librosa.logamplitude, ... ref_power=np.max) >>> # Chain them into a pipeline >>> Features = sklearn.pipeline.Pipeline([('MelSpectrogram', MS), ... ('LogAmplitude', LA)]) >>> # Load an audio file >>> y, sr = librosa.load(librosa.util.example_audio_file()) >>> # Apply the transformation to y >>> F = Features.transform([y])
Attributes
function (function) The feature extraction function to wrap. Example: librosa.feature.melspectrogram
target (str or None) If None, then function is called with the input data as the first positional argument. If str, then function is called with the input data as a keyword argument with key target. iterate (bool) If True, then function is applied iteratively to each item of the input. If False, then function is applied to the entire data stream simultaneously. This is useful for things like aggregation and stacking. kwargs (additional keyword arguments) Parameters to be passed through to function Methods
__init__
(function[, target, iterate])FeatureExtractor constructor fit
(*args, **kwargs)This function does nothing, and is provided for interface compatibility. fit_transform
(X[, y])Fit to data, then transform it. get_params
([deep])Get parameters for this estimator. set_params
(**kwargs)Update the parameters of the feature extractor. transform
(X)Applies the feature transformation to an array of input data.