hollywoodfrancis/LopezLLM
Text Generation • Updated • 3
Answer stringlengths 18 5.54k | AnswerCount int64 1 31 | System Administration and DevOps int64 0 1 | Networking and APIs int64 0 1 | is_accepted bool 2
classes | Q_Score int64 0 1.72k | Tags stringlengths 6 90 | Title stringlengths 15 149 | Users Score int64 -11 327 | Database and SQL int64 0 1 | A_Id int64 5.3k 72.5M | Other int64 0 1 | Q_Id int64 5.14k 60M | Score float64 -1 1.2 | Question stringlengths 49 9.42k | Data Science and Machine Learning int64 1 1 | Web Development int64 0 1 | CreationDate stringlengths 23 23 | GUI and Desktop Applications int64 0 1 | Python Basics and Environment int64 0 1 | ViewCount int64 7 3.27M | Available Count int64 1 13 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
One thing to remember is that the Matlab compiler does not actually compile the Matlab code into native machine instructions. It simply wraps it into a standalone executable or a library with its own runtime engine that runs it. You would be able to run your code without Matlab installed, and you would be able to int... | 4 | 0 | 0 | false | 14 | python,c,matlab | Does anyone have experience creating a shared library in MATLAB? | 5 | 0 | 1,659,332 | 0 | 5,136 | 0.244919 | A researcher has created a small simulation in MATLAB and we want to make it accessible to others. My plan is to take the simulation, clean up a few things and turn it into a set of functions. Then I plan to compile it into a C library and use SWIG to create a Python wrapper. At that point, I should be able to call the... | 1 | 0 | 2008-08-07T18:47:00.000 | 1 | 0 | 2,313 | 3 |
I'd also try ctypes first.
Use the Matlab compiler to compile the code into C.
Compile the C code into a DLL.
Use ctypes to load and call code from this DLL
The hardest step is probably 1, but if you already know Matlab and have used the Matlab compiler, you should not have serious problems with it. | 4 | 0 | 0 | false | 14 | python,c,matlab | Does anyone have experience creating a shared library in MATLAB? | 2 | 0 | 138,534 | 0 | 5,136 | 0.099668 | A researcher has created a small simulation in MATLAB and we want to make it accessible to others. My plan is to take the simulation, clean up a few things and turn it into a set of functions. Then I plan to compile it into a C library and use SWIG to create a Python wrapper. At that point, I should be able to call the... | 1 | 0 | 2008-08-07T18:47:00.000 | 1 | 0 | 2,313 | 3 |
I won't help much but I remember that I was able to wrap a MATLAB simulation into DLL and then call it from a Delphi app. It worked really well. | 4 | 0 | 0 | true | 14 | python,c,matlab | Does anyone have experience creating a shared library in MATLAB? | 3 | 0 | 5,302 | 0 | 5,136 | 1.2 | A researcher has created a small simulation in MATLAB and we want to make it accessible to others. My plan is to take the simulation, clean up a few things and turn it into a set of functions. Then I plan to compile it into a C library and use SWIG to create a Python wrapper. At that point, I should be able to call the... | 1 | 0 | 2008-08-07T18:47:00.000 | 1 | 0 | 2,313 | 3 |
for loops in MATLAB used to be slow, but this is not true anymore.
So vectorizing is not always the miracle solution. Just use the profiler, and tic and toc functions to help you identify possible bottlenecks. | 7 | 0 | 0 | false | 14 | python,arrays,matlab,for-loop | Can parallel traversals be done in MATLAB just as in Python? | -2 | 0 | 138,886 | 0 | 49,307 | -0.057081 | Using the zip function, Python allows for loops to traverse multiple sequences in parallel.
for (x,y) in zip(List1, List2):
Does MATLAB have an equivalent syntax? If not, what is the best way to iterate over two parallel arrays at the same time using MATLAB? | 1 | 0 | 2008-09-08T08:25:00.000 | 0 | 1 | 7,417 | 1 |
__reduce_ex__ is what __reduce__ should have been but never became. __reduce_ex__ works like __reduce__ but the pickle protocol is passed. | 2 | 0 | 0 | false | 19 | python,pickle | What is the difference between __reduce__ and __reduce_ex__? | 9 | 0 | 150,318 | 0 | 150,284 | 1 | I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both? | 1 | 0 | 2008-09-29T19:31:00.000 | 0 | 1 | 9,908 | 1 |
You can try pygame, its very easy to handle and similar to SDL under c++ | 3 | 0 | 0 | false | 12 | python,animation,2d | 2D animation in Python | 3 | 0 | 1,568,711 | 0 | 169,810 | 0.197375 | I'm writing a simulator in Python, and am curious about options and opinions regarding basic 2D animations. By animation, I'm referring to rendering on the fly, not displaying prerendered images.
I'm currently using matplotlib (Wxagg backend), and it's possible that I'll be able to continue using it, but I suspect it w... | 1 | 0 | 2008-10-04T05:36:00.000 | 1 | 0 | 29,957 | 1 |
Seems to be pure inertia. Where it is in use, everyone is too busy to learn IDL or numpy in sufficient detail to switch, and don't want to rewrite good working programs. Luckily that's not strictly true, but true enough in enough places that Matlab will be around a long time. Like Fortran (in active use where i wor... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 5 | 0 | 181,127 | 0 | 179,904 | 0.047583 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
Matlab is good at doing number crunching. Also Matrix and matrix manipulation. It has many helpful built in libraries(depends on the what version) I think it is easier to use than python if you are going to be calculating equations. | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 2 | 0 | 1,890,839 | 0 | 179,904 | 0.019045 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
MATLAB is great for doing array manipulation, doing specialized math functions, and for creating nice plots quick.
I'd probably only use it for large programs if I could use a lot of array/matrix manipulation.
You don't have to worry about the IDE as much as in more formal packages, so it's easier for students without ... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 13 | 0 | 179,910 | 0 | 179,904 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
The main reason it is useful in industry is the plug-ins built on top of the core functionality. Almost all active Matlab development for the last few years has focused on these.
Unfortunately, you won't have much opportunity to use these in an academic environment. | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 4 | 0 | 179,932 | 0 | 179,904 | 0.038077 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
One reason MATLAB is popular with universities is the same reason a lot of things are popular with universities: there's a lot of professors familiar with it, and it's fairly robust.
I've spoken to a lot of folks who are especially interested in MATLAB's nascent ability to tap into the GPU instead of working serially. ... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 4 | 0 | 180,012 | 0 | 179,904 | 0.038077 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
I think you answered your own question when you noted that Matlab is "cool to work with matrixes and plotting things". Any application that requires a lot of matrix maths and visualisation will probably be easiest to do in Matlab.
That said, Matlab's syntax feels awkward and shows the language's age. In contrast, Pytho... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 3 | 0 | 181,295 | 0 | 179,904 | 0.028564 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
Hold everything. When's the last time you programed your calculator to play tetris? Did you actually think you could write anything you want in those 128k of RAM? Likely not. MATLAB is not for programming unless you're dealing with huge matrices. It's the graphing calculator you whip out when you've got Megabytes to Gi... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 15 | 0 | 181,492 | 0 | 179,904 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
I've been using matlab for many years in my research. It's great for linear algebra and has a large set of well-written toolboxes. The most recent versions are starting to push it into being closer to a general-purpose language (better optimizers, a much better object model, richer scoping rules, etc.).
This past s... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 34 | 0 | 193,386 | 0 | 179,904 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
It's been some time since I've used Matlab, but from memory it does provide (albeit with extra plugins) the ability to generate source to allow you to realise your algorithm on a DSP.
Since python is a general purpose programming language there is no reason why you couldn't do everything in python that you can do in ma... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 3 | 0 | 180,736 | 0 | 179,904 | 0.028564 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
Personally, I tend to think of Matlab as an interactive matrix calculator and plotting tool with a few scripting capabilities, rather than as a full-fledged programming language like Python or C. The reason for its success is that matrix stuff and plotting work out of the box, and you can do a few very specific things... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 7 | 0 | 181,274 | 0 | 179,904 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
I believe you have a very good point and it's one that has been raised in the company where I work. The company is limited in it's ability to apply matlab because of the licensing costs involved. One developer proved that Python was a very suitable replacement but it fell on ignorant ears because to the owners of those... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 6 | 0 | 180,017 | 0 | 179,904 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
The most likely reason that it's used so much in universities is that the mathematics faculty are used to it, understand it, and know how to incorporate it into their curriculum. | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 6 | 0 | 179,912 | 0 | 179,904 | 1 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
I know this question is old, and therefore may no longer be
watched, but I felt it was necessary to comment. As an
aerospace engineer at Georgia Tech, I can say, with no
qualms, that MATLAB is awesome. You can have it quickly
interface with your Excel spreadsheets to pull in data about
how high and fast rockets are fly... | 21 | 0 | 0 | false | 53 | python,matlab | What is MATLAB good for? Why is it so used by universities? When is it better than Python? | 4 | 0 | 1,113,065 | 0 | 179,904 | 0.038077 | I've been recently asked to learn some MATLAB basics for a class.
What does make it so cool for researchers and people that works in university?
I saw it's cool to work with matrices and plotting things... (things that can be done easily in Python using some libraries).
Writing a function or parsing a file is just pain... | 1 | 0 | 2008-10-07T19:11:00.000 | 0 | 1 | 200,558 | 13 |
If you hate numpy, get out RPy and your local copy of R, and use it instead.
(I would also echo to make you you really need to invert the matrix. In R, for example, linalg.solve and the solve() function don't actually do a full inversion, since it is unnecessary.) | 7 | 0 | 0 | false | 62 | python,algorithm,matrix,linear-algebra,matrix-inverse | Python Inverse of a Matrix | 1 | 0 | 213,717 | 1 | 211,160 | 0.028564 | How do I get the inverse of a matrix in python? I've implemented it myself, but it's pure python, and I suspect there are faster modules out there to do it. | 1 | 0 | 2008-10-17T05:30:00.000 | 0 | 0 | 125,109 | 1 |
Using deltaX
if deltax between 2 and 10 half increment
if deltax between 10 and 20 unit increment
if smaller than 2 we multiply by 10 and test again
if larger than 20 we divide
Then we get the position of the first unit or half increment on the width using xmin.
I still need to test this solution. | 5 | 0 | 0 | false | 2 | python,algorithm,math | Ticking function grapher | 0 | 0 | 346,873 | 0 | 346,823 | 0 | I am trying to figure out the following problem.
I am building Yet another math function grapher, The function is drawn on its predefined x,y range, that's all good.
Now I am working on the background and the ticking of X, Y axes (if any axes are shown).
I worked out the following.
I have a fixed width of 250 p
The ti... | 1 | 0 | 2008-12-06T21:40:00.000 | 0 | 0 | 239 | 1 |
The following is a description of random weighted selection of an element of a
set (or multiset, if repeats are allowed), both with and without replacement in O(n) space
and O(log n) time.
It consists of implementing a binary search tree, sorted by the elements to be
selected, where each node of the tree contains:
... | 9 | 0 | 0 | false | 52 | python,algorithm,random,random-sample | Weighted random selection with and without replacement | 4 | 0 | 9,827,070 | 0 | 352,670 | 0.088656 | Recently I needed to do weighted random selection of elements from a list, both with and without replacement. While there are well known and good algorithms for unweighted selection, and some for weighted selection without replacement (such as modifications of the resevoir algorithm), I couldn't find any good algorithm... | 1 | 0 | 2008-12-09T13:15:00.000 | 0 | 0 | 32,149 | 2 |
This is an old question for which numpy now offers an easy solution so I thought I would mention it. Current version of numpy is version 1.2 and numpy.random.choice allows the sampling to be done with or without replacement and with given weights. | 9 | 0 | 0 | false | 52 | python,algorithm,random,random-sample | Weighted random selection with and without replacement | 1 | 0 | 66,553,611 | 0 | 352,670 | 0.022219 | Recently I needed to do weighted random selection of elements from a list, both with and without replacement. While there are well known and good algorithms for unweighted selection, and some for weighted selection without replacement (such as modifications of the resevoir algorithm), I couldn't find any good algorithm... | 1 | 0 | 2008-12-09T13:15:00.000 | 0 | 0 | 32,149 | 2 |
Maybe you can use Python Imaging Library (PIL).
Also have a look at PyX, but this library is meant to output to PDF, ... | 5 | 0 | 0 | false | 3 | python,python-3.x,plot,graphing,scatter-plot | Are there any graph/plotting/anything-like-that libraries for Python 3.0? | 1 | 0 | 421,947 | 0 | 418,835 | 0.039979 | As per the title. I am trying to create a simple scater plot, but haven't found any Python 3.0 libraries that can do it. Note, this isn't for a website, so the web ones are a bit useless. | 1 | 0 | 2009-01-07T01:12:00.000 | 0 | 0 | 1,540 | 1 |
In addition to the previous replies, I would like to introduce another function.
numpy.random.shuffle as well as random.shuffle perform in-place shuffling. However, if you want to return a shuffled array numpy.random.permutation is the function to use. | 11 | 0 | 0 | false | 325 | python,arrays,random,shuffle | Shuffle an array with python, randomize array item order with python | 4 | 0 | 40,674,024 | 0 | 473,973 | 0.072599 | What's the easiest way to shuffle an array with python? | 1 | 0 | 2009-01-23T18:34:00.000 | 0 | 1 | 285,289 | 1 |
I would open seven file streams as accumulating them might be quite memory extensive if it's a lot of data. Of course that is only an option if you can sort them live and don't first need all data read to do the sorting. | 2 | 0 | 0 | false | 0 | python,file-io | Multiple output files | 2 | 0 | 555,159 | 0 | 555,146 | 0.197375 | edit: Initially I was trying to be general but it came out vague. I've included more detail below.
I'm writing a script that pulls in data from two large CSV files, one of people's schedules and the other of information about their schedules. The data is mined and combined to eventually create pajek format graphs for ... | 1 | 0 | 2009-02-17T00:29:00.000 | 0 | 0 | 593 | 1 |
cPickle will be the fastest since it is saved in binary and no real python code has to be parsed.
Other advantates are that it is more secure (since it does not execute commands) and you have no problems with setting $PYTHONPATH correctly. | 6 | 0 | 0 | false | 11 | python,serialization,caching | Python list serialization - fastest method | 1 | 0 | 556,961 | 1 | 556,730 | 0.033321 | I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.
Which is the fastest method, and why?
Using import on a .py file that just contains th... | 1 | 0 | 2009-02-17T13:16:00.000 | 0 | 0 | 8,359 | 1 |
In addition to df's answer, if you want to know the specific prices that are above the base prices, you can do:
prices[prices > (1.10 * base_prices)] | 4 | 0 | 0 | false | 1 | python,numpy | Statistics with numpy | 1 | 0 | 570,197 | 0 | 570,137 | 0.049958 | I am working at some plots and statistics for work and I am not sure how I can do some statistics using numpy: I have a list of prices and another one of basePrices. And I want to know how many prices are with X percent above basePrice, how many are with Y percent above basePrice.
Is there a simple way to do that using... | 1 | 0 | 2009-02-20T16:04:00.000 | 0 | 0 | 1,834 | 1 |
Do you have the possibility of using Jython? I just mention it because using TreeMap, TreeSet, etc. is trivial. Also if you're coming from a Java background and you want to head in a Pythonic direction Jython is wonderful for making the transition easier. Though I recognise that use of TreeSet in this case would not ... | 7 | 0 | 0 | false | 22 | python,data-structures | Python equivalent to java.util.SortedSet? | 0 | 0 | 20,666,684 | 0 | 628,192 | 0 | Does anybody know if Python has an equivalent to Java's SortedSet interface?
Heres what I'm looking for: lets say I have an object of type foo, and I know how to compare two objects of type foo to see whether foo1 is "greater than" or "less than" foo2. I want a way of storing many objects of type foo in a list L, so th... | 1 | 1 | 2009-03-09T21:58:00.000 | 0 | 1 | 9,278 | 1 |
Back-propagation works by minimizing the error. However, you can really minimize whatever you want. So, you could use back-prop-like update rules to find the Artificial Neural Network inputs that minimize the output.
This is a big question, sorry for the short answer. I should also add that my suggested approach sou... | 8 | 0 | 0 | false | 10 | python,artificial-intelligence,neural-network,minimization | Can a neural network be used to find a functions minimum(a)? | 3 | 0 | 13,611,588 | 0 | 652,283 | 0.07486 | I had been interested in neural networks for a bit and thought about using one in python for a light project that compares various minimization techniques in a time domain (which is fastest).
Then I realized I didn't even know if a NN is good for minimization. What do you think? | 1 | 0 | 2009-03-16T21:53:00.000 | 0 | 0 | 7,231 | 4 |
They're pretty bad for the purpose; one of the big problems of neural networks is that they get stuck in local minima. You might want to look into support vector machines instead. | 8 | 0 | 0 | false | 10 | python,artificial-intelligence,neural-network,minimization | Can a neural network be used to find a functions minimum(a)? | 0 | 0 | 652,348 | 0 | 652,283 | 0 | I had been interested in neural networks for a bit and thought about using one in python for a light project that compares various minimization techniques in a time domain (which is fastest).
Then I realized I didn't even know if a NN is good for minimization. What do you think? | 1 | 0 | 2009-03-16T21:53:00.000 | 0 | 0 | 7,231 | 4 |
The training process of a back-propagation neural network works by minimizing the error from the optimal result. But having a trained neural network finding the minimum of an unknown function would be pretty hard.
If you restrict the problem to a specific function class, it could work, and be pretty quick too. Neural n... | 8 | 0 | 0 | false | 10 | python,artificial-intelligence,neural-network,minimization | Can a neural network be used to find a functions minimum(a)? | 1 | 0 | 652,327 | 0 | 652,283 | 0.024995 | I had been interested in neural networks for a bit and thought about using one in python for a light project that compares various minimization techniques in a time domain (which is fastest).
Then I realized I didn't even know if a NN is good for minimization. What do you think? | 1 | 0 | 2009-03-16T21:53:00.000 | 0 | 0 | 7,231 | 4 |
Neural networks are classifiers. They separate two classes of data elements. They learn this separation (usually) by preclassified data elements. Thus, I say: No, unless you do a major stretch beyond breakage. | 8 | 0 | 0 | true | 10 | python,artificial-intelligence,neural-network,minimization | Can a neural network be used to find a functions minimum(a)? | -5 | 0 | 652,362 | 0 | 652,283 | 1.2 | I had been interested in neural networks for a bit and thought about using one in python for a light project that compares various minimization techniques in a time domain (which is fastest).
Then I realized I didn't even know if a NN is good for minimization. What do you think? | 1 | 0 | 2009-03-16T21:53:00.000 | 0 | 0 | 7,231 | 4 |
I found that array.fromfile is the fastest methods for homogeneous data. | 4 | 0 | 0 | false | 6 | python,input,binaryfiles | Most efficient way of loading formatted binary files in Python | 0 | 0 | 703,588 | 1 | 703,262 | 0 | I have binary files no larger than 20Mb in size that have a header section and then a data section containing sequences of uchars. I have Numpy, SciPy, etc. and each library has different ways of loading in the data. Any suggestions for the most efficient methods I should use? | 1 | 0 | 2009-03-31T22:03:00.000 | 0 | 0 | 450 | 1 |
There was a company offering a dump of the social graph, but it was taken down and no longer available. As you already realized - it is kind of hard, as it is changing all the time.
I would recommend checking out their social_graph api methods as they give the most info with the least API calls. | 3 | 0 | 0 | true | 3 | python,twitter,dump,social-graph | Twitter Data Mining: Degrees of separation | 0 | 0 | 817,451 | 0 | 785,327 | 1.2 | What ready available algorithms could I use to data mine twitter to find out the degrees of separation between 2 people on twitter.
How does it change when the social graph keeps changing and updating constantly.
And then, is there any dump of twitter social graph data which I could use rather than making so many API c... | 1 | 0 | 2009-04-24T10:30:00.000 | 0 | 0 | 2,436 | 1 |
I don't believe there is anything standard (but I could be wrong, I don't keep up with python that closely).
It's very easy to implement though, and you may want to build on top of the numpy array as a container for it anyway, which gives you lots of good (and efficient) bits and pieces. | 2 | 0 | 0 | false | 6 | python,vector | Is there a Vector3 type in Python? | 2 | 0 | 786,758 | 0 | 786,691 | 0.197375 | I quickly checked numPy but it looks like it's using arrays as vectors? I am looking for a proper Vector3 type that I can instance and work on. | 1 | 0 | 2009-04-24T16:46:00.000 | 0 | 0 | 12,341 | 1 |
There is a great library for this task called: pymatreader.
Just do as follows:
Install the package: pip install pymatreader
Import the relevant function of this package: from pymatreader import read_mat
Use the function to read the matlab struct: data = read_mat('matlab_struct.mat')
use data.keys() to locate where... | 12 | 0 | 0 | false | 508 | python,matlab,file-io,scipy,mat-file | Read .mat files in Python | 12 | 0 | 66,453,257 | 0 | 874,461 | 1 | Is it possible to read binary MATLAB .mat files in Python?
I've seen that SciPy has alleged support for reading .mat files, but I'm unsuccessful with it. I installed SciPy version 0.7.0, and I can't find the loadmat() method. | 1 | 0 | 2009-05-17T12:02:00.000 | 0 | 0 | 566,507 | 1 |
I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed.
Is the data only ever going to be parsed by Python programs? If not, then I'd avoid pickle et al (shelve and marshal) since they're very Python specific. JS... | 5 | 0 | 0 | false | 3 | python,file-io,csv,multidimensional-array,fileparsing | Simple data storing in Python | 2 | 0 | 875,525 | 0 | 875,228 | 0.07983 | I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed.
I'm sure python has library for doing such a task easily but so far all the approaches I have found seemed like it would have been sloppy to get it to work a... | 1 | 0 | 2009-05-17T19:00:00.000 | 0 | 1 | 5,460 | 1 |
I attach an simple routine to convert a npy to an image. Works 100% and it is a piece of cake!
from PIL import Image
import matplotlib
img = np.load('flair1_slice75.npy')
matplotlib.image.imsave("G1_flair_75.jpeg", img) | 21 | 0 | 0 | false | 370 | python,image,numpy | Saving a Numpy array as an image | 0 | 0 | 72,331,083 | 0 | 902,761 | 0 | I have a matrix in the type of a Numpy array. How would I write it to disk it as an image? Any format works (png, jpeg, bmp...). One important constraint is that PIL is not present. | 1 | 0 | 2009-05-24T00:08:00.000 | 0 | 0 | 767,103 | 1 |
How about using a formular like r' = r-(g+b)? | 3 | 0 | 0 | false | 1 | python,image-processing,opencv,color-space | How to isolate a single color in an image | 0 | 0 | 968,351 | 0 | 968,317 | 0 | I'm using the python OpenCV bindings and at the moment I try to isolate a colorrange. That means I want to filter out everything that is not reddish.
I tried to take only the red color channel but this includes the white spaces in the Image too.
What is a good way to do that? | 1 | 0 | 2009-06-09T05:36:00.000 | 0 | 0 | 2,798 | 2 |
Use the HSV colorspace. Select pixels that have an H value in the range that you consider to contain "red," and an S value large enough that you do not consider it to be neutral, maroon, brown, or pink. You might also need to throw out pixels with low V's. The H dimension is a circle, and red is right where the circ... | 3 | 0 | 0 | false | 1 | python,image-processing,opencv,color-space | How to isolate a single color in an image | 1 | 0 | 2,204,755 | 0 | 968,317 | 0.066568 | I'm using the python OpenCV bindings and at the moment I try to isolate a colorrange. That means I want to filter out everything that is not reddish.
I tried to take only the red color channel but this includes the white spaces in the Image too.
What is a good way to do that? | 1 | 0 | 2009-06-09T05:36:00.000 | 0 | 0 | 2,798 | 2 |
I don't really know about NER, but judging from that example, you could make an algorithm that searched for capital letters in the words or something like that. For that I would recommend regex as the most easy to implement solution if you're thinking small.
Another option is to compare the texts with a database, wich ... | 6 | 0 | 0 | false | 22 | php,python,extract,analysis,named-entity-recognition | Algorithms for named entity recognition | -11 | 0 | 1,026,976 | 0 | 1,026,925 | -1 | I would like to use named entity recognition (NER) to find adequate tags for texts in a database.
I know there is a Wikipedia article about this and lots of other pages describing NER, I would preferably hear something about this topic from you:
What experiences did you make with the various algorithms?
Which algorith... | 1 | 0 | 2009-06-22T12:26:00.000 | 0 | 0 | 9,656 | 1 |
I don't think there are methods that give you a metric exactly for what you want, but the methods that it has, like RMS, takes you a long way there. To do things with color, you can split the image into one layer per color, and get the RMS on each layer, which tells you some of the things you want to know. You can also... | 1 | 0 | 0 | false | 4 | python,python-imaging-library | Simple Image Metrics with PIL | 1 | 0 | 1,037,217 | 0 | 1,037,090 | 0.197375 | I want to process uploaded photos with PIL and determine some "soft" image metrics like:
is the image contrastful or dull?
colorful or monochrome?
bright or dark?
is the image warm or cold (regarding light temperature)?
is there a dominant hue?
the metrics should be measured in a rating-style, e.g. colorful++++ for a... | 1 | 0 | 2009-06-24T08:30:00.000 | 0 | 0 | 609 | 1 |
test = csv.reader(c.split('\n')) | 4 | 0 | 0 | false | 7 | python,csv | python csv question | 2 | 0 | 1,083,367 | 0 | 1,083,364 | 0.099668 | i'm just testing out the csv component in python, and i am having some trouble with it.
I have a fairly standard csv string, and the default options all seems to fit with my test, but the result shouldn't group 1, 2, 3, 4 in a row and 5, 6, 7, 8 in a row?
Thanks a lot for any enlightenment provided!
Python 2.6.2 (r26... | 1 | 0 | 2009-07-05T02:49:00.000 | 0 | 1 | 850 | 2 |
csv.reader expects an iterable. You gave it "1, 2, 3, 4\n 5, 6, 7, 8\n"; iteration produces characters. Try giving it ["1, 2, 3, 4\n", "5, 6, 7, 8\n"] -- iteration will produce lines. | 4 | 0 | 0 | true | 7 | python,csv | python csv question | 8 | 0 | 1,083,376 | 0 | 1,083,364 | 1.2 | i'm just testing out the csv component in python, and i am having some trouble with it.
I have a fairly standard csv string, and the default options all seems to fit with my test, but the result shouldn't group 1, 2, 3, 4 in a row and 5, 6, 7, 8 in a row?
Thanks a lot for any enlightenment provided!
Python 2.6.2 (r26... | 1 | 0 | 2009-07-05T02:49:00.000 | 0 | 1 | 850 | 2 |
You could write the matrix in Python to a CSV file and read it in MATLAB using csvread. | 7 | 0 | 0 | false | 51 | python,matlab,file-io,import,matrix | Matrix from Python to MATLAB | 4 | 0 | 1,095,296 | 1 | 1,095,265 | 0.113791 | I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this?
Thanks! | 1 | 0 | 2009-07-07T22:55:00.000 | 0 | 0 | 69,405 | 2 |
I would probably use numpy.savetxt('yourfile.mat',yourarray) in Python
and then yourarray = load('yourfile.mat') in MATLAB. | 7 | 0 | 0 | false | 51 | python,matlab,file-io,import,matrix | Matrix from Python to MATLAB | 5 | 0 | 7,737,622 | 1 | 1,095,265 | 0.141893 | I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this?
Thanks! | 1 | 0 | 2009-07-07T22:55:00.000 | 0 | 0 | 69,405 | 2 |
To work out the "worst" case, instead of using entropic I am looking to the partition that has the maximum number of elements, then select the try that is a minimum for this maximum => This will give me the minimum number of remaining possibility when I am not lucky (which happens in the worst case).
This always solve ... | 9 | 0 | 0 | false | 38 | python,algorithm | How to solve the "Mastermind" guessing game? | 0 | 0 | 9,515,347 | 0 | 1,185,634 | 0 | How would you create an algorithm to solve the following puzzle, "Mastermind"?
Your opponent has chosen four different colours from a set of six (yellow, blue, green, red, orange, purple). You must guess which they have chosen, and in what order. After each guess, your opponent tells you how many (but not which) of the... | 1 | 0 | 2009-07-26T21:43:00.000 | 0 | 0 | 37,167 | 1 |
I apply hierarchical Bayes models in R in combination with JAGS (Linux) or sometimes WinBUGS (Windows, or Wine). Check out the book of Andrew Gelman, as referred to above. | 7 | 0 | 0 | false | 12 | python,r,statistics | Hierarchical Bayes for R or Python | 2 | 0 | 1,832,314 | 1 | 1,191,689 | 0.057081 | Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out ther... | 1 | 0 | 2009-07-28T02:43:00.000 | 0 | 0 | 8,690 | 3 |
This answer comes almost ten years late, but it will hopefully help someone in the future.
The brms package in R is a very good option for Bayesian hierarchical/multilevel models, using a syntax very similar to the lme4 package.
The brms package uses the probabilistic programming language Stan in the back to do the inf... | 7 | 0 | 0 | false | 12 | python,r,statistics | Hierarchical Bayes for R or Python | 0 | 0 | 55,978,470 | 1 | 1,191,689 | 0 | Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out ther... | 1 | 0 | 2009-07-28T02:43:00.000 | 0 | 0 | 8,690 | 3 |
The lme4 package, which estimates hierarchical models using frequentist methods, has a function called mcmcsamp that allows you to sample from the posterior distribution of the model using MCMC. This currently works only for linear models, quite unfortunately. | 7 | 0 | 0 | false | 12 | python,r,statistics | Hierarchical Bayes for R or Python | 0 | 0 | 1,197,766 | 1 | 1,191,689 | 0 | Hierarchical Bayes models are commonly used in Marketing, Political Science, and Econometrics. Yet, the only package I know of is bayesm, which is really a companion to a book (Bayesian Statistics and Marketing, by Rossi, et al.) Am I missing something? Is there a software package for R or Python doing the job out ther... | 1 | 0 | 2009-07-28T02:43:00.000 | 0 | 0 | 8,690 | 3 |
Probably either a dict of list or a list of dict. Personally, I'd go with the former. So, parse the heading row of the CSV to get a dict from column heading to column index. Then when you're reading through each row, work out what index you're at, grab the column heading, and then append to the end of the list for that... | 6 | 0 | 0 | false | 2 | python,file,csv | Whats the best way of putting tabular data into python? | 0 | 0 | 1,199,371 | 0 | 1,199,350 | 0 | I have a CSV file which I am processing and putting the processed data into a text file.
The entire data that goes into the text file is one big table(comma separated instead of space). My problem is How do I remember the column into which a piece of data goes in the text file?
For eg. Assume there is a column called '... | 1 | 0 | 2009-07-29T10:44:00.000 | 0 | 1 | 798 | 2 |
Is SQLite an option for you? I know that you have CSV input and output. However, you can import all the data into the SQLite database. Then do all the necessary processing with the power of SQL. Then you can export the results as CSV. | 6 | 0 | 0 | false | 2 | python,file,csv | Whats the best way of putting tabular data into python? | 1 | 0 | 1,199,409 | 0 | 1,199,350 | 0.033321 | I have a CSV file which I am processing and putting the processed data into a text file.
The entire data that goes into the text file is one big table(comma separated instead of space). My problem is How do I remember the column into which a piece of data goes in the text file?
For eg. Assume there is a column called '... | 1 | 0 | 2009-07-29T10:44:00.000 | 0 | 1 | 798 | 2 |
If you're using numpy 1.3, there's also numpy.lib.recfunctions.append_fields().
For many installations, you'll need to import numpy.lib.recfunctions to access this. import numpy will not allow one to see the numpy.lib.recfunctions | 2 | 0 | 0 | true | 22 | python,numpy | Adding a field to a structured numpy array | 20 | 0 | 1,208,039 | 0 | 1,201,817 | 1.2 | What is the cleanest way to add a field to a structured numpy array? Can it be done destructively, or is it necessary to create a new array and copy over the existing fields? Are the contents of each field stored contiguously in memory so that such copying can be done efficiently? | 1 | 0 | 2009-07-29T17:24:00.000 | 0 | 0 | 9,033 | 1 |
You have to encode your input and your output to something that can be represented by the neural network units. ( for example 1 for "x has a certain property p" -1 for "x doesn't have the property p" if your units' range is in [-1, 1])
The way you encode your input and the way you decode your output depends on what you... | 4 | 0 | 0 | true | 3 | python,neural-network | Neural net input/output | 3 | 0 | 1,205,509 | 0 | 1,205,449 | 1.2 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big ... | 1 | 0 | 2009-07-30T09:22:00.000 | 0 | 0 | 671 | 4 |
You have to add the number of units for input and output you need for the problem. If the unknown function to approximate depends on n parameter, you will have n input units. The number of output units depends on the nature of the funcion. For real functions with n real parameters you will have one output unit.
Some pr... | 4 | 0 | 0 | false | 3 | python,neural-network | Neural net input/output | 0 | 0 | 20,683,280 | 0 | 1,205,449 | 0 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big ... | 1 | 0 | 2009-07-30T09:22:00.000 | 0 | 0 | 671 | 4 |
Your features must be decomposed into parts that can be represented as real numbers. The magic of a Neural Net is it's a black box, the correct associations will be made (with internal weights) during the training
Inputs
Choose as few features as are needed to accurately describe the situation, then decompose each int... | 4 | 0 | 0 | false | 3 | python,neural-network | Neural net input/output | 2 | 0 | 1,207,505 | 0 | 1,205,449 | 0.099668 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big ... | 1 | 0 | 2009-07-30T09:22:00.000 | 0 | 0 | 671 | 4 |
More complex data usually means adding more neurons in the input and output layers.
You can feed each "field" of your register, properly encoded as a real value (normalized, etc.) to each input neuron, or maybe you can even decompose even further into bit fields, assigning saturated inputs of 1 or 0 to the neurons... f... | 4 | 0 | 0 | false | 3 | python,neural-network | Neural net input/output | 0 | 0 | 1,206,597 | 0 | 1,205,449 | 0 | Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types
i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out
if someone could provide examples in python that would be a big ... | 1 | 0 | 2009-07-30T09:22:00.000 | 0 | 0 | 671 | 4 |
Yes, SciPy/Numpy is mostly concerned about arrays.
If you can tolerate an approximate solution, and your functions only operate over a range of value (not infinite) you can fill an array with the values and convolve the arrays.
If you want something more "correct" calculus-wise you would probably need a powerful solver... | 2 | 0 | 0 | true | 2 | python,convolution | Convolution of two functions in Python | 1 | 0 | 1,226,509 | 0 | 1,222,147 | 1.2 | I will have to implement a convolution of two functions in Python, but SciPy/Numpy appear to have functions only for the convolution of two arrays.
Before I try to implement this by using the the regular integration expression of convolution, I would like to ask if someone knows of an already available module that perf... | 1 | 0 | 2009-08-03T12:42:00.000 | 0 | 0 | 8,768 | 1 |
Are you likely to need all rows in order or will you want only specific known rows?
If you need to read all the data there isn't much advantage to having it in a database.
edit: If the code fits in memory then a simple CSV is fine. Plain text data formats are always easier to deal with than opaque ones if you can use t... | 4 | 0 | 0 | false | 0 | python,database,database-design,file-io | Store data series in file or database if I want to do row level math operations? | 0 | 1 | 1,241,784 | 0 | 1,241,758 | 0 | I'm developing an app that handle sets of financial series data (input as csv or open document), one set could be say 10's x 1000's up to double precision numbers (Simplifying, but thats what matters).
I plan to do operations on that data (eg. sum, difference, averages etc.) as well including generation of say another ... | 1 | 0 | 2009-08-06T21:58:00.000 | 0 | 0 | 581 | 3 |
What matters most if all data will fit simultaneously into memory. From the size that you give, it seems that this is easily the case (a few megabytes at worst).
If so, I would discourage using a relational database, and do all operations directly in Python. Depending on what other processing you need, I would probably... | 4 | 0 | 0 | false | 0 | python,database,database-design,file-io | Store data series in file or database if I want to do row level math operations? | 0 | 1 | 1,241,787 | 0 | 1,241,758 | 0 | I'm developing an app that handle sets of financial series data (input as csv or open document), one set could be say 10's x 1000's up to double precision numbers (Simplifying, but thats what matters).
I plan to do operations on that data (eg. sum, difference, averages etc.) as well including generation of say another ... | 1 | 0 | 2009-08-06T21:58:00.000 | 0 | 0 | 581 | 3 |
"I plan to do operations on that data (eg. sum, difference, averages etc.) as well including generation of say another column based on computations on the input."
This is the standard use case for a data warehouse star-schema design. Buy Kimball's The Data Warehouse Toolkit. Read (and understand) the star schema befo... | 4 | 0 | 0 | true | 0 | python,database,database-design,file-io | Store data series in file or database if I want to do row level math operations? | 2 | 1 | 1,245,169 | 0 | 1,241,758 | 1.2 | I'm developing an app that handle sets of financial series data (input as csv or open document), one set could be say 10's x 1000's up to double precision numbers (Simplifying, but thats what matters).
I plan to do operations on that data (eg. sum, difference, averages etc.) as well including generation of say another ... | 1 | 0 | 2009-08-06T21:58:00.000 | 0 | 0 | 581 | 3 |
An ordered tree is usually better for this cases, but random access is going to be log(n). You should keep into account also insertion and removal costs... | 10 | 0 | 0 | false | 36 | python,data-structures,collections,dictionary | Key-ordered dict in Python | 4 | 0 | 1,319,790 | 0 | 1,319,763 | 0.07983 | I am looking for a solid implementation of an ordered associative array, that is, an ordered dictionary. I want the ordering in terms of keys, not of insertion order.
More precisely, I am looking for a space-efficent implementation of a int-to-float (or string-to-float for another use case) mapping structure for which... | 1 | 0 | 2009-08-23T22:33:00.000 | 0 | 1 | 12,867 | 1 |
You could build an index which maps words to phrases and do something like:
let matched = set of all phrases
for each word in the searched phrase
let wordMatch = all phrases containing the current word
let matched = intersection of matched and wordMatch
After this, matched would contain all phrases matching a... | 4 | 0 | 0 | false | 1 | c#,java,c++,python,algorithm | Algorithm to filter a set of all phrases containing in other phrase | 1 | 0 | 1,372,627 | 0 | 1,372,531 | 0.049958 | Given a set of phrases, i would like to filter the set of all phrases that contain any of the other phrases. Contained here means that if a phrase contains all the words of another phrase it should be filtered out. Order of the words within the phrase does not matter.
What i have so far is this:
Sort the set by the nu... | 1 | 0 | 2009-09-03T10:02:00.000 | 0 | 1 | 709 | 2 |
sort phrases by their contents, i.e., 'Z A' -> 'A Z', then eliminating phrases is easy going from shortest to longer ones. | 4 | 0 | 0 | false | 1 | c#,java,c++,python,algorithm | Algorithm to filter a set of all phrases containing in other phrase | 0 | 0 | 1,372,585 | 0 | 1,372,531 | 0 | Given a set of phrases, i would like to filter the set of all phrases that contain any of the other phrases. Contained here means that if a phrase contains all the words of another phrase it should be filtered out. Order of the words within the phrase does not matter.
What i have so far is this:
Sort the set by the nu... | 1 | 0 | 2009-09-03T10:02:00.000 | 0 | 1 | 709 | 2 |
If you are willing to consider a library, pandas (http://pandas.pydata.org/) is a library built on top of numpy which amongst many other things provides:
Intelligent data alignment and integrated handling of missing data: gain automatic label-based alignment in computations and easily manipulate messy data into an ord... | 4 | 0 | 0 | false | 11 | python,numpy,data-analysis | How do you deal with missing data using numpy/scipy? | 4 | 0 | 11,086,822 | 0 | 1,377,130 | 0.197375 | One of the things I deal with most in data cleaning is missing values. R deals with this well using its "NA" missing data label. In python, it appears that I'll have to deal with masked arrays which seem to be a major pain to set up and don't seem to be well documented. Any suggestions on making this process easier in ... | 1 | 0 | 2009-09-04T03:44:00.000 | 0 | 0 | 10,010 | 1 |
The best way to show multiple figures is use matplotlib or pylab. (for windows)
with matplotlib you can prepare the figures and then when you finish the process with them you can show with the comand "matplotlib.show()" and all figures should be shown.
(on linux) you don´t have problems adding changes to figures becaus... | 3 | 0 | 0 | false | 32 | python,matplotlib,figures | Python with matplotlib - drawing multiple figures in parallel | 0 | 0 | 14,591,411 | 0 | 1,401,102 | 0 | I have functions that contribute to small parts of a figure generation. I'm trying to use these functions to generate multiple figures? So something like this:
work with Figure 1
do something else
work with Figure 2
do something else
work with Figure 1
do something else
work with Figure 2
If anyone could help, that'd... | 1 | 0 | 2009-09-09T17:57:00.000 | 0 | 1 | 43,360 | 1 |
Speed depends on the ratio of hits to misses. To be pythonic choose the clearer method.
Personally I think way#1 is clearer (It takes less lines to have an 'if' block rather than an exception block and also uses less brain space). It will also be faster when there are more hits than misses (an exception is more expensi... | 5 | 0 | 0 | false | 2 | python | Which is more pythonic for array removal? | 3 | 0 | 1,418,321 | 1 | 1,418,266 | 0.119427 | I'm removing an item from an array if it exists.
Two ways I can think of to do this
Way #1
# x array, r item to remove
if r in x :
x.remove( r )
Way #2
try :
x.remove( r )
except :
pass
Timing it shows the try/except way can be faster
(some times i'm getting:)
1.16225508968e-06
8.80804972547e-07
1.143141965... | 1 | 0 | 2009-09-13T17:15:00.000 | 0 | 1 | 267 | 3 |
The try/except way | 5 | 0 | 0 | false | 2 | python | Which is more pythonic for array removal? | 2 | 0 | 1,418,275 | 1 | 1,418,266 | 0.07983 | I'm removing an item from an array if it exists.
Two ways I can think of to do this
Way #1
# x array, r item to remove
if r in x :
x.remove( r )
Way #2
try :
x.remove( r )
except :
pass
Timing it shows the try/except way can be faster
(some times i'm getting:)
1.16225508968e-06
8.80804972547e-07
1.143141965... | 1 | 0 | 2009-09-13T17:15:00.000 | 0 | 1 | 267 | 3 |
I've always gone with the first method. if in reads far more clearly than exception handling does. | 5 | 0 | 0 | true | 2 | python | Which is more pythonic for array removal? | 6 | 0 | 1,418,310 | 1 | 1,418,266 | 1.2 | I'm removing an item from an array if it exists.
Two ways I can think of to do this
Way #1
# x array, r item to remove
if r in x :
x.remove( r )
Way #2
try :
x.remove( r )
except :
pass
Timing it shows the try/except way can be faster
(some times i'm getting:)
1.16225508968e-06
8.80804972547e-07
1.143141965... | 1 | 0 | 2009-09-13T17:15:00.000 | 0 | 1 | 267 | 3 |
You only need to store the lower triangle of the matrix. Typically this is done with one n(n+1)/2 length list. You'll need to overload the __getitem__ method to interpret what the entry means. | 4 | 0 | 0 | false | 1 | python,data-structures,matrix | Symmetrically adressable matrix | 1 | 0 | 1,425,181 | 0 | 1,425,162 | 0.049958 | I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill... | 1 | 0 | 2009-09-15T04:48:00.000 | 0 | 1 | 247 | 2 |
You're probably better off using a full square numpy matrix. Yes, it wastes half the memory storing redundant values, but rolling your own symmetric matrix in Python will waste even more memory and CPU by storing and processing the integers as Python objects. | 4 | 0 | 0 | false | 1 | python,data-structures,matrix | Symmetrically adressable matrix | 2 | 0 | 1,425,305 | 0 | 1,425,162 | 0.099668 | I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill... | 1 | 0 | 2009-09-15T04:48:00.000 | 0 | 1 | 247 | 2 |
10B booleans (1.25MB of memory, assuming Python is sane)
I think you have your arithmetic wrong -- stored supercompactly, 10B booleans would be 1.25 GIGA, _not__ MEGA, bytes.
A list takes at least 4 bytes per item, so you'd need 40GB to do it the way you want.
You can store an array (see the array module in the standa... | 6 | 0 | 0 | false | 2 | python | long-index arrays in python | 2 | 0 | 1,436,482 | 0 | 1,436,411 | 0.066568 | I'm attempting to shorten the memory footprint of 10B sequential integers by referencing them as indexes in a boolean array. In other words, I need to create an array of 10,000,000,000 elements, but that's well into the "Long" range. When I try to reference an array index greater than sys.maxint the array blows up:
x ... | 1 | 0 | 2009-09-17T02:18:00.000 | 0 | 1 | 4,919 | 2 |
A dense bit vector is plausible but it won't be optimal unless you know you won't have more than about 10**10 elements, all clustered near each other, with a reasonably randomized distribution. If you have a different distribution, then a different structure will be better.
For instance, if you know that in that ran... | 6 | 0 | 0 | false | 2 | python | long-index arrays in python | 3 | 0 | 1,436,547 | 0 | 1,436,411 | 0.099668 | I'm attempting to shorten the memory footprint of 10B sequential integers by referencing them as indexes in a boolean array. In other words, I need to create an array of 10,000,000,000 elements, but that's well into the "Long" range. When I try to reference an array index greater than sys.maxint the array blows up:
x ... | 1 | 0 | 2009-09-17T02:18:00.000 | 0 | 1 | 4,919 | 2 |
Well, the .sort() method of lists sorts the list in place, while sorted() creates a new list. So if you have a large list, part of your performance difference will be due to copying.
Still, an order of magnitude difference seems larger than I'd expect. Perhaps list.sort() has some special-cased optimization that sort... | 3 | 0 | 0 | false | 40 | python,sorting | Python sort() method on list vs builtin sorted() function | 9 | 0 | 1,436,981 | 0 | 1,436,962 | 1 | I know that __builtin__ sorted() function works on any iterable. But can someone explain this huge (10x) performance difference between anylist.sort() vs sorted(anylist) ? Also, please point out if I am doing anything wrong with way this is measured.
"""
Example Output:
$ python list_sort_timeit.py
Using sort method... | 1 | 0 | 2009-09-17T06:07:00.000 | 0 | 1 | 63,711 | 1 |
Well i can\t quite get exactly what are you looking for, whole solution or maybe you've got problem with colors, if that second thing below you got some ideas
The most simple solution would be to create 14-elements array with color that you write from hand with help of some graphic software and than simply fetch elemen... | 2 | 0 | 0 | false | 0 | ironpython | Colour map in ipython | 0 | 0 | 1,448,617 | 0 | 1,448,582 | 0 | I am trying to plot some data in ipy.
The data consists of three variables alpha,beta and delta. The alpha and beta values are the coordinates of the data points that I wish to plot using a hammer projection. I want to scale the colour of the markers according to the delta values, preferably in a rainbow scale colormap... | 1 | 0 | 2009-09-19T13:47:00.000 | 0 | 0 | 279 | 1 |
Do you mean opencv can't connect to your webcam or can't read video files recorded by it?
Have you tried saving the video in an other format?
OpenCV is probably the best supported python image processing tool | 4 | 0 | 0 | true | 13 | python,image-processing,video-processing | Most used Python module for video processing? | 7 | 0 | 1,480,450 | 0 | 1,480,431 | 1.2 | I need to:
Open a video file
Iterate over the frames of the file as images
Do some analysis in this image frame of the video
Draw in this image of the video
Create a new video with these changes
OpenCV isn't working for my webcam, but python-gst is working. Is this possible using python-gst?
Thank you! | 1 | 0 | 2009-09-26T04:23:00.000 | 0 | 1 | 12,979 | 2 |
Just build a C/C++ wrapper for your webcam and then use SWIG or SIP to access these functions from Python. Then use OpenCV in Python that's the best open sourced computer vision library in the wild.
If you worry for performance and you work under Linux, you could download free versions of Intel Performance Primitives (... | 4 | 0 | 0 | false | 13 | python,image-processing,video-processing | Most used Python module for video processing? | 0 | 0 | 1,497,418 | 0 | 1,480,431 | 0 | I need to:
Open a video file
Iterate over the frames of the file as images
Do some analysis in this image frame of the video
Draw in this image of the video
Create a new video with these changes
OpenCV isn't working for my webcam, but python-gst is working. Is this possible using python-gst?
Thank you! | 1 | 0 | 2009-09-26T04:23:00.000 | 0 | 1 | 12,979 | 2 |
Try axis('equal'). It's been a while since I worked with matplotlib, but I seem to remember typing that command a lot. | 3 | 0 | 0 | false | 4 | python,matplotlib,boxplot | Matplotlib square boxplot | 3 | 0 | 1,506,741 | 0 | 1,506,647 | 0.197375 | I have a plot of two boxplots in the same figure. For style reasons, the axis should have the same length, so that the graphic box is square. I tried to use the set_aspect method, but the axes are too different because of their range
and the result is terrible.
Is it possible to have 1:1 axes even if they do not have t... | 1 | 0 | 2009-10-01T21:37:00.000 | 0 | 0 | 8,361 | 1 |
In early python-versions, the sort function implemented a modified version of quicksort.
However, it was deemed unstable and as of 2.3 they switched to using an adaptive mergesort algorithm. | 3 | 0 | 0 | false | 128 | python,algorithm,sorting,python-internals | About Python's built in sort() method | 10 | 0 | 1,517,357 | 0 | 1,517,347 | 1 | What algorithm is the built in sort() method in Python using? Is it possible to have a look at the code for that method? | 1 | 0 | 2009-10-04T20:48:00.000 | 0 | 1 | 71,971 | 1 |
It is good to know the version of numpy you run, but strictly speaking if you just need to have specific version on your system you can write like this:
pip install numpy==1.14.3 and this will install the version you need and uninstall other versions of numpy. | 17 | 0 | 0 | false | 340 | python,numpy,version | How do I check which version of NumPy I'm using? | 0 | 0 | 53,898,417 | 0 | 1,520,234 | 0 | How can I check which version of NumPy I'm using? | 1 | 0 | 2009-10-05T13:56:00.000 | 0 | 0 | 514,245 | 2 |
You can try this:
pip show numpy | 17 | 0 | 0 | false | 340 | python,numpy,version | How do I check which version of NumPy I'm using? | 11 | 0 | 46,330,631 | 0 | 1,520,234 | 1 | How can I check which version of NumPy I'm using? | 1 | 0 | 2009-10-05T13:56:00.000 | 0 | 0 | 514,245 | 2 |
On possible option is to do a single pass through the file first to count the number of rows, without loading them.
The other option is to double your table size each time, which has two benefits:
You will only re-alloc memory log(n) times where n is the number of rows.
You only need 50% more ram than your largest tab... | 4 | 0 | 0 | false | 11 | python,numpy,memory-management | Incrementally building a numpy array and measuring memory usage | 1 | 0 | 1,534,340 | 0 | 1,530,960 | 0.049958 | I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:
As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array be most efficie... | 1 | 0 | 2009-10-07T11:08:00.000 | 0 | 0 | 6,464 | 1 |
You can also use GDAL, which has many many functions to work with spatial data. | 8 | 0 | 0 | false | 49 | python,algorithm,cluster-analysis,k-means | Python k-means algorithm | 0 | 0 | 1,545,672 | 0 | 1,545,606 | 0 | I am looking for Python implementation of k-means algorithm with examples to cluster and cache my database of coordinates. | 1 | 0 | 2009-10-09T19:16:00.000 | 0 | 0 | 89,635 | 1 |
Why not download some real open source repos and use those?
Have you thought about what goes into the files? is that random data too? | 4 | 0 | 0 | true | 2 | python,algorithm | Generate random directories/files given number of files and depth | 5 | 0 | 1,553,126 | 0 | 1,553,114 | 1.2 | I'd like to profile some VCS software, and to do so I want to generate a set of random files, in randomly arranged directories. I'm writing the script in Python, but my question is briefly: how do I generate a random directory tree with an average number of sub-directories per directory and some broad distribution of f... | 1 | 0 | 2009-10-12T07:06:00.000 | 0 | 0 | 3,603 | 1 |
You haven't made it completely clear what you need. It sounds like itertools should have what you need. Perhaps what you wish is an itertools.combinations of the itertools.product of the lists in your big list.
@fortran: you can't have a set of sets. You can have a set of frozensets, but depending on what it really me... | 3 | 0 | 0 | false | 2 | python | How to make all combinations of the elements in an array? | 1 | 0 | 1,592,512 | 0 | 1,591,762 | 0.066568 | I have a list. It contains x lists, each with y elements.
I want to pair each element with all the other elements, just once, (a,b = b,a)
EDIT: this has been criticized as being too vague.So I'll describe the history.
My function produces random equations and using genetic techniques, mutates and crossbreeds them, sele... | 1 | 0 | 2009-10-19T23:51:00.000 | 0 | 1 | 598 | 2 |
First of all, please don't refer to this as an "array". You are using a list of lists. In Python, an array is a different type of data structure, provided by the array module.
Also, your application sounds suspiciously like a matrix. If you are really doing matrix manipulations, you should investigate the Numpy packag... | 3 | 0 | 0 | false | 2 | python | How to make all combinations of the elements in an array? | 0 | 0 | 1,591,802 | 0 | 1,591,762 | 0 | I have a list. It contains x lists, each with y elements.
I want to pair each element with all the other elements, just once, (a,b = b,a)
EDIT: this has been criticized as being too vague.So I'll describe the history.
My function produces random equations and using genetic techniques, mutates and crossbreeds them, sele... | 1 | 0 | 2009-10-19T23:51:00.000 | 0 | 1 | 598 | 2 |
If you are I/O bound, the best way I have found to optimize is to read or write the entire file into/out of memory at once, then operate out of RAM from there on.
With extensive testing I found that my runtime eded up bound not by the amount of data I read from/wrote to disk, but by the number of I/O operations I used ... | 7 | 0 | 0 | false | 3 | python,performance,optimization,file-io | How should I optimize this filesystem I/O bound program? | 3 | 1 | 1,594,704 | 0 | 1,594,604 | 0.085505 | I have a python program that does something like this:
Read a row from a csv file.
Do some transformations on it.
Break it up into the actual rows as they would be written to the database.
Write those rows to individual csv files.
Go back to step 1 unless the file has been totally read.
Run SQL*Loader and load those f... | 1 | 0 | 2009-10-20T13:27:00.000 | 0 | 0 | 2,504 | 5 |
Use buffered writes for step 4.
Write a simple function that simply appends the output onto a string, checks the string length, and only writes when you have enough which should be some multiple of 4k bytes. I would say start with 32k buffers and time it.
You would have one buffer per file, so that most "writes" won't ... | 7 | 0 | 0 | false | 3 | python,performance,optimization,file-io | How should I optimize this filesystem I/O bound program? | 1 | 1 | 1,595,358 | 0 | 1,594,604 | 0.028564 | I have a python program that does something like this:
Read a row from a csv file.
Do some transformations on it.
Break it up into the actual rows as they would be written to the database.
Write those rows to individual csv files.
Go back to step 1 unless the file has been totally read.
Run SQL*Loader and load those f... | 1 | 0 | 2009-10-20T13:27:00.000 | 0 | 0 | 2,504 | 5 |
Python already does IO buffering and the OS should handle both prefetching the input file and delaying writes until it needs the RAM for something else or just gets uneasy about having dirty data in RAM for too long. Unless you force the OS to write them immediately, like closing the file after each write or opening t... | 7 | 0 | 0 | true | 3 | python,performance,optimization,file-io | How should I optimize this filesystem I/O bound program? | 3 | 1 | 1,595,626 | 0 | 1,594,604 | 1.2 | I have a python program that does something like this:
Read a row from a csv file.
Do some transformations on it.
Break it up into the actual rows as they would be written to the database.
Write those rows to individual csv files.
Go back to step 1 unless the file has been totally read.
Run SQL*Loader and load those f... | 1 | 0 | 2009-10-20T13:27:00.000 | 0 | 0 | 2,504 | 5 |
Can you use a ramdisk for step 4? Low millions sounds doable if the rows are less than a couple of kB or so. | 7 | 0 | 0 | false | 3 | python,performance,optimization,file-io | How should I optimize this filesystem I/O bound program? | 2 | 1 | 1,597,062 | 0 | 1,594,604 | 0.057081 | I have a python program that does something like this:
Read a row from a csv file.
Do some transformations on it.
Break it up into the actual rows as they would be written to the database.
Write those rows to individual csv files.
Go back to step 1 unless the file has been totally read.
Run SQL*Loader and load those f... | 1 | 0 | 2009-10-20T13:27:00.000 | 0 | 0 | 2,504 | 5 |
Isn't it possible to collect a few thousand rows in ram, then go directly to the database server and execute them?
This would remove the save to and load from the disk that step 4 entails.
If the database server is transactional, this is also a safe way to do it - just have the database begin before your first row and... | 7 | 0 | 0 | false | 3 | python,performance,optimization,file-io | How should I optimize this filesystem I/O bound program? | 1 | 1 | 1,597,281 | 0 | 1,594,604 | 0.028564 | I have a python program that does something like this:
Read a row from a csv file.
Do some transformations on it.
Break it up into the actual rows as they would be written to the database.
Write those rows to individual csv files.
Go back to step 1 unless the file has been totally read.
Run SQL*Loader and load those f... | 1 | 0 | 2009-10-20T13:27:00.000 | 0 | 0 | 2,504 | 5 |
Contra the other answers offered, I believe that we can make a strong argument about the recoverability of a pickle. That answer is: "Yes, an incomplete pickle always leads to an exception."
Why are we able to do this? Because the "pickle" format is in fact a small stack-based language. In a stack-based language you wr... | 5 | 0 | 0 | false | 4 | python | If pickling was interrupted, will unpickling necessarily always fail? - Python | 7 | 0 | 1,654,390 | 0 | 1,653,897 | 1 | Suppose my attempt to write a pickle object out to disk is incomplete due to a crash. Will an attempt to unpickle the object always lead to an exception or is it possible that the fragment that was written out may be interpreted as valid pickle and the error go unnoticed? | 1 | 0 | 2009-10-31T09:38:00.000 | 0 | 1 | 1,351 | 4 |
I doubt you could make a claim that it will always lead to an exception. Pickles are actually programs written in a specialized stack language. The internal details of pickles change from version to version, and new pickle protocols are added occasionally. The state of the pickle after a crash, and the resulting eff... | 5 | 0 | 0 | false | 4 | python | If pickling was interrupted, will unpickling necessarily always fail? - Python | 1 | 0 | 1,654,321 | 0 | 1,653,897 | 0.039979 | Suppose my attempt to write a pickle object out to disk is incomplete due to a crash. Will an attempt to unpickle the object always lead to an exception or is it possible that the fragment that was written out may be interpreted as valid pickle and the error go unnoticed? | 1 | 0 | 2009-10-31T09:38:00.000 | 0 | 1 | 1,351 | 4 |
To be sure that you have a "complete" pickle file, you need to pickle three things.
Pickle a header of some kind that claims how many objects and what the end-of-file flag will look like. A tuple of an integer and the EOF string, for example.
Pickle the objects you actually care about. The count is given by the head... | 5 | 0 | 0 | false | 4 | python | If pickling was interrupted, will unpickling necessarily always fail? - Python | 1 | 0 | 1,654,503 | 0 | 1,653,897 | 0.039979 | Suppose my attempt to write a pickle object out to disk is incomplete due to a crash. Will an attempt to unpickle the object always lead to an exception or is it possible that the fragment that was written out may be interpreted as valid pickle and the error go unnoticed? | 1 | 0 | 2009-10-31T09:38:00.000 | 0 | 1 | 1,351 | 4 |
Pickling an object returns an str object, or writes an str object to a file ... it doesn't modify the original object. If a "crash" (exception) happens inside a pickling call, the result won't be returned to the caller, so you don't have anything that you could try to unpickle. Besides, why would you want to unpickle s... | 5 | 0 | 0 | false | 4 | python | If pickling was interrupted, will unpickling necessarily always fail? - Python | 2 | 0 | 1,654,329 | 0 | 1,653,897 | 0.07983 | Suppose my attempt to write a pickle object out to disk is incomplete due to a crash. Will an attempt to unpickle the object always lead to an exception or is it possible that the fragment that was written out may be interpreted as valid pickle and the error go unnoticed? | 1 | 0 | 2009-10-31T09:38:00.000 | 0 | 1 | 1,351 | 4 |
This is a tough one to answer.
I recently switched some of my graphing workload from R to matplotlib. In my humble opinion, I find matplotlib's graphs to be prettier (better default colors, they look crisper and more modern). I also think matplotlib renders PNGs a whole lot better.
The real motivation for me though... | 2 | 0 | 0 | true | 11 | python,r,matplotlib,scipy,data-visualization | matplotlib for R user? | 13 | 0 | 1,662,207 | 0 | 1,661,479 | 1.2 | I regularly make figures (the exploratory data analysis type) in R. I also program in Python and was wondering if there are features or concepts in matplotlib that would be worth learning. For instance, I am quite happy with R - but its image() function will produce large files with pixelated output, whereas Matlab's e... | 1 | 0 | 2009-11-02T14:01:00.000 | 0 | 0 | 10,755 | 2 |
I think that the largest advantage is that matplotlib is based on Python, which you say you already know. So, this is one language less to learn. Just spend the time mastering Python, and you'll benefit both directly for the plotting task at hand and indirectly for your other Python needs.
Besides, IMHO Python is an o... | 2 | 0 | 0 | false | 11 | python,r,matplotlib,scipy,data-visualization | matplotlib for R user? | 4 | 0 | 1,662,225 | 0 | 1,661,479 | 0.379949 | I regularly make figures (the exploratory data analysis type) in R. I also program in Python and was wondering if there are features or concepts in matplotlib that would be worth learning. For instance, I am quite happy with R - but its image() function will produce large files with pixelated output, whereas Matlab's e... | 1 | 0 | 2009-11-02T14:01:00.000 | 0 | 0 | 10,755 | 2 |
You can get out of the box named entity chunking with the nltk.ne_chunk() method. It takes a list of POS tagged tuples:
nltk.ne_chunk([('Barack', 'NNP'), ('Obama', 'NNP'), ('lives', 'NNS'), ('in', 'IN'), ('Washington', 'NNP')])
results in:
Tree('S', [Tree('PERSON', [('Barack', 'NNP')]), Tree('ORGANIZATION', [('Obama',... | 2 | 0 | 0 | true | 9 | python,nlp,nltk,chunking | What is the default chunker for NLTK toolkit in Python? | 9 | 0 | 1,687,712 | 0 | 1,687,510 | 1.2 | I am using their default POS tagging and default tokenization..and it seems sufficient. I'd like their default chunker too.
I am reading the NLTK toolkit book, but it does not seem like they have a default chunker? | 1 | 0 | 2009-11-06T13:10:00.000 | 0 | 0 | 4,560 | 1 |
sorry, may I ask which tool could judge "difficulty level" of sentences?
I wish to find out "similar difficulty level" of sentences for user to read. | 5 | 0 | 0 | false | 6 | python,text,nlp,words,wordnet | Does WordNet have "levels"? (NLP) | 0 | 0 | 58,050,062 | 0 | 1,695,971 | 0 | For example...
Chicken is an animal.
Burrito is a food.
WordNet allows you to do "is-a"...the hiearchy feature.
However, how do I know when to stop travelling up the tree? I want a LEVEL.
That is consistent.
For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain leve... | 1 | 0 | 2009-11-08T10:29:00.000 | 0 | 0 | 2,585 | 4 |
No dataset card yet