Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

random search cv

# Import necessary modules
from scipy.stats import randint
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import RandomizedSearchCV

# Setup the parameters and distributions to sample from: param_dist
param_dist = {"max_depth": [3, None],
              "max_features": randint(1, 9),
              "min_samples_leaf": randint(1, 9),
              "criterion": ["gini", "entropy"]}
…# Print the tuned parameters and score
print("Tuned Decision Tree Parameters: {}".format(tree_cv.best_params_))
print("Best score is {}".format(tree_cv.best_score_))
Comment

PREVIOUS NEXT
Code Example
Python :: try catch python 
Python :: data structures and algorithms in python 
Python :: how to import your own function python 
Python :: line length in flake8 
Python :: get the current date and time in python 
Python :: drop a list of index pandas 
Python :: pandas df num rows 
Python :: set type of column pandas 
Python :: python argparse file argument 
Python :: python del 
Python :: seaborn histplot modify legend 
Python :: python make an object hashable 
Python :: python path to python executable 
Python :: while loop python 
Python :: Display if the column(s) contain duplicates in the DataFrame 
Python :: how to make addition in python 
Python :: python list fill nan 
Python :: flask print to console 
Python :: django render template 
Python :: Python JSON API example 
Python :: check if array is empty python 
Python :: dictionary to list python 
Python :: python print trailing zeros 
Python :: how to get int input in python 
Python :: keyboardinterrupt python 
Python :: python run command 
Python :: python - find specific name in a df 
Python :: check if year is leap python 
Python :: Python Changing Directory 
Python :: rename in python 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =