<jupyter_start><jupyter_text>Load data<jupyter_code>from sklearn.datasets import load_iris
iris_data = load_iris()
type(iris_data)
iris_data.keys()
print(iris_data.target_names)
print(iris_data.DESCR)
df = pd.DataFrame(data=iris_data.data,columns=iris_data.feature_names) 
df.head()
df['target'] =iris_data.target
df.head()<jupyter_output><empty_output><jupyter_text>Check the packaging<jupyter_code>df.shape
#Check for null values
print(df.isnull().sum())
df.isnull()
print(df.columns)<jupyter_output>Index(['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)',
       'petal width (cm)', 'target'],
      dtype='object')<jupyter_text>Q. Can you set the columns as 
['sepal_length','sepal_width','petal_length','petal_width','target']<jupyter_code>#Ans:
df.columns = ['sepal_length','sepal_width','petal_length','petal_width','target']
df.head(2)<jupyter_output><empty_output><jupyter_text>Q. How many types of flowers do we have and what are their counts?<jupyter_code>#describe data
df.describe()
#Ans.
#Balanced in this case
#Rename the target variable
#Use of Apply
def rename_target(target):
  if target == 0:
    return 'setosa' 
  elif target == 1:
    return 'versicolor' 
  elif target == 2:
    return 'virginica'
  else:
    return target

df.target = df.target.apply(rename_target)
df.head()<jupyter_output><empty_output><jupyter_text>Q. Find the count of flowers that are having sepal length more than 85% of max sepal length and petal length greater than 50% of max petal length. Univariate Analysis<jupyter_code>#Seaborn: https://seaborn.pydata.org/
sns.scatterplot(data=df, x='sepal_length', y=np.zeros_like(df.sepal_length), hue='target')
#hue parameter determines which column in the data frame should be used for colour encoding<jupyter_output><empty_output><jupyter_text>Bivariate Analysis<jupyter_code>sns.FacetGrid(df,hue="target",size=6).map(plt.scatter,'sepal_length','petal_length').add_legend()<jupyter_output>/usr/local/lib/python3.7/dist-packages/seaborn/axisgrid.py:316: UserWarning: The `size` parameter has been renamed to `height`; please update your code.
  warnings.warn(msg, UserWarning)<jupyter_text>Q. Based on which features can we separate setosa from virginica?<jupyter_code>sns.pairplot(df,vars =['sepal_length','sepal_width'],hue='target',size=4)
#!pip install pandas_profiling
!pip install pandas-profiling==2.8.0
from pandas_profiling import ProfileReport
#https://github.com/pandas-profiling/pandas-profiling
profile = ProfileReport(df)
profile.to_file("output.html")
#profile.to_widgets()
#Based on profiling report.
df.drop_duplicates(keep='first')
df.corr()
plt.figure(figsize= (6, 6))
sns.heatmap(df.corr())
from google.colab import files
uploaded = files.upload()
#Automobile Dataset
#https://archive.ics.uci.edu/ml/datasets/Automobile
col_name = ['symboling','normalized-losses','make','fuel-type','aspiration','num-of-doors','body-style','drive-wheels','engine-location','wheel-base','length','width','height','curb-weight','engine-type','num-of-cylinders','engine-size','fuel-system','bore','stroke','compression-ratio','horsepower','peak-rpm','city-mpg','highway-mpg','price']
data = pd.read_csv('automobile.csv',names = col_name)
data.columns
#checking the first 5 and last 5 rows
data.head(-5)<jupyter_output><empty_output><jupyter_text>Q. What is the distribution of cars for symboling values?<jupyter_code>#Ans
#Finding distribution of cars based on symboling stat
plt.hist(data.symboling)
plt.ylabel('Count')
plt.xlabel('Symboling')
#Relation between Price and Symboling
plt.scatter(data.symboling,data.price)
plt.yticks([])
plt.ylabel('Price')
plt.xlabel('Symboling')<jupyter_output><empty_output><jupyter_text>Q. Plot the count for body-style column<jupyter_code>#Ans<jupyter_output><empty_output><jupyter_text>Q. What if we want to find relation between body-style and safety rating/<jupyter_code>sns.catplot(x='body-style', kind="count",hue='symboling', palette="ch:.25", data = data)
#Creating smafe-label based on symboling value
data['safe-label'] = data.symboling.apply(lambda x:'safe' if x<=0 else 'unsafe')
data.head()
palette = ["#FF0000", "#00FF00"]
sns.catplot(x="body-style",palette=palette,hue="safe-label",kind="count",data=data)<jupyter_output><empty_output><jupyter_text>Q. Can you find the symboling stats for cars that are safe?<jupyter_code>#Ans
#Relation of symboling with number of doors
palette = ["#FF0000", "#00FF00"]
sns.catplot(x="num-of-doors", data=data, hue="safe-label", kind="count", size=3, palette=palette )
data['num-of-doors'].value_counts()
#Searching ? in entire data
data.isin(['?']).sum()<jupyter_output><empty_output><jupyter_text>Q. Find car distribution by drive-wheel and body-style and give the symboling count<jupyter_code>#Ans
#Plot relation between Drive wheels and the car body type
data['drive-wheel-num'] = data['drive-wheels'].map({"fwd": 1, "rwd": 2, "4wd": 3})
drw_bs =data.groupby(by=['body-style','drive-wheels'],as_index=False)['drive-wheels'].size()
drw_bs
sns.lineplot(x='body-style',y='size', data=drw_bs, hue="drive-wheels")<jupyter_output><empty_output><jupyter_text>Assignment
1. Do analysis of various features wrt price of the car

2. Do analysis on the Titanic Dataset 
clue: survival vs gender, survival vs passenger class, survival vs age, survival vs embarked category<jupyter_code>uploaded = files.upload()
#Titanic Dataset
df_titanic = pd.read_csv('titanic_train.csv')
df_titanic.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1498442938267082, 'fraction_numerical': 0.008976002930939732, 'mean_word_length': 7.625592417061611, 'pattern_counts': {'":': 3, '<': 52, '<?xml version=': 0, '>': 51, 'https://': 3, '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': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '92523', 'license': 'MIT', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1927, 'n_words': 400, 'path': 'EDA.ipynb', 'repo_name': 'Amanimatta/data-science-bootcamp', 'size': '5459'}