Linked Questions
27 questions linked to/from What does numpy.random.seed(0) do?
0
votes
0
answers
34
views
Hash-based selection, based on choices and probabilities [duplicate]
I have a list of choices in python like:
choices = ['A', 'B', 'C', 'D']
and a list of probabilities like:
probs = [0.5, 0.2, 0.1, 0.1]
they're related position-wise, A has a probability of 0.5, ...
138
votes
4
answers
70k
views
Differences between numpy.random and random.random in Python
I have a big script in Python. I inspired myself in other people's code so I ended up using the numpy.random module for some things (for example for creating an array of random numbers taken from a ...
71
votes
4
answers
8k
views
Randomness of Python's random
I'm using Python to generate images using dashed lines for stippling. The period of the dashing is constant, what changes is dash/space ratio. This produces something like this:
However in that image ...
8
votes
2
answers
12k
views
Generate random timeseries data with dates
I am trying to generate random data(integers) with dates so that I can practice pandas data analytics commands on it and plot time series graphs.
temp depth acceleration
2019-01-1 ...
14
votes
1
answer
38k
views
What exactly does the Pandas random_state do?
I have the following code where I use the Pandas random_state
randomState = 123
sampleSize = 750
df = pd.read_csv(filePath, delim_whitespace=True)
df_s = df.sample(n=sampleSize, random_state=...
4
votes
3
answers
6k
views
Python Numpy: Random number in a loop
I have such code and use Jupyter-Notebook
for j in range(timesteps):
a_int = np.random.randint(largest_number/2) # int version
and i get random numbers, but when i try to move part of code to ...
1
vote
1
answer
3k
views
Gensim LDA: coherence values not reproducible between runs
I used this code, https://datascienceplus.com/evaluation-of-topic-modeling-topic-coherence/, to find topic coherence for a dataset. When I tried this code with the same number of topics, I got new ...
6
votes
1
answer
3k
views
Why does my keras neural network model output different values on a different machine?
I am using aws ec2 to train a model for a multi-label classification task. After training , I tested the model on the same machine which gives me good results (accuracy of 90+%). However, after I ...
3
votes
1
answer
7k
views
Set numpy.random.seed on a global scale [closed]
How can I set numpy.random.seed(0) on a global scale? It seems I have to reset the seed every time I call a np.random function.
import numpy as np
np.random.seed(0)
print(np.random.randint(0,10,2))
...
1
vote
2
answers
4k
views
random_state parameter in sklearn's train_test_split
What difference does different values of random state makes to the output? For instance, if I set 0 and if I set 100 what difference would it make to the output?
1
vote
1
answer
4k
views
XgBoost accuracy results differ on each run, with the same parameters. How can I make them constant?
The 'merror' and 'logloss' result from XGB multiclass classification differs by about 0.01 or 0.02 on each run, with the same parameters. Is this normal?
I want 'merror' and 'logloss' to be constant ...
1
vote
3
answers
2k
views
Dynamic pandas dataframe generation
Here is code I wrote to generate a dataframe that contains 4 columns
num_rows = 10
df = pd.DataFrame({ 'id_col' : [x+1 for x in range(num_rows)] , 'c1': [randint(0, 9) for x in range(num_rows)], 'c2'...
0
votes
1
answer
2k
views
RandomizedSearchCV best_params_ changes everytime when I run this program
I want to use LogisticRegression to classify. So, I use RandomizedSearchCV to pick best C params in LogisticRegression.
My question is: Why do best_params_ change every time I run this program? I ...
0
votes
4
answers
541
views
Sorting a pandas dataframe rowwise
A sample input data frame
import pandas as pd
df_input = pd.DataFrame([[1.7, 0.2], [0.4, 0.93], [0.05, 0.96], [0.97, 0.68]], columns=["A", "B"])
This example has two columns whereas the real ...
1
vote
1
answer
1k
views
np.random.seed need to be called every time
Following two version code should have given the same output. Looks like np.random.seed need to be called every time. Is it correct?
Is there any way to set seed once so that same random number ...