Provide January with the mood

Instead of an epilogue





This story happened quite a long time ago, but some of the details have become clear only now, which is why the time has come to tell it.





We will not dwell on the description of the types of parallel realities, many writers, lovers of alternative history, futurists and simply fans of such things have been doing this for a long time and successfully. Let's get straight to the point.





, . ., «» . , . . : « :





1) 1000 ;





2) .1 , .





« » , . , .









. : « » . . , .. notebook c Anaconda. , ython , .





, 1000 . , , , 1 . : « » « ».





:





#       
# Pivot        :     
Cnt_arr = pd.DataFrame()
Cnt_arr = F_Lst_FULL_df.pivot_table('DT_evnt', index='Date_event',dropna = False,fill_value=0, columns='Type',aggfunc='count')
# 
sns.set()  #  seaborn styles  
Cnt_arr.plot()
plt.xlabel(' ')
plt.ylabel(' ')
      
      







. , . . , — =1, , =2 .





« . » — , « , , – ?».





5 :





#         
sns.set_style("white")
gridobj = sns.lmplot(x='Date_event', y='DT_evnt', hue='Type', data=Cnt_arr, height=7, aspect=1.6, 
robust=True, palette='tab10', scatter_kws=dict(s=60, linewidths=.7, edgecolors='black'))
#            !
# :      0-100!
#    X (min, max)
Xmin=Cnt_arr['Date_event'].min()-1
Xmax=Cnt_arr['Date_event'].max()+1
#    Y (min, max)
Ymin=Cnt_arr['DT_evnt'].min()-1
Ymax=Cnt_arr['DT_evnt'].max()+1
# 
gridobj.set(xlim=(Xmin, Xmax), ylim=(Ymin, Ymax))
plt.title("       ", 
fontsize=20)
plt.show()
      
      



« . !» — , . : « ? , ?».





(, , ), : « , : 1) , ; 2) , .. .»





, , : « . »:





#  
#    ( )
F_Lst_FULL_df['Date_event'] = F_Lst_FULL_df['DT_evnt']-F_Lst_FULL_df['DT_evnt']%1
#     0    1-
F_Lst_FULL_df['Date_event'] = F_Lst_FULL_df['Date_event'].replace(0.0, 1.0)
#        0  1
F_Lst_FULL_df['PartOfDay'] = F_Lst_FULL_df['DT_evnt']%1
#   
F_Lst_FULL_df['NWeek'] = F_Lst_FULL_df['Date_event']//7%7+1
#      1-
F_Lst_FULL_df['D_Week'] = 1 + (F_Lst_FULL_df['Date_event']+6)%7
      
      



«» . «» « », :





#               
#  :
#     ()     - , ,  
#       - pivot
vis_date = F_Lst_FULL_df.pivot_table('DT_evnt', index=['D_Week','PartOfDay'],
                                     dropna = False,fill_value=0, aggfunc='count').reset_index()
Angle_dim  = vis_date['D_Week']   #  
Radius_dim = vis_date['PartOfDay']  #   (0-1)  24 
      
      



# 
#        
theta = 2 * np.pi * Angle_dim/7 #      Pi (3.14159265...)
#            
area = vis_date['DT_evnt']  #
colors = theta #      (1-,2-,3-...7-)

fig = plt.figure()
#   ,     :
#  : , 111 -   ,     ( )    Figure.
ax = fig.add_subplot(111, projection='polar')
#      ,       ( )
#  ,     !
xtks = pd.DataFrame()
xtks['val']=(2 * np.pi * Angle_dim/7).unique()   #   
xtks['mrk']=['','','','','','',''] #    
plt.xticks(xtks['val'].tolist(),xtks['mrk'].tolist())
c = ax.scatter(theta, Radius_dim, c=colors, s=area, cmap='hsv', alpha=0.75)
      
      



« – , » — , . « . ?» — , . « » — .









, :





#  (    0-1)
d = preprocessing.normalize(F_Lst_FULL_df,axis=0)
scaled_df = pd.DataFrame(d,columns = ['DT_evnt', 'Type', 'Date_event', 'PartOfDay','NWeek','D_Week'])
del d
      
      



(k-Menas)





: «N_Clstr .





N_Clstr=2 (/);





N_Clstr=7 ;





N_Clstr=31 ;





N_Clstr=14 .»





#  
N_Clstr=14
model = KMeans(n_clusters=N_Clstr)
#  
model.fit(scaled_df)
#     
all_predictions = model.predict(scaled_df)
      
      



( )





«», . . « TSNE 2D.





#     
model = TSNE()
#  
transformed = model.fit_transform(scaled_df)
#     
x_axis = transformed[:, 0]
y_axis = transformed[:, 1]
      
      



, ,





plt.title('K-Means   - : '+str(N_Clstr)+'.    ')
plt.scatter(x_axis, y_axis, c=scaled_df['Type'])
plt.show()
#    :
#     D_Week
#         PartOfDay
#     Date_event
#       NWeek
      
      







, , : «, , , , ( ), - ( ( ).





:





1) ,





2) .





, «» . , !».





Vibegallo was very pleased, smiling broadly, he asked: "Has the report been published yet?" "Of course, all this data is here." Alexander took out a folder from the top drawer.





"You are well done! I will definitely mark you when summing up the results of the year! " - said Vibegallo and resolutely went to the Troika's secretariat.








All Articles