<jupyter_start><jupyter_text>Using the readings, try and create a RandomForestClassifier for the iris dataset<jupyter_code>iris = datasets.load_iris() 
iris.keys()
X = iris.data[:,2:]
y = iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, stratify=y, random_state=42, test_size=0.25,train_size=0.75)
#What is random_state?
#What is stratify?
#What is this doing in the moon example exactly?
#X, y = make_moons(n_samples=100, noise=0.25, random_state=3)
forest = RandomForestClassifier(n_estimators=5, random_state=100)
forest.fit(X_train, y_train)
print("accuracy on training set: %f" % forest.score(X_train, y_train))
print("accuracy on test set: %f" % forest.score(X_test, y_test))<jupyter_output>accuracy on training set: 0.990991
accuracy on test set: 0.948718<jupyter_text>Using a 25/75 training/test split, compare the results with the original decision tree model and describe the result to the best of your ability in your PR<jupyter_code>X_train, X_test, y_train, y_test = train_test_split(x,y,test_size=0.25,train_size=0.75)
dt = tree.DecisionTreeClassifier()
dt = dt.fit(X_train,y_train)
y_pred=dt.predict(X_test)
Accuracy_score = metrics.accuracy_score(y_test, y_pred)
Accuracy_score
#Comments on RandomForestClassifiers & Original Decision Tree Model
#While the Random Trees result is consistent, varying depending how you choose the random_state or the n_estimators, 
#the result of the orgininal decision tree model varies a lot. 
#The random_state defines how random the versions of the data is that the modelling takes into consideration, and 
#the n_estimators regulates how many "random" datasets are used. It's fascinating to see how the this makes the 
#result so much more consistent than the orginal decision tree model. 
#General commets on the homework
#I really enjoyed this homework and it really helped me understand, what is going on under the hood. 
#I found this reading while I was doing the homework. It looks nice to go deeper? Do you know the
#guy? https://github.com/amueller/introduction_to_ml_with_python
#I feel I now need practice on real life dirty data sets, to fully understand how predictions models 
#can work. I take my comments back, that I can't see how I can implement this into my reporting. I can. But how 
#can I do this technically? i.e. with the data on PERM visas? Say input nationality, wage, lawyer, job title, and get a reply what the chances could be of 
#getting a work visa? I also feel a little shaky on how I need to prep my data to feed in it into the predictor 
#correctly.
#Comments on classifier
#Questions:
#Not sure why it's 10fold cross validation, cv is set at 5?
#Why are we predicting the<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07269372693726937, 'fraction_numerical': 0.01734317343173432, 'mean_word_length': 5.485645933014354, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '509489', 'license': 'MIT', 'n_tokens_mistral': 888, 'n_tokens_neox': 840, 'n_words': 358, 'path': '09 More Trees/homework/Skinner_Barnaby_9_2.ipynb', 'repo_name': 'barjacks/algorithms_mine', 'size': '2710'}