# How to Output a Value with Changed Random State

Asked 5 months ago, Updated 5 months ago, 17 views

I am outputting while changing random state in machine learning.
For example, is it possible for the following program to output random state from 0 to 20 all values?
Currently, I manually change from 0 to 20 and output it on the jupyter notebook one by one.

``````import numpy as np
from sklearn.enable import RandomForestClassifier
from sklearn.model_selection import LeaveOneOut
from sklearn.model_selection import cross_val_score

forest=RandomForestClassifier(n_estimators=100, random_state=0)
labels=data [:,0:1]
features=data [:,1:]
loo=LeaveOneOut()
scores=cross_val_score(forest, features, labels.ravel(), cv=loo)

print('Mean accuracy: {:3f}'.format(scores.mean())))
``````

python numpy

2022-09-30 11:07

The task is to repeat almost the same thing over and over again, so you can do it using the for statement."In addition, this time, ""repeat while changing from 0 to 20"", so simply change one variable from 0 to 20 and repeat it."

For example, the program below prints numbers from 0 to 20.

``````for i in range(0,21):
print(i)
``````

This problem can be solved by changing the contents of the for statement in the same way.

Perhaps they are learning machine learning while copying and pasting Python programs from some kind of material.If you want to do something more advanced, you have to understand the programming language Python itself to a certain extent, so I think it will be easier to do any Python tutorials in the future.

2022-09-30 11:07

## If you have any answers or tips

Popular Tags
python x 4627
android x 1593
java x 1492
javascript x 1425
c x 924
c++ x 877
ruby-on-rails x 696
php x 692
python3 x 683
html x 656