hyperparticle / graph-nlu Goto Github PK
View Code? Open in Web Editor NEWGraph NLU is a natural language understanding tool that leverages the power of graph databases
License: MIT License
Graph NLU is a natural language understanding tool that leverages the power of graph databases
License: MIT License
So, i already tried to run your babi_dialogue_ridge.ipynb notebooks, and so far i do some trial and error, but i just can't seem to solve this part of your code :
import operator
import scipy
import sklearn
eval_data = dev_data
gold=[]
guess=[]
indeces = list(set(eval_data.index))
print('num instances', len(indeces))
mrr = 0.0
for eid in indeces:
sub = rdata[rdata.index == eid] # grab the RE for this scene
target = compute_target(sub) # compose the predictions of each word to a target vector
distances = [(v['rname'], scipy.spatial.distance.cosine(target,v.ix[start_col:])) for i,v in restaurants.iterrows()]
distances.sort(key=operator.itemgetter(1))
guess += [distances[0][0]]
d = list(zip(*distances))[0]
mrr += compute_mrr(d, sub.iloc[-1].ix['target'])
gold += [sub.iloc[-1].ix['target']] # all the rows in sub have the same matrix
when i run it, it will give me this:
AttributeError Traceback (most recent call last)
in ()
13 sub = rdata[rdata.index == eid] # grab the RE for this scene
14 target = compute_target(sub) # compose the predictions of each word to a target vector
---> 15 distances = [(v['rname'], scipy.spatial.distance.cosine(target,v.ix[start_col:])) for i,v in restaurants.iterrows()]
16 distances.sort(key=operator.itemgetter(1))
17 guess += [distances[0][0]]
in (.0)
13 sub = rdata[rdata.index == eid] # grab the RE for this scene
14 target = compute_target(sub) # compose the predictions of each word to a target vector
---> 15 distances = [(v['rname'], scipy.spatial.distance.cosine(target,v.ix[start_col:])) for i,v in restaurants.iterrows()]
16 distances.sort(key=operator.itemgetter(1))
17 guess += [distances[0][0]]
~\Anaconda3\lib\site-packages\scipy\spatial\distance.py in cosine(u, v, w)
742 # cosine distance is also referred to as 'uncentered correlation',
743 # or 'reflective correlation'
--> 744 return correlation(u, v, w=w, centered=False)
745
746
~\Anaconda3\lib\site-packages\scipy\spatial\distance.py in correlation(u, v, w, centered)
693 u = u - umu
694 v = v - vmu
--> 695 uv = np.average(u * v, weights=w)
696 uu = np.average(np.square(u), weights=w)
697 vv = np.average(np.square(v), weights=w)
~\Anaconda3\lib\site-packages\numpy\lib\function_base.py in average(a, axis, weights, returned)
1127 if weights is None:
1128 avg = a.mean(axis)
-> 1129 scl = avg.dtype.type(a.size/avg.size)
1130 else:
1131 wgt = np.asanyarray(weights)
AttributeError: 'float' object has no attribute 'dtype'
Help, anyone?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.