# ajaanbaahu

6 questions

1

votes

2

answer

91

views

### How to find complexity for the following program?

So I am not a CS major and have hard time answering questions about a program's big(O) complexity.
I wrote the following routine to output the pairs of numbers in an array which sum to 0:
asd=[-3,-2,-3,2,3,2,4,5,8,-8,9,10,-4]
def sum_zero(asd):
for i in range(len(asd)):
for j in range(i,len(asd)):...

2

votes

1

answer

409

views

### Is there a limit in Gensim's Doc2Vec most_similar documents result set?

I have been experimenting with the doc2vec module for sometime now. I can train my model and have the trained model output similar documents for a given document as follows :
import re
modelloaded=Doc2Vec.load('model_all_doc_dm_1')
st = 'long description of a document as string'
doc = re.sub('[^a-zA...

4

votes

2

answer

3.6k

views

### How to find set of most frequently occurring word-pairs in a file using python?

I have a data set as follows:
'485','AlterNet','Statistics','Estimation','Narnia','Two and half men'
'717','I like Sheen', 'Narnia', 'Statistics', 'Estimation'
'633','MachineLearning','AI','I like Cars, but I also like bikes'
'717','I like Sheen','MachineLearning', 'regression', 'AI'
'136','MachineL...

1

votes

4

answer

1.1k

views

### How to group key:value pairs in a python dictionary based on certain range or interval?

I have a dictionary dict={14:1, 15:2, 16:4, 11:5, 20:1,22:5,25:2...} in python
How can I obtain a final result in any data structure(dictionary or something else) which looks like:
Final= [10-15:8, 16-20:5, 21-25:7....] or at least can sum up the values for keys falling under certain ranges of let s...

3

votes

1

answer

521

views

### How to speed up cosine similarity between a numpy array and a very very large matrix?

I have a problem where a need to calculate cosine similarities between a numpy array of shape (1, 300) and a matrix of shape (5000000, 300). I have tried multiple different flavors of codes and now I am wondering if there is a way to reduce the run time substantially :
Version 1 : I divide my big ma...

2

votes

1

answer

39

views

### How to build a nested Dictionary type datastructure for a time series like data in python?

I am trying to create a nested dictionary or similar structure for the following output :
2014-08-19 23 positive
2014-08-19 23 neutral
2014-08-19 23 positive
2014-08-19 23 bot
2014-08-19 23 positive
2014-08-19 23 positive
2014-08-19 23 bot
2014-08-19 23 positive
2014-08-19 24 positive
2014-08-19 24...