Datasets:

Modalities:
Text
Languages:
English
Libraries:
Datasets
License:
asahi417 commited on
Commit
5c740ef
1 Parent(s): 37599eb
Files changed (1) hide show
  1. stats.py +7 -7
stats.py CHANGED
@@ -101,8 +101,13 @@ if __name__ == '__main__':
101
  e_dist_full.append(e_dist)
102
  data_size_full.append(data_size)
103
  config.append([min_e_freq, max_p_freq])
104
- with open(f"data/t_rex.clean.min_entity_{min_e_freq}_max_predicate_{max_p_freq}.jsonl", 'w') as f:
105
- f.write('\n'.join([json.dumps(i) for i in new_data]))
 
 
 
 
 
106
 
107
  # check statistics
108
  print("- Data Size")
@@ -119,20 +124,15 @@ if __name__ == '__main__':
119
  # plot predicate distribution
120
  df_p = pd.DataFrame([dict(enumerate(sorted(p.values(), reverse=True))) for p in p_dist_full]).T
121
  df_p.columns = [f"min entity: {mef}, max predicate: {mpf}" for mef, mpf in candidates]
122
- plt.figure()
123
  fig, axes = plt.subplots(2, 2, constrained_layout=True)
124
  fig.suptitle('Predicate Distribution over Different Configurations')
125
  for (x, y), mpf in zip([(0, 0), (0, 1), (1, 0), (1, 1)], [100, 50, 25, 10]):
126
- # fig = plt.figure()
127
  _df = df_p[[f"min entity: {mef}, max predicate: {mpf}" for mef in [1, 2, 3, 4]]]
128
  _df.columns = [f"min entity: {mef}" for mef in [1, 2, 3, 4]]
129
  ax = sns.lineplot(ax=axes[x, y], data=_df, linewidth=1)
130
  if mpf != 100:
131
  ax.legend_.remove()
132
  axes[x, y].set_title(f'max predicate: {mpf}')
133
- # ax.set(xlabel='unique predicates sorted by frequency', ylabel='number of triples', title='Predicate Distribution (max predicate: {mpf})')
134
- # ax.get_figure().savefig(f"data/stats.predicate_distribution.max_predicate_{mpf}.png", bbox_inches='tight')
135
- # ax.get_figure().clf()
136
  fig.supxlabel('unique predicates sorted by frequency')
137
  fig.supylabel('number of triples')
138
  fig.savefig("data/stats.predicate_distribution.png", bbox_inches='tight')
 
101
  e_dist_full.append(e_dist)
102
  data_size_full.append(data_size)
103
  config.append([min_e_freq, max_p_freq])
104
+ # save data
105
+ for s in ['train', 'validation', 'test']:
106
+ new_data_s = [i for i in new_data if i['split'] == s]
107
+ for i in new_data_s:
108
+ i.pop('split')
109
+ with open(f"data/t_rex.clean.min_entity_{min_e_freq}_max_predicate_{max_p_freq}.{s}.jsonl", 'w') as f:
110
+ f.write('\n'.join([json.dumps(i) for i in new_data_s]))
111
 
112
  # check statistics
113
  print("- Data Size")
 
124
  # plot predicate distribution
125
  df_p = pd.DataFrame([dict(enumerate(sorted(p.values(), reverse=True))) for p in p_dist_full]).T
126
  df_p.columns = [f"min entity: {mef}, max predicate: {mpf}" for mef, mpf in candidates]
 
127
  fig, axes = plt.subplots(2, 2, constrained_layout=True)
128
  fig.suptitle('Predicate Distribution over Different Configurations')
129
  for (x, y), mpf in zip([(0, 0), (0, 1), (1, 0), (1, 1)], [100, 50, 25, 10]):
 
130
  _df = df_p[[f"min entity: {mef}, max predicate: {mpf}" for mef in [1, 2, 3, 4]]]
131
  _df.columns = [f"min entity: {mef}" for mef in [1, 2, 3, 4]]
132
  ax = sns.lineplot(ax=axes[x, y], data=_df, linewidth=1)
133
  if mpf != 100:
134
  ax.legend_.remove()
135
  axes[x, y].set_title(f'max predicate: {mpf}')
 
 
 
136
  fig.supxlabel('unique predicates sorted by frequency')
137
  fig.supylabel('number of triples')
138
  fig.savefig("data/stats.predicate_distribution.png", bbox_inches='tight')