Pair distances among Fourier series

Distances between Fourier songs can be calculated indicated the frequencies and the amplitude, the available metrics can be found in distance.py module.

Distance between two songs is calculated with:

foucluster.distance.pair_distance(freq_x, features_x, freq_y, features_y, warp=None, distance_metric='l2_norm')[source]

Distance between song x (with frequencies and features) and song y is calculated.

Parameters:
  • freq_x (numpy.array) – frequencies of the song x.
  • features_x (numpy.array) – features (fourier amplitude) of song x.
  • freq_y (numpy.array) – frequencies of the song y.
  • features_y (numpy.array) – features (fourier amplitude) of song y.
  • warp – to calculate distance with warp between series, warp is float. If None, warp is not applied.
  • distance_metric (str) –

    name of the metric to use. Options are:

    • ’positive’: positive_error.
    • ’hellinger’: hellinger.
    • ’l2_norm’: l2_norm.
    • ’integrate’: integrate.
Returns:

distance in float.

For a distance of all the songs from a folder, in JSON format (just the output from foucluster.transform.all_songs,

foucluster.distance.distance_matrix(fourier_folder, warp=None, upper_limit=6000.0, distance_metric='l2_norm')[source]

A distance matrix with all the songs of a folder can be calculated.

Parameters:
  • fourier_folder
  • warp
  • upper_limit
  • distance_metric
Returns: