Comments (4)
Thanks for your question. The three variables are list:
- d0 records the root (HC point)
distance to the origin
and its length equal tothe number of real epochs
- d2 records the mean
distance to the origin
and its length equal tothe number of real epochs
- hdo records all node distance to the origin and its length equal to
the number of nodes
from hie.
Thanks for your interest! The following is our code for the HDO figure, for your information.
from os.path import expanduser
import matplotlib.font_manager as font_manager
fontpath = expanduser('~/.local/share/fonts/LinLibertine_R.ttf')
prop = font_manager.FontProperties(fname=fontpath)
from matplotlib.pyplot import MultipleLocator
def one(f):
return '{:.1f}'.format(f)
def plot_HDO_distribution():
import numpy as np
import matplotlib.pyplot as plt
def get_colors(length, i):
if i == 0:
return plt.cm.plasma(np.linspace(-0.5, 1, length))
else:
return plt.cm.cool(np.linspace(-0.5, 1, length))
filepath = './results/distance_curv/icml23/dist_data_final/'
for dim in [16, 64, 256]:
for dataset in ['cora', 'citeseer', 'disease_nc', 'airport']:
data0 = np.loadtxt(filepath + '{}/{}_{}/{}_HDO0.txt'.format(dataset, dataset, dim, dataset))
data1 = np.loadtxt(filepath + '{}/{}_{}/{}_HDO1.txt'.format(dataset, dataset, dim, dataset))
key_nodes0 = np.loadtxt(filepath + '{}/{}_{}/{}_d20.txt'.format(dataset, dataset, dim, dataset))
key_nodes1 = np.loadtxt(filepath + '{}/{}_{}/{}_d21.txt'.format(dataset, dataset, dim, dataset))
dist0 = np.expand_dims(data0, 1)
dist1 = np.expand_dims(data1, 1)
minvalue0, center0, meanvalue0, maxvalue0 = key_nodes0
minvalue1, center1, meanvalue1, maxvalue1 = key_nodes1
plt.xlim([0, 8.5])
plt.ylim([0, 0.5])
margin = 0.1
freqs0 = []
freqs1 = []
for r in np.arange(0, 7, margin):
freqs0.append(np.where((dist0 > r) & (dist0 < r + margin))[0].shape[0])
freqs1.append(np.where((dist1 > r) & (dist1 < r + margin))[0].shape[0])
# colors0 = get_colors(len(freqs0), 1)
# colors1 = get_colors(len(freqs0), 0)
plt.bar(np.arange(0, 7, margin), np.array(freqs0) / np.sum(freqs0), color="#1F77B4", edgecolor="white",
width=margin, alpha=0.8, label='HGCN')
plt.bar(np.arange(0, 7, margin), np.array(freqs1) / np.sum(freqs1), color="#FE7E0D", edgecolor="white",
width=margin, alpha=0.9, label='Ours')
plt.legend(loc='upper right', prop={'size': 15})
row_labels = ['STATS', 'ROOT', 'MIN', 'MEAN', 'MAX'] # ROOT/ HC
table_vals = [['HGCN', 'Ours'],
[one(center0), one(center1)],
[one(minvalue0), one(minvalue1)],
[one(meanvalue0), one(meanvalue1)],
[one(maxvalue0), one(maxvalue1)]
]
the_table = plt.table(cellText=table_vals, colWidths=[0.12] * 2,
rowLabels=row_labels,
colLoc='center', rowLoc='left', cellLoc='center',
edges='closed',
bbox=(0.20, 0.55, 0.27, 0.4))
the_table.auto_set_font_size(False)
the_table.set_fontsize(14)
plt.title('{}'.format(dataset.capitalize()) + '($\mathcal{H}^{%d}$)' % dim, fontproperties=prop,
fontsize=20)
plt.yticks(fontproperties=prop, size=20)
plt.xticks(fontproperties=prop, size=20)
ax = plt.gca()
x_major_locator = MultipleLocator(1)
ax.xaxis.set_major_locator(x_major_locator)
plt.savefig('./results/icml2023/hdo/pdf/{}_{}.pdf'.format(dataset, dim), bbox_inches='tight', pad_inches=0)
plt.clf()
The HDO is computed by
if self.manifold.name == 'PoincareBall':
d2 = self.manifold.dist0(embeddings, c=c).mean()
from hie.
It is very clear. I greatly appreciate your help!
from hie.
I hope I'm not being too bothersome with another question, but could you please provide more details on how to compute 'self.d0', 'self.d2'
, and 'self.hdo'
? I guess that 'd2'
below might be used to compute 'self.hdo'
, but I'm unsure about the methods for calculating 'self.d0'
and 'self.d2'
in the NCModel
. Could you clarify the differences between them for me?"
if self.manifold.name == 'PoincareBall':
d2 = self.manifold.dist0(embeddings, c=c).mean()
class NCModel(BaseModel):
def __init__(self, args):
super(NCModel, self).__init__(args)
self.args = args
self.decoder = model2decoder[args.model](self.c, args)
if args.n_classes > 2:
self.f1_average = 'micro'
else:
self.f1_average = 'binary'
if args.pos_weight:
self.weights = torch.Tensor([1., 1. / data['labels'][idx_train].mean()])
else:
self.weights = torch.Tensor([1.] * args.n_classes)
if not args.cuda == -1:
self.weights = self.weights.to(args.device)
self.d0 = []
self.d2 = []
self.hdo = []
self.center = None
self.activation = lambda x: x
I would greatly appreciate any additional details you can provide. Thank you for your patience and assistance.
from hie.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hie.