转换小时数的最合乎逻辑的方法是分为两个变量,这些变量在接收器中来回摆动。想象一下24小时制时针的末尾位置。该x位置与该y位置一起从水槽中来回摆动。对于24小时制,您可以使用x=sin(2pi*hour/24),完成y=cos(2pi*hour/24)。  
您需要两个变量,否则会丢失正确的移动时间。这是由于正弦或余弦的导数随时间变化的事实,即(x,y)位置在单位圆中移动时位置平滑变化。
最后,考虑是否值得添加第三项功能来跟踪线性时间,该时间可以从第一条记录的开始(小时或分钟或秒)或Unix时间戳或类似的时间构建。然后,这三个功能可提供时间的周期性和线性进展的代理,例如,您可以提取诸如人的运动中的睡眠周期之类的周期性现象,以及诸如人口与时间之类的线性增长。
希望这可以帮助!
添加我为另一个答案生成的一些相关示例代码:
如果完成的示例:
# Enable inline plotting
%matplotlib inline
#Import everything I need...
import numpy as np
import matplotlib as mp
import matplotlib.pyplot as plt
import pandas as pd
# Grab some random times from here: https://www.random.org/clock-times/
# put them into a csv.
from pandas import DataFrame, read_csv
df = read_csv('/Users/angus/Machine_Learning/ipython_notebooks/times.csv',delimiter=':')
df['hourfloat']=df.hour+df.minute/60.0
df['x']=np.sin(2.*np.pi*df.hourfloat/24.)
df['y']=np.cos(2.*np.pi*df.hourfloat/24.)
df

def kmeansshow(k,X):
    from sklearn import cluster
    from matplotlib import pyplot
    import numpy as np
    kmeans = cluster.KMeans(n_clusters=k)
    kmeans.fit(X)
    labels = kmeans.labels_
    centroids = kmeans.cluster_centers_
    #print centroids
    for i in range(k):
        # select only data observations with cluster label == i
        ds = X[np.where(labels==i)]
        # plot the data observations
        pyplot.plot(ds[:,0],ds[:,1],'o')
        # plot the centroids
        lines = pyplot.plot(centroids[i,0],centroids[i,1],'kx')
        # make the centroid x's bigger
        pyplot.setp(lines,ms=15.0)
        pyplot.setp(lines,mew=2.0)
    pyplot.show()
    return centroids
现在让我们尝试一下:
kmeansshow(6,df[['x', 'y']].values)

您几乎看不到午夜之前的绿色群集中包含一些午夜之后的时间。现在让我们减少集群的数量,并显示午夜前后可以更详细地连接到单个集群中:
kmeansshow(3,df[['x', 'y']].values)

查看蓝色群集如何包含午夜前后的时间,这些时间聚集在同一群集中...
QED!