I want to run a clustering algorithm (svm, knn) on the ferquency spectrum data of a temperature sensor that published at irregular times. Here is the temperature data to take the FFT:

enter image description here I got the mean frequency for this temperature data as well as every temp sensor in the dataframe the average is every 18mins, longest distance between 2 points is 3hrs:

# group by short id
groups = df.groupby('id')
time_diff = groups.apply(lambda df: df.published_at.diff().mean())

Isolated the graphed temp data in a series:

signal = df.loc[df['_id'] == 'A1']['temperature']

Stored size of signal and mean sampling frequency as variables:

# sampling frequency: 
Fs = time_diff[:1]
Out[217]: 00:18:54.085526

# size 
S = signal.size
Then took the fft and calculated dBs

X = np.fft.fft(signal)
X_db = 20*np.log10(2*np.abs(X)/S)
And plotted the results:


enter image description here


enter image description here

These graphs intuitively do not look like they correspond to the original data. The objective with the fft is to then classify the data using SVM, however, I am not sure which variant fft is appropriate, nor if using the mean time frequency is either.


2 Answers 2


One option, in addition to the Non-uniform DFT that has been mentioned, is simply interpolating the data on a regularly-spaced grid by using a timestep approximately the same size as the smallest timestep, and then taking the DFT on the interpolated data.


You might want to look at the non uniform DFT


Google (nonuniform fft) and many useful references will be returned

and also



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.