{"id":754,"date":"2018-07-03T19:00:12","date_gmt":"2018-07-03T19:00:12","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2018\/07\/03\/how-to-generate-random-numbers-in-python\/"},"modified":"2018-07-03T19:00:12","modified_gmt":"2018-07-03T19:00:12","slug":"how-to-generate-random-numbers-in-python","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2018\/07\/03\/how-to-generate-random-numbers-in-python\/","title":{"rendered":"How to Generate Random Numbers in Python"},"content":{"rendered":"<p>Author: Jason Brownlee<\/p>\n<div>\n<p>The use of randomness is an important part of the configuration and evaluation of machine learning algorithms.<\/p>\n<p>From the random initialization of weights in an artificial neural network, to the splitting of data into random train and test sets, to the random shuffling of a training dataset in stochastic gradient descent, generating random numbers and harnessing randomness is a required skill.<\/p>\n<p>In this tutorial, you will discover how to generate and work with random numbers in Python.<\/p>\n<p>After completing this tutorial, you will know:<\/p>\n<ul>\n<li>That randomness can be applied in programs via the use of pseudorandom number generators.<\/li>\n<li>How to generate random numbers and use randomness via the Python standard library.<\/li>\n<li>How to generate arrays of random numbers via the NumPy library.<\/li>\n<\/ul>\n<p>Let\u2019s get started.<\/p>\n<div id=\"attachment_5709\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-5709\" src=\"https:\/\/machinelearningmastery.com\/wp-content\/uploads\/2018\/07\/How-to-Generate-Random-Numbers-in-Python.jpg\" alt=\"How to Generate Random Numbers in Python\" width=\"640\" height=\"424\" srcset=\"http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2018\/07\/How-to-Generate-Random-Numbers-in-Python.jpg 640w, http:\/\/3qeqpr26caki16dnhd19sv6by6v.wpengine.netdna-cdn.com\/wp-content\/uploads\/2018\/07\/How-to-Generate-Random-Numbers-in-Python-300x199.jpg 300w\" sizes=\"(max-width: 640px) 100vw, 640px\"><\/p>\n<p class=\"wp-caption-text\">How to Generate Random Numbers in Python<br \/>Photo by <a href=\"https:\/\/www.flickr.com\/photos\/a_little_brighter\/15908996592\/\">Harold Litwiler<\/a>, some rights reserved.<\/p>\n<\/div>\n<h2>Tutorial Overview<\/h2>\n<p>This tutorial is divided into 3 parts; they are:<\/p>\n<ol>\n<li>Pseudorandom Number Generators<\/li>\n<li>Random Numbers with Python<\/li>\n<li>Random Numbers with NumPy<\/li>\n<\/ol>\n<p><!-- Start shortcoder --><\/p>\n<div class=\"woo-sc-hr\"><\/div>\n<p><center><\/p>\n<h3>Need help with Statistics for Machine Learning?<\/h3>\n<p>Take my free 7-day email crash course now (with sample code).<\/p>\n<p>Click to sign-up and also get a free PDF Ebook version of the course.<\/p>\n<p><a href=\"https:\/\/machinelearningmastery.lpages.co\/leadbox\/142f75173f72a2%3A164f8be4f346dc\/5750943224168448\/\" target=\"_blank\" style=\"background: rgb(255, 206, 10); color: rgb(255, 255, 255); text-decoration: none; font-family: Helvetica, Arial, sans-serif; font-weight: bold; font-size: 16px; line-height: 20px; padding: 10px; display: inline-block; max-width: 300px; border-radius: 5px; text-shadow: rgba(0, 0, 0, 0.25) 0px -1px 1px; box-shadow: rgba(255, 255, 255, 0.5) 0px 1px 3px inset, rgba(0, 0, 0, 0.5) 0px 1px 3px;\">Download Your FREE Mini-Course<\/a><script data-leadbox=\"142f75173f72a2:164f8be4f346dc\" data-url=\"https:\/\/machinelearningmastery.lpages.co\/leadbox\/142f75173f72a2%3A164f8be4f346dc\/5750943224168448\/\" data-config=\"%7B%7D\" type=\"text\/javascript\" src=\"https:\/\/machinelearningmastery.lpages.co\/leadbox-1526328103.js\"><\/script><\/p>\n<p><\/center><\/p>\n<div class=\"woo-sc-hr\"><\/div>\n<p><!-- End shortcoder v4.1.7--><\/p>\n<h2>1. Pseudorandom Number Generators<\/h2>\n<p>The source of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Randomness\">randomness<\/a> that we inject into our programs and algorithms is a mathematical trick called a pseudorandom number generator.<\/p>\n<p>A random number generator is a system that generates random numbers from a true source of randomness. Often something physical, such as a Geiger counter, where the results are turned into random numbers. We do not need true randomness in machine learning. Instead we can use <a href=\"https:\/\/en.wikipedia.org\/wiki\/Pseudorandom_number_generator\">pseudorandomness<\/a>. Pseudorandomness is a sample of numbers that look close to random, but were generated using a deterministic process.<\/p>\n<p>Shuffling data and initializing coefficients with random values use pseudorandom number generators. These little programs are often a function that you can call that will return a random number. Called again, they will return a new random number. Wrapper functions are often also available and allow you to get your randomness as an integer, floating point, within a specific distribution, within a specific range, and so on.<\/p>\n<p>The numbers are generated in a sequence. The sequence is deterministic and is seeded with an initial number. If you do not explicitly seed the pseudorandom number generator, then it may use the current system time in seconds or milliseconds as the seed.<\/p>\n<p>The value of the seed does not matter. Choose anything you wish. What does matter is that the same seeding of the process will result in the same sequence of random numbers.<\/p>\n<p>Let\u2019s make this concrete with some examples.<\/p>\n<h2>2. Random Numbers with Python<\/h2>\n<p>The Python standard library provides a module called <a href=\"https:\/\/docs.python.org\/3\/library\/random.html\">random<\/a> that offers a suite of functions for generating random numbers.<\/p>\n<p>Python uses a popular and robust pseudorandom number generator called the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Mersenne_Twister\">Mersenne Twister<\/a>.<\/p>\n<p>In this section, we will look at a number of use cases for generating and using random numbers and randomness with the standard Python API.<\/p>\n<h3>Seed The Random Number Generator<\/h3>\n<p>The pseudorandom number generator is a mathematical function that generates a sequence of nearly random numbers.<\/p>\n<p>It takes a parameter to start off the sequence, called the seed. The function is deterministic, meaning given the same seed, it will produce the same sequence of numbers every time. The choice of seed does not matter.<\/p>\n<p>The <em>seed()<\/em> function will seed the pseudorandom number generator, taking an integer value as an argument, such as 1 or 7. If the seed() function is not called prior to using randomness, the default is to use the current system time in milliseconds from epoch (1970).<\/p>\n<p>The example below demonstrates seeding the pseudorandom number generator, generates some random numbers, and shows that reseeding the generator will result in the same sequence of numbers being generated.<\/p>\n<pre class=\"crayon-plain-tag\"># seed the pseudorandom number generator\r\nfrom random import seed\r\nfrom random import random\r\n# seed random number generator\r\nseed(1)\r\n# generate some random numbers\r\nprint(random(), random(), random())\r\n# reset the seed\r\nseed(1)\r\n# generate some random numbers\r\nprint(random(), random(), random())<\/pre>\n<p>Running the example seeds the pseudorandom number generator with the value 1, generates 3 random numbers, reseeds the generator, and shows that the same three random numbers are generated.<\/p>\n<pre class=\"crayon-plain-tag\">0.13436424411240122 0.8474337369372327 0.763774618976614\r\n0.13436424411240122 0.8474337369372327 0.763774618976614<\/pre>\n<p>It can be useful to control the randomness by setting the seed to ensure that your code produces the same result each time, such as in a production model.<\/p>\n<p>For running experiments where randomization is used to control for confounding variables, a different seed may be used for each experimental run.<\/p>\n<h3>Random Floating Point Values<\/h3>\n<p>Random floating point values can be generated using the <em>random()<\/em> function. Values will be generated in the range between 0 and 1, specifically in the interval [0,1).<\/p>\n<p>Values are drawn from a uniform distribution, meaning each value has an equal chance of being drawn.<\/p>\n<p>The example below generates 10 random floating point values.<\/p>\n<pre class=\"crayon-plain-tag\"># generate random floating point values\r\nfrom random import seed\r\nfrom random import random\r\n# seed random number generator\r\nseed(1)\r\n# generate random numbers between 0-1\r\nfor _ in range(10):\r\n\tvalue = random()\r\n\tprint(value)<\/pre>\n<p>Running the example generates and prints each random floating point value.<\/p>\n<pre class=\"crayon-plain-tag\">0.13436424411240122\r\n0.8474337369372327\r\n0.763774618976614\r\n0.2550690257394217\r\n0.49543508709194095\r\n0.4494910647887381\r\n0.651592972722763\r\n0.7887233511355132\r\n0.0938595867742349\r\n0.02834747652200631<\/pre>\n<p>The floating point values could be rescaled to a desired range by multiplying them by the size of the new range and adding the min value, as follows:<\/p>\n<pre class=\"crayon-plain-tag\">scaled value = min + (value * (max - min))<\/pre>\n<p>Where <em>min<\/em> and <em>max<\/em> are the minimum and maximum values of the desired range respectively, and <em>value<\/em> is the randomly generated floating point value in the range between 0 and 1.<\/p>\n<h3>Random Integer Values<\/h3>\n<p>Random integer values can be generated with the <em>randint()<\/em> function.<\/p>\n<p>This function takes two arguments: the start and the end of the range for the generated integer values. Random integers are generated within and including the start and end of range values, specifically in the interval [start, end]. Random values are drawn from a uniform distribution.<\/p>\n<p>The example below generates 10 random integer values between 0 and 10.<\/p>\n<pre class=\"crayon-plain-tag\"># generate random integer values\r\nfrom random import seed\r\nfrom random import randint\r\n# seed random number generator\r\nseed(1)\r\n# generate some integers\r\nfor _ in range(10):\r\n\tvalue = randint(0, 10)\r\n\tprint(value)<\/pre>\n<p>Running the example generates and prints 10 random integer values.<\/p>\n<pre class=\"crayon-plain-tag\">2\r\n9\r\n1\r\n4\r\n1\r\n7\r\n7\r\n7\r\n10\r\n6<\/pre>\n<\/p>\n<h3>Random Gaussian Values<\/h3>\n<p>Random floating point values can be drawn from a Gaussian distribution using the <em>gauss()<\/em> function.<\/p>\n<p>This function takes two arguments that correspond to the parameters that control the size of the distribution, specifically the mean and the standard deviation.<\/p>\n<p>The example below generates 10 random values drawn from a Gaussian distribution with a mean of 0.0 and a standard deviation of 1.0.<\/p>\n<p>Note that these parameters are not the bounds on the values and that the spread of the values will be controlled by the bell shape of the distribution, in this case proportionately likely above and below 0.0.<\/p>\n<pre class=\"crayon-plain-tag\"># generate random Gaussian values\r\nfrom random import seed\r\nfrom random import gauss\r\n# seed random number generator\r\nseed(1)\r\n# generate some Gaussian values\r\nfor _ in range(10):\r\n\tvalue = gauss(0, 1)\r\n\tprint(value)<\/pre>\n<p>Running the example generates and prints 10 Gaussian random values.<\/p>\n<pre class=\"crayon-plain-tag\">1.2881847531554629\r\n1.449445608699771\r\n0.06633580893826191\r\n-0.7645436509716318\r\n-1.0921732151041414\r\n0.03133451683171687\r\n-1.022103170010873\r\n-1.4368294451025299\r\n0.19931197648375384\r\n0.13337460465860485<\/pre>\n<\/p>\n<h3>Randomly Choosing From a List<\/h3>\n<p>Random numbers can be used to randomly choose an item from a list.<\/p>\n<p>For example, if a list had 10 items with indexes between 0 and 9, then you could generate a random integer between 0 and 9 and use it to randomly select an item from the list. The <em>choice()<\/em> function implements this behavior for you. Selections are made with a uniform likelihood.<\/p>\n<p>The example below generates a list of 20 integers and gives five examples of choosing one random item from the list.<\/p>\n<pre class=\"crayon-plain-tag\"># choose a random element from a list\r\nfrom random import seed\r\nfrom random import choice\r\n# seed random number generator\r\nseed(1)\r\n# prepare a sequence\r\nsequence = [i for i in range(20)]\r\nprint(sequence)\r\n# make choices from the sequence\r\nfor _ in range(5):\r\n\tselection = choice(sequence)\r\n\tprint(selection)<\/pre>\n<p>Running the example first prints the list of integer values, followed by five examples of choosing and printing a random value from the list.<\/p>\n<pre class=\"crayon-plain-tag\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\r\n4\r\n18\r\n2\r\n8\r\n3<\/pre>\n<\/p>\n<h3>Random Subsample From a List<\/h3>\n<p>We may be interested in repeating the random selection of items from a list to create a randomly chosen subset.<\/p>\n<p>Importantly, once an item is selected from the list and added to the subset, it should not be added again. This is called selection without replacement because once an item from the list is selected for the subset, it is not added back to the original list (i.e. is not made available for re-selection).<\/p>\n<p>This behavior is provided in the <em>sample()<\/em> function that selects a random sample from a list without replacement. The function takes both the list and the size of the subset to select as arguments. Note that items are not actually removed from the original list, only selected into a copy of the list.<\/p>\n<p>The example below demonstrates selecting a subset of five items from a list of 20 integers.<\/p>\n<pre class=\"crayon-plain-tag\"># select a random sample without replacement\r\nfrom random import seed\r\nfrom random import sample\r\n# seed random number generator\r\nseed(1)\r\n# prepare a sequence\r\nsequence = [i for i in range(20)]\r\nprint(sequence)\r\n# select a subset without replacement\r\nsubset = sample(sequence, 5)\r\nprint(subset)<\/pre>\n<p>Running the example first prints the list of integer values, then the random sample is chosen and printed for comparison.<\/p>\n<pre class=\"crayon-plain-tag\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\r\n[4, 18, 2, 8, 3]<\/pre>\n<\/p>\n<h3>Randomly Shuffle a List<\/h3>\n<p>Randomness can be used to shuffle a list of items, like shuffling a deck of cards.<\/p>\n<p>The <em>shuffle()<\/em> function can be used to shuffle a list. The shuffle is performed in place, meaning that the list provided as an argument to the <em>shuffle()<\/em> function is shuffled rather than a shuffled copy of the list being made and returned.<\/p>\n<p>The example below demonstrates randomly shuffling a list of integer values.<\/p>\n<pre class=\"crayon-plain-tag\"># randomly shuffle a sequence\r\nfrom random import seed\r\nfrom random import shuffle\r\n# seed random number generator\r\nseed(1)\r\n# prepare a sequence\r\nsequence = [i for i in range(20)]\r\nprint(sequence)\r\n# randomly shuffle the sequence\r\nshuffle(sequence)\r\nprint(sequence)<\/pre>\n<p>Running the example first prints the list of integers, then the same list after it has been randomly shuffled.<\/p>\n<pre class=\"crayon-plain-tag\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\r\n[11, 5, 17, 19, 9, 0, 16, 1, 15, 6, 10, 13, 14, 12, 7, 3, 8, 2, 18, 4]<\/pre>\n<\/p>\n<h2>3. Random Numbers with NumPy<\/h2>\n<p>In machine learning, you are likely using libraries such as scikit-learn and Keras.<\/p>\n<p>These libraries make use of NumPy under the covers, a library that makes working with vectors and matrices of numbers very efficient.<\/p>\n<p>NumPy also has its own implementation of a <a href=\"https:\/\/docs.scipy.org\/doc\/numpy\/reference\/routines.random.html\">pseudorandom number generator<\/a> and convenience wrapper functions.<\/p>\n<p>NumPy also implements the Mersenne Twister pseudorandom number generator.<\/p>\n<p>Let\u2019s look at a few examples of generating random numbers and using randomness with NumPy arrays.<\/p>\n<h3>Seed The Random Number Generator<\/h3>\n<p>The NumPy pseudorandom number generator is different from the Python standard library pseudorandom number generator.<\/p>\n<p>Importantly, seeding the Python pseudorandom number generator does not impact the NumPy pseudorandom number generator. It must be seeded and used separately.<\/p>\n<p>The <em>seed()<\/em> function can be used to seed the NumPy pseudorandom number generator, taking an integer as the seed value.<\/p>\n<p>The example below demonstrates how to seed the generator and how reseeding the generator will result in the same sequence of random numbers being generated.<\/p>\n<pre class=\"crayon-plain-tag\"># seed the pseudorandom number generator\r\nfrom numpy.random import seed\r\nfrom numpy.random import rand\r\n# seed random number generator\r\nseed(1)\r\n# generate some random numbers\r\nprint(rand(3))\r\n# reset the seed\r\nseed(1)\r\n# generate some random numbers\r\nprint(rand(3))<\/pre>\n<p>Running the example seeds the pseudorandom number generator, prints a sequence of random numbers, then reseeds the generator showing that the exact same sequence of random numbers is generated.<\/p>\n<pre class=\"crayon-plain-tag\">[4.17022005e-01 7.20324493e-01 1.14374817e-04]\r\n[4.17022005e-01 7.20324493e-01 1.14374817e-04]<\/pre>\n<\/p>\n<h3>Array of Random Floating Point Values<\/h3>\n<p>An array of random floating point values can be generated with the <em>rand()<\/em> NumPy function.<\/p>\n<p>If no argument is provided, then a single random value is created, otherwise the size of the array can be specified.<\/p>\n<p>The example below creates an array of 10 random floating point values drawn from a uniform distribution.<\/p>\n<pre class=\"crayon-plain-tag\"># generate random floating point values\r\nfrom numpy.random import seed\r\nfrom numpy.random import rand\r\n# seed random number generator\r\nseed(1)\r\n# generate random numbers between 0-1\r\nvalues = rand(10)\r\nprint(values)<\/pre>\n<p>Running the example generates and prints the NumPy array of random floating point values.<\/p>\n<pre class=\"crayon-plain-tag\">[4.17022005e-01 7.20324493e-01 1.14374817e-04 3.02332573e-01\r\n 1.46755891e-01 9.23385948e-02 1.86260211e-01 3.45560727e-01\r\n 3.96767474e-01 5.38816734e-01]<\/pre>\n<\/p>\n<h3>Array of Random Integer Values<\/h3>\n<p>An array of random integers can be generated using the <em>randint()<\/em> NumPy function.<\/p>\n<p>This function takes three arguments, the lower end of the range, the upper end of the range, and the number of integer values to generate or the size of the array. Random integers will be drawn from a uniform distribution including the lower value and excluding the upper value, e.g. in the interval [lower, upper).<\/p>\n<p>The example below demonstrates generating an array of random integers.<\/p>\n<pre class=\"crayon-plain-tag\"># generate random integer values\r\nfrom numpy.random import seed\r\nfrom numpy.random import randint\r\n# seed random number generator\r\nseed(1)\r\n# generate some integers\r\nvalues = randint(0, 10, 20)\r\nprint(values)<\/pre>\n<p>Running the example generates and prints an array of 20 random integer values between 0 and 10.<\/p>\n<pre class=\"crayon-plain-tag\">[5 8 9 5 0 0 1 7 6 9 2 4 5 2 4 2 4 7 7 9]<\/pre>\n<\/p>\n<h3>Array of Random Gaussian Values<\/h3>\n<p>An array of random Gaussian values can be generated using the <em>randn()<\/em> NumPy function.<\/p>\n<p>This function takes a single argument to specify the size of the resulting array. The Gaussian values are drawn from a standard Gaussian distribution; this is a distribution that has a mean of 0.0 and a standard deviation of 1.0.<\/p>\n<p>The example below shows how to generate an array of random Gaussian values.<\/p>\n<pre class=\"crayon-plain-tag\"># generate random Gaussian values\r\nfrom numpy.random import seed\r\nfrom numpy.random import randn\r\n# seed random number generator\r\nseed(1)\r\n# generate some Gaussian values\r\nvalues = randn(10)\r\nprint(values)<\/pre>\n<p>Running the example generates and prints an array of 10 random values from a standard Gaussian distribution.<\/p>\n<pre class=\"crayon-plain-tag\">[ 1.62434536 -0.61175641 -0.52817175 -1.07296862  0.86540763 -2.3015387\r\n  1.74481176 -0.7612069   0.3190391  -0.24937038]<\/pre>\n<p>Values from a standard Gaussian distribution can be scaled by multiplying the value by the standard deviation and adding the mean from the desired scaled distribution. For example:<\/p>\n<pre class=\"crayon-plain-tag\">scaled value = mean + value * stdev<\/pre>\n<p>Where <em>mean<\/em> and <em>stdev<\/em> are the mean and standard deviation for the desired scaled Gaussian distribution and <em>value<\/em> is the randomly generated value from a standard Gaussian distribution.<\/p>\n<h3>Shuffle NumPy Array<\/h3>\n<p>A NumPy array can be randomly shuffled in-place using the <em>shuffle()<\/em> NumPy function.<\/p>\n<p>The example below demonstrates how to shuffle a NumPy array.<\/p>\n<pre class=\"crayon-plain-tag\"># randomly shuffle a sequence\r\nfrom numpy.random import seed\r\nfrom numpy.random import shuffle\r\n# seed random number generator\r\nseed(1)\r\n# prepare a sequence\r\nsequence = [i for i in range(20)]\r\nprint(sequence)\r\n# randomly shuffle the sequence\r\nshuffle(sequence)\r\nprint(sequence)<\/pre>\n<p>Running the example first generates a list of 20 integer values, then shuffles and prints the shuffled array.<\/p>\n<pre class=\"crayon-plain-tag\">[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\r\n[3, 16, 6, 10, 2, 14, 4, 17, 7, 1, 13, 0, 19, 18, 9, 15, 8, 12, 11, 5]<\/pre>\n<\/p>\n<h3>Further Reading<\/h3>\n<p>This section provides more resources on the topic if you are looking to go deeper.<\/p>\n<ul>\n<li><a href=\"https:\/\/machinelearningmastery.com\/randomness-in-machine-learning\/\">Embrace Randomness in Machine Learning<\/a><\/li>\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/random.html\">random \u2013 Generate pseudo-random numbers<\/a><\/li>\n<li><a href=\"https:\/\/docs.scipy.org\/doc\/numpy\/reference\/routines.random.html\">Random sampling in NumPy<\/a><\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Pseudorandom_number_generator\">Pseudorandom number generator on Wikipedia<\/a><\/li>\n<\/ul>\n<h2>Summary<\/h2>\n<p>In this tutorial, you discovered how to generate and work with random numbers in Python.<\/p>\n<p>Specifically, you learned:<\/p>\n<ul>\n<li>That randomness can be applied in programs via the use of pseudorandom number generators.<\/li>\n<li>How to generate random numbers and use randomness via the Python standard library.<\/li>\n<li>How to generate arrays of random numbers via the NumPy library.<\/li>\n<\/ul>\n<p>Do you have any questions?<br \/>\nAsk your questions in the comments below and I will do my best to answer.<\/p>\n<p>The post <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/how-to-generate-random-numbers-in-python\/\">How to Generate Random Numbers in Python<\/a> appeared first on <a rel=\"nofollow\" href=\"https:\/\/machinelearningmastery.com\/\">Machine Learning Mastery<\/a>.<\/p>\n<\/div>\n<p><a href=\"https:\/\/machinelearningmastery.com\/how-to-generate-random-numbers-in-python\/\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: Jason Brownlee The use of randomness is an important part of the configuration and evaluation of machine learning algorithms. From the random initialization of [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2018\/07\/03\/how-to-generate-random-numbers-in-python\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":755,"comment_status":"registered_only","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[24],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/754"}],"collection":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=754"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/754\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/755"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}