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)
data=np.loadtxt('mh.csv', delimiter=',',', skiprows=1, dtype=float)
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())))
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.
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 Understanding How to Configure Google API Key
566 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
567 Who developed the "avformat-59.dll" that comes with FFmpeg?
596 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.