<jupyter_start><jupyter_text>Good Evening to all  Random Forest Algorithm- efficient results for the large datsets- works better even though dataset has missing values<jupyter_code>import pandas as pd
df=pd.read_csv("birds.csv")
df.head()
df["type"].unique()
from sklearn.preprocessing import LabelEncoder
le=LabelEncoder()
df["type"]=le.fit_transform(df["type"])
df.head()
df["type"].unique()
df.isna().sum()
#replacing all the values with zero
import numpy as np
df=df.replace(np.nan,0.0)
df.isna().sum()
x=df.iloc[:,1:11]
x.head()
y=df["type"]
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.1,random_state=100)
from sklearn.ensemble import RandomForestClassifier
model=RandomForestClassifier()
model.fit(x_train,y_train)
y_pred=model.predict(x_test)
y_pred
from sklearn.metrics import accuracy_score,confusion_matrix
print(accuracy_score(y_test,y_pred))<jupyter_output>0.8571428571428571<jupyter_text>Unsupervised learning- train your machine on unlabelled without any guidance- Clustering--grouping of similar datapoints into clusters- Association ***Clustering**** K-Means(k-no of clusters)    - choose the optimal value of k    - initializing the centroids    - finding out mean and distances    - repeat step 2 and 3 untill convergence<jupyter_code>from sklearn.datasets import load_iris
iris=load_iris()
iris.keys()
df=pd.DataFrame(iris.data,columns=iris.feature_names)
df.head(2)
x=df.iloc[:,0:4]
range_k=range(1,8)
wsse_list=[]
from sklearn.cluster import KMeans
for k in range_k:
    model=KMeans(n_clusters=k)
    model.fit(x)
    wsse=model.inertia_
    wsse_list.append(wsse)
    print("the wsse for k={} is {}".format(k,wsse))
import matplotlib.pyplot as plt
x1=range_k
y1=wsse_list
plt.plot(x1,y1,marker='o')
plt.show()
from sklearn.cluster import KMeans
model=KMeans(n_clusters=3)
model.fit(x)
pred_out=model.predict(x)
pred_out
df["pred_target"]=pred_out
df.head(2)
df["pred_target"].value_counts()<jupyter_output><empty_output><jupyter_text>***exam timings:6:45pm to 7:15pm***<jupyter_code>range(1,8)
1,2,3,4,5,6,7<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12898686679174484, 'fraction_numerical': 0.025797373358348967, 'mean_word_length': 7.364705882352941, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '248660', 'license': 'CC0-1.0', 'n_tokens_mistral': 836, 'n_tokens_neox': 809, 'n_words': 161, 'path': 'Day08_03Nov2020/Day08_RandomForest_&_KMeans.ipynb', 'repo_name': 'AP-State-Skill-Development-Corporation/Machine-Learning-Using-Python-EB7', 'size': '2132'}