Kernel dies when using itertools.permutationSpyder iPython console crashing in a long programKernel died, restarting in the middle of my simulation (spyder)Run Tensorflow on Jupyter notebook but kernel deadupdated environment in anaconda and now kernel dies and “code will never be executed”Find optimal filter of combination of attributes in pandas dataframe to maximise value columnPython: How to get possible combinations of keys in dictalgorithm, closest point between list elementsHow can I fix the error of “The kernel has died, and the automatic restart has failed.”?Itertools permutations with replacement one by oneOptimisation to find combinations at less time in python list

How does a pilot select the correct ILS when the airport has parallel runways?

How to make clear to people I don't want to answer their "Where are you from?" question?

Drawing people along with x and y axis

How long would it take to cross the Channel in 1890's?

Cut the gold chain

Why do some professors with PhDs leave their professorships to teach high school?

Are all Ringwraiths called Nazgûl in LotR?

What does the hyphen "-" mean in "tar xzf -"?

Understanding the reasoning of the woman who agreed with King Solomon to "cut the baby in half"

Java TreeMap.floorKey() equivalent for std::map

Find the C-factor of a vote

Can White Castle?

Has there been any indication at all that further negotiation between the UK and EU is possible?

Does this Wild Magic result affect the sorcerer or just other creatures?

Is it damaging to turn off a small fridge for two days every week?

Is this proposal by U.S. presidential candidate Pete Buttigieg to change the composition of the Supreme Court constitutional?

Why do even high-end cameras often still include normal (non-cross-type) AF sensors?

Why did pressing the joystick button spit out keypresses?

How to model a twisted cylinder like this

Would it be a copyright violation if I made a character’s full name refer to a song?

Is "Busen" just the area between the breasts?

Methodology: Writing unit tests for another developer

How is hair tissue mineral analysis performed?

Can any NP-Complete Problem be solved using at most polynomial space (but while using exponential time?)



Kernel dies when using itertools.permutation


Spyder iPython console crashing in a long programKernel died, restarting in the middle of my simulation (spyder)Run Tensorflow on Jupyter notebook but kernel deadupdated environment in anaconda and now kernel dies and “code will never be executed”Find optimal filter of combination of attributes in pandas dataframe to maximise value columnPython: How to get possible combinations of keys in dictalgorithm, closest point between list elementsHow can I fix the error of “The kernel has died, and the automatic restart has failed.”?Itertools permutations with replacement one by oneOptimisation to find combinations at less time in python list






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I have a list of strings. And I want to find all possible combination of that list. I use itertools.permutation and it runs for while but then it crashes saying Kernel died, restarting. I try running the code through terminal too. But it crashes there too. Here is my code:



import itertools


sum_stats = ['pi', 'theta W','Tajima D','distVar','distSkew','distKurt','nDiplos',
'diplo_H1','diplo_H12','diplo_H2/H1','diplo_ZnS','diplo_Omega']

permuted_sum_stats = list(itertools.permutations(sum_stats))


Can someone show me an efficient way to create all possible combinations of this list?










share|improve this question






















  • Hello, you are trying to put factorial 12 elements in memory with list. This is 479,001,600 elements, which is a lot. Using itertools you may not need to store it in a list

    – FlorianGD
    Mar 25 at 9:08











  • How do I store it then?

    – Shafa Haider
    Mar 25 at 9:20






  • 1





    Depends on what you want to do. You can iterate over it without putting it in a list for stats in itertools.permutations(sum_stats): do_something()

    – FlorianGD
    Mar 25 at 9:22












  • Thank you. It'll work.

    – Shafa Haider
    Mar 25 at 13:52

















1















I have a list of strings. And I want to find all possible combination of that list. I use itertools.permutation and it runs for while but then it crashes saying Kernel died, restarting. I try running the code through terminal too. But it crashes there too. Here is my code:



import itertools


sum_stats = ['pi', 'theta W','Tajima D','distVar','distSkew','distKurt','nDiplos',
'diplo_H1','diplo_H12','diplo_H2/H1','diplo_ZnS','diplo_Omega']

permuted_sum_stats = list(itertools.permutations(sum_stats))


Can someone show me an efficient way to create all possible combinations of this list?










share|improve this question






















  • Hello, you are trying to put factorial 12 elements in memory with list. This is 479,001,600 elements, which is a lot. Using itertools you may not need to store it in a list

    – FlorianGD
    Mar 25 at 9:08











  • How do I store it then?

    – Shafa Haider
    Mar 25 at 9:20






  • 1





    Depends on what you want to do. You can iterate over it without putting it in a list for stats in itertools.permutations(sum_stats): do_something()

    – FlorianGD
    Mar 25 at 9:22












  • Thank you. It'll work.

    – Shafa Haider
    Mar 25 at 13:52













1












1








1








I have a list of strings. And I want to find all possible combination of that list. I use itertools.permutation and it runs for while but then it crashes saying Kernel died, restarting. I try running the code through terminal too. But it crashes there too. Here is my code:



import itertools


sum_stats = ['pi', 'theta W','Tajima D','distVar','distSkew','distKurt','nDiplos',
'diplo_H1','diplo_H12','diplo_H2/H1','diplo_ZnS','diplo_Omega']

permuted_sum_stats = list(itertools.permutations(sum_stats))


Can someone show me an efficient way to create all possible combinations of this list?










share|improve this question














I have a list of strings. And I want to find all possible combination of that list. I use itertools.permutation and it runs for while but then it crashes saying Kernel died, restarting. I try running the code through terminal too. But it crashes there too. Here is my code:



import itertools


sum_stats = ['pi', 'theta W','Tajima D','distVar','distSkew','distKurt','nDiplos',
'diplo_H1','diplo_H12','diplo_H2/H1','diplo_ZnS','diplo_Omega']

permuted_sum_stats = list(itertools.permutations(sum_stats))


Can someone show me an efficient way to create all possible combinations of this list?







python-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 8:47









Shafa HaiderShafa Haider

12610




12610












  • Hello, you are trying to put factorial 12 elements in memory with list. This is 479,001,600 elements, which is a lot. Using itertools you may not need to store it in a list

    – FlorianGD
    Mar 25 at 9:08











  • How do I store it then?

    – Shafa Haider
    Mar 25 at 9:20






  • 1





    Depends on what you want to do. You can iterate over it without putting it in a list for stats in itertools.permutations(sum_stats): do_something()

    – FlorianGD
    Mar 25 at 9:22












  • Thank you. It'll work.

    – Shafa Haider
    Mar 25 at 13:52

















  • Hello, you are trying to put factorial 12 elements in memory with list. This is 479,001,600 elements, which is a lot. Using itertools you may not need to store it in a list

    – FlorianGD
    Mar 25 at 9:08











  • How do I store it then?

    – Shafa Haider
    Mar 25 at 9:20






  • 1





    Depends on what you want to do. You can iterate over it without putting it in a list for stats in itertools.permutations(sum_stats): do_something()

    – FlorianGD
    Mar 25 at 9:22












  • Thank you. It'll work.

    – Shafa Haider
    Mar 25 at 13:52
















Hello, you are trying to put factorial 12 elements in memory with list. This is 479,001,600 elements, which is a lot. Using itertools you may not need to store it in a list

– FlorianGD
Mar 25 at 9:08





Hello, you are trying to put factorial 12 elements in memory with list. This is 479,001,600 elements, which is a lot. Using itertools you may not need to store it in a list

– FlorianGD
Mar 25 at 9:08













How do I store it then?

– Shafa Haider
Mar 25 at 9:20





How do I store it then?

– Shafa Haider
Mar 25 at 9:20




1




1





Depends on what you want to do. You can iterate over it without putting it in a list for stats in itertools.permutations(sum_stats): do_something()

– FlorianGD
Mar 25 at 9:22






Depends on what you want to do. You can iterate over it without putting it in a list for stats in itertools.permutations(sum_stats): do_something()

– FlorianGD
Mar 25 at 9:22














Thank you. It'll work.

– Shafa Haider
Mar 25 at 13:52





Thank you. It'll work.

– Shafa Haider
Mar 25 at 13:52












1 Answer
1






active

oldest

votes


















2














Your list has 12 elements. To get all possible permutations, your new list needs 12!, or about 500 million elements. One of these lists takes about 150 bytes, excluding the space of the strings, which I assume is reused.



This leads to about 75 GB of data, which is probably more than the RAM of your machine.






share|improve this answer























  • Yes that's what I thought too. Could you suggest another approach by which I can do that?

    – Shafa Haider
    Mar 25 at 9:18











  • Can you tell me why you want a list of all permutations?

    – L3viathan
    Mar 25 at 15:01











  • I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

    – Shafa Haider
    Mar 25 at 15:07














Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334040%2fkernel-dies-when-using-itertools-permutation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Your list has 12 elements. To get all possible permutations, your new list needs 12!, or about 500 million elements. One of these lists takes about 150 bytes, excluding the space of the strings, which I assume is reused.



This leads to about 75 GB of data, which is probably more than the RAM of your machine.






share|improve this answer























  • Yes that's what I thought too. Could you suggest another approach by which I can do that?

    – Shafa Haider
    Mar 25 at 9:18











  • Can you tell me why you want a list of all permutations?

    – L3viathan
    Mar 25 at 15:01











  • I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

    – Shafa Haider
    Mar 25 at 15:07
















2














Your list has 12 elements. To get all possible permutations, your new list needs 12!, or about 500 million elements. One of these lists takes about 150 bytes, excluding the space of the strings, which I assume is reused.



This leads to about 75 GB of data, which is probably more than the RAM of your machine.






share|improve this answer























  • Yes that's what I thought too. Could you suggest another approach by which I can do that?

    – Shafa Haider
    Mar 25 at 9:18











  • Can you tell me why you want a list of all permutations?

    – L3viathan
    Mar 25 at 15:01











  • I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

    – Shafa Haider
    Mar 25 at 15:07














2












2








2







Your list has 12 elements. To get all possible permutations, your new list needs 12!, or about 500 million elements. One of these lists takes about 150 bytes, excluding the space of the strings, which I assume is reused.



This leads to about 75 GB of data, which is probably more than the RAM of your machine.






share|improve this answer













Your list has 12 elements. To get all possible permutations, your new list needs 12!, or about 500 million elements. One of these lists takes about 150 bytes, excluding the space of the strings, which I assume is reused.



This leads to about 75 GB of data, which is probably more than the RAM of your machine.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 25 at 9:05









L3viathanL3viathan

17.4k13151




17.4k13151












  • Yes that's what I thought too. Could you suggest another approach by which I can do that?

    – Shafa Haider
    Mar 25 at 9:18











  • Can you tell me why you want a list of all permutations?

    – L3viathan
    Mar 25 at 15:01











  • I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

    – Shafa Haider
    Mar 25 at 15:07


















  • Yes that's what I thought too. Could you suggest another approach by which I can do that?

    – Shafa Haider
    Mar 25 at 9:18











  • Can you tell me why you want a list of all permutations?

    – L3viathan
    Mar 25 at 15:01











  • I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

    – Shafa Haider
    Mar 25 at 15:07

















Yes that's what I thought too. Could you suggest another approach by which I can do that?

– Shafa Haider
Mar 25 at 9:18





Yes that's what I thought too. Could you suggest another approach by which I can do that?

– Shafa Haider
Mar 25 at 9:18













Can you tell me why you want a list of all permutations?

– L3viathan
Mar 25 at 15:01





Can you tell me why you want a list of all permutations?

– L3viathan
Mar 25 at 15:01













I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

– Shafa Haider
Mar 25 at 15:07






I have matrices of size 12 x 11 where each row corresponds to one of the variables in sum_stats in the matrix. When I train my convolution neural network based on a specific order of sum_stats, it gives me test accuracy of 94% but the moment I change the order of sum_stats in the test matrices, its accuracy drops. I thought if I could train my network using different images where I use different ordering of sum_stats, it'll become more robust to these perturbations. So I needed the list of all perturbations so that I could perturb the rows in my matrices accordingly.

– Shafa Haider
Mar 25 at 15:07




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55334040%2fkernel-dies-when-using-itertools-permutation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript