In [14]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from datamanager import read_coms_from_txt, read_edges_from_txt, DataManager

In [15]:
edges = read_edges_from_txt("data/raw/blogcatalog_edges.txt", one_origin=True)
coms = read_coms_from_txt("data/raw/blogcatalog_coms.txt", one_origin=True)
dm = DataManager(edges, coms)

In [16]:
vis_nodes = [n for n, c in dm.ground_truth.items() if len(c) == 1]

In [34]:
gt_colors = [list(dm.ground_truth[n])[0] for n in range(len(vis_nodes))]

In [33]:
dm.ground_truth[10311] = set([19])

In [12]:
dm = pd.read_pickle("data/blogcatalog.data")


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in try_read(path, encoding)
     51             with open(path, 'rb') as fh:
---> 52                 return pkl.load(fh)
     53         except Exception:

ImportError: No module named 'datamanager'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in try_read(path, encoding)
     56                 with open(path, 'rb') as fh:
---> 57                     return pc.load(fh, encoding=encoding, compat=False)
     58 

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/compat/pickle_compat.py in load(fh, encoding, compat, is_verbose)
    116 
--> 117         return up.load()
    118     except:

/usr/lib/python3.5/pickle.py in load(self)
   1038                 assert isinstance(key, bytes_types)
-> 1039                 dispatch[key[0]](self)
   1040         except _Stop as stopinst:

/usr/lib/python3.5/pickle.py in load_global(self)
   1333         name = self.readline()[:-1].decode("utf-8")
-> 1334         klass = self.find_class(module, name)
   1335         self.append(klass)

/usr/lib/python3.5/pickle.py in find_class(self, module, name)
   1383                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384         __import__(module, level=0)
   1385         if self.proto >= 4:

ImportError: No module named 'datamanager'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in read_pickle(path)
     64     try:
---> 65         return try_read(path)
     66     except:

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in try_read(path, encoding)
     61                 with open(path, 'rb') as fh:
---> 62                     return pc.load(fh, encoding=encoding, compat=True)
     63 

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/compat/pickle_compat.py in load(fh, encoding, compat, is_verbose)
    116 
--> 117         return up.load()
    118     except:

/usr/lib/python3.5/pickle.py in load(self)
   1038                 assert isinstance(key, bytes_types)
-> 1039                 dispatch[key[0]](self)
   1040         except _Stop as stopinst:

/usr/lib/python3.5/pickle.py in load_global(self)
   1333         name = self.readline()[:-1].decode("utf-8")
-> 1334         klass = self.find_class(module, name)
   1335         self.append(klass)

/usr/lib/python3.5/pickle.py in find_class(self, module, name)
   1383                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384         __import__(module, level=0)
   1385         if self.proto >= 4:

ImportError: No module named 'datamanager'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in try_read(path, encoding)
     51             with open(path, 'rb') as fh:
---> 52                 return pkl.load(fh)
     53         except Exception:

ImportError: No module named 'datamanager'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in try_read(path, encoding)
     56                 with open(path, 'rb') as fh:
---> 57                     return pc.load(fh, encoding=encoding, compat=False)
     58 

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/compat/pickle_compat.py in load(fh, encoding, compat, is_verbose)
    116 
--> 117         return up.load()
    118     except:

/usr/lib/python3.5/pickle.py in load(self)
   1038                 assert isinstance(key, bytes_types)
-> 1039                 dispatch[key[0]](self)
   1040         except _Stop as stopinst:

/usr/lib/python3.5/pickle.py in load_global(self)
   1333         name = self.readline()[:-1].decode("utf-8")
-> 1334         klass = self.find_class(module, name)
   1335         self.append(klass)

/usr/lib/python3.5/pickle.py in find_class(self, module, name)
   1383                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384         __import__(module, level=0)
   1385         if self.proto >= 4:

ImportError: No module named 'datamanager'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-12-4e877b3a6515> in <module>()
----> 1 dm = pd.read_pickle("data/blogcatalog.data")

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in read_pickle(path)
     66     except:
     67         if PY3:
---> 68             return try_read(path, encoding='latin1')
     69         raise
     70 

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/io/pickle.py in try_read(path, encoding)
     60             except:
     61                 with open(path, 'rb') as fh:
---> 62                     return pc.load(fh, encoding=encoding, compat=True)
     63 
     64     try:

/home/nukui-s/env/keras/lib/python3.5/site-packages/pandas/compat/pickle_compat.py in load(fh, encoding, compat, is_verbose)
    115         up.is_verbose = is_verbose
    116 
--> 117         return up.load()
    118     except:
    119         raise

/usr/lib/python3.5/pickle.py in load(self)
   1037                     raise EOFError
   1038                 assert isinstance(key, bytes_types)
-> 1039                 dispatch[key[0]](self)
   1040         except _Stop as stopinst:
   1041             return stopinst.value

/usr/lib/python3.5/pickle.py in load_global(self)
   1332         module = self.readline()[:-1].decode("utf-8")
   1333         name = self.readline()[:-1].decode("utf-8")
-> 1334         klass = self.find_class(module, name)
   1335         self.append(klass)
   1336     dispatch[GLOBAL[0]] = load_global

/usr/lib/python3.5/pickle.py in find_class(self, module, name)
   1382             elif module in _compat_pickle.IMPORT_MAPPING:
   1383                 module = _compat_pickle.IMPORT_MAPPING[module]
-> 1384         __import__(module, level=0)
   1385         if self.proto >= 4:
   1386             return _getattribute(sys.modules[module], name)[0]

ImportError: No module named 'datamanager'

In [23]:
embed.shape


Out[23]:
(10312, 50)

In [37]:
weights = pd.read_pickle("save/nce_blogcatalog_e1_ed50_ne10_ns2_nw5_wl10_ws2_it1_nb500_adam_motif.weights")

In [38]:
embed = weights[0]

In [39]:
from sklearn.manifold import TSNE
from sklearn.preprocessing import normalize

In [40]:
tsne = TSNE(2)
embed_tsne = tsne.fit_transform(embed)

In [41]:
plt.scatter(embed_tsne[:,0], embed_tsne[:,1], c=gt_colors)


Out[41]:
<matplotlib.collections.PathCollection at 0x7f7dc2e75e10>

In [8]:
embed_norm = normalize(embed)

In [9]:
embed_norm_tsne = TSNE(learning_rate=100).fit_transform(embed_norm)

In [36]:
plt.scatter(embed_norm_tsne[:,0], embed_norm_tsne[:,1], c=gt_colors)


Out[36]:
<matplotlib.collections.PathCollection at 0x7f7dc2e912e8>

In [ ]: