1.0 Fingerprint_preliminary_tests_non_scaled-checkpoint



In [1]:
import fingerprint as fp


/usr/local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

In [2]:
s_all=fp.read_pickle("struct_all.pickle")

In [4]:
import pandas as pd
import tqdm

In [5]:
s250=s_all[0:250]
f_ones_250=[fp.get_phi(s250[i],obser="ones",rmax=12,delta=0.05) for i in tqdm.tqdm_notebook(range(len(s250)))]
f_Z_250=[fp.get_phi(s250[i],obser="Z",rmax=12,delta=0.05) for i in tqdm.tqdm_notebook(range(len(s250)))]
f_Chi_250=[fp.get_phi(s250[i],obser="Chi",rmax=12,delta=0.05) for i in tqdm.tqdm_notebook(range(len(s250)))]





In [6]:
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np

In [12]:
plt.figure(figsize=(10,10))
r=np.linspace(0.05,12,(12/0.05))
for i in range(2):
    lab=s250[i].composition
    plt.plot(r,f_Z_250[i],label=lab)
plt.legend()


Out[12]:
<matplotlib.legend.Legend at 0x12830d1d0>

In [14]:
df_ones=pd.DataFrame(f_ones_250)

In [15]:
metric_ones=np.array([np.dot(f_ones_250[i],f_ones_250[j]) for i in range(250) for j in range(250)]).reshape(250,250)

In [16]:
metric_Z=np.array([np.dot(f_ones_250[i],f_ones_250[j]) for i in range(250) for j in range(250)]).reshape(250,250)

In [17]:
dist=np.array([np.dot(f_ones_250[0],f_ones_250[i]) for i in range(250)])

In [18]:
df_ones=pd.DataFrame({"phi_ones":f_ones_250})

In [19]:
df_ones["dist"]=dist

dt_sort=df_ones.sort("dist").drop("dist",axis=1)


/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:3: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)
  app.launch_new_instance()

In [20]:
comps=[s250[i].composition for i in range(250)]

In [21]:
df_ones["Composition"]=comps

In [22]:
dt_sort=df_ones.sort("dist",ascending=False)


/usr/local/lib/python2.7/site-packages/ipykernel/__main__.py:1: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)
  if __name__ == '__main__':

In [23]:
dt_sort.set_index(np.arange(dt_sort.shape[0]),inplace=True)

In [24]:
for i in range(5):
    print dt_sort["Composition"][i]


Nb1 Ag1 O3
Ni1 Ag1 F3
Mg1 Ag1 F3
Zn1 Ag1 F3
S2 Bi1 Ag1

In [25]:
sorted_f_ones=dt_sort['phi_ones'].values

In [26]:
metric_ones=np.array([np.dot(sorted_f_ones[i],sorted_f_ones[j]) for i in range(250) for j in range(250)]).reshape(250,250)

In [27]:
#for i in range(250):    
#    metric_ones[i][i]=0
plt.figure(figsize=(15,15))
plt.imshow(metric_ones[0:250,0:250])
plt.colorbar()


Out[27]:
<matplotlib.colorbar.Colorbar at 0x11e4e2950>

In [73]:
import sklearn

In [74]:
from sklearn.metrics.pairwise import euclidean_distances

In [79]:
euclid=np.array([np.sqrt(np.dot(sorted_f_ones[i],sorted_f_ones[i])+np.dot(sorted_f_ones[j],sorted_f_ones[j])-2*np.dot(sorted_f_ones[i],sorted_f_ones[j])) for i in tqdm.tqdm_notebook(range(250)) for j in range(250)]).reshape(250,250)




In [82]:
plt.figure(figsize=(15,15))
plt.imshow(euclid[0:250,0:250])
plt.colorbar()


Out[82]:
<matplotlib.colorbar.Colorbar at 0x11a183790>