Clustering Business and Residential network areas using KMeans

Viewed 39

I have a dataframe that contains the hourly Download volume of each eNodeB in one city. I have to calculate the Median Profile of DL Traffic of each eNodeB and cluster in the Residential zone or Business zone. These are the Median Weekly Signature that I have to recognize: Clustering Median Weekly Signature

This is the approach that I followed but I am not sure if it is correct or if something can be done better.

I considered only the time interval between 6 am and 12 pm because during the night the Median Weekly signatures are similar.

I created two new columns:

x['Hour'] = pd.to_datetime(x['Date']).dt.hour
x['Weekday'] = x['Date'].dt.weekday

Now I have a dataset like this ['ENODEB_ID', 'DL_VOL', 'Hour', 'Weekday']

I performed the median on the DL_VOL:

x = x.groupby(['ENODEB_ID', 'Hour', 'Weekday'], as_index=False).agg({'ENODEB_ID': 'first', 'DL_VOL': 'median', 'Hour': 'first', 'Weekday': 'first'})
x = x.reset_index(drop=True)

I enumerated hours in a week: (I am not sure that it's the correct approach)

x['Weekday'] = x['Weekday'].apply(lambda x: x * 24)
x['Hour'] = x['Hour'] + x['Weekday']

I performed the KMeans clustering on ['DL_VOL', 'Hour']

dl_array = x[['DL_VOL', 'Hour']]
kmeans_kwargs = {
    "init": "k-means++",
    "n_init": 10,
    "max_iter": 300,
    "random_state": 0,
    }
kmeans = KMeans(n_clusters=2).fit(dl_array)
identified_clusters = kmeans.fit_predict(dl_array)
0 Answers
Related