Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could u explain code and result . In [78]: from sklearn.model_selection import train_test_split d={ Male': 0 , 'Female': 1 } df[ 'Gender' ]=df[ 'Gender' ]map(d)

Could u explain code and result .

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

In [78]: from sklearn.model_selection import train_test_split d={ Male': 0 , 'Female': 1 } df[ 'Gender' ]=df[ 'Gender' ]map(d) d={ 'Eco': 0 , 'Business': 1, 'Eco Plus': 2\} df[ 'Class' ]=df[ 'Class' ]map(d) d={ 'Business travel': 0 , 'Personal Travel': 1} df[ 'Type of Travel'] =df[ 'Type of Travel' ]map(d) d={ 'Loyal Customer': 1, 'disloyal Customer': 0} df[ 'Customer Type'] = df['Customer Type'].map(d) features = ['Gender', 'Age', 'Type of Travel', 'Class', 'Inflight wifi service', 'Cleanliness', 'Departure Delay in Minutes'] X=df [features] y=df[ 'Customer Type'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size= 0.3, random_state=1) \# 70\% training and 30\% test In [79]: clf = DecisionTreeclassifier (ccpalpha=0.01) * Train Decision Tree Classifer clf=clf.fit(xtrain,ytrain) \#Predict the response for test dataset \( y_{\text {_pred }}= \) clf.predict \( \left(X_{\text {_test }} ight) \) In [89]: clf.get_params() Out [89]: \{'ccp_alpha': 0.01, 'class_weight': None, 'criterion': 'gini', 'max_depth': None, 'max_leaf_nodes': 'min_impurity_decrease' : 0.0, 'min_samples_leaf': 1 , 'min_samples_split': 2, 'min_weight_fraction_leaf': 0.0, 'random_state': None, : 'best'\} \begin{tabular}{l} = \\ \hdashline \end{tabular} feature_importance = pd.DataFrame(clf.feature_importances_, index = feature_names) feature_importance feature_importance.head(10).plot(kind = bar' ) : ax1 = sn.distplot(y_test, hist=False, color ="r, label ="s) sn.distplot(pred_random, hist=False, color=" b ", label=" a", ax=ax1) plt.show() 'distplot' is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either "displot' (a figure-level function with similar flexibility) or "kdeplot" (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 ax1 = sn.distplot(y_test, hist=False, color=" r ", label = "s") 'distplot' is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either "displot' (a figure-level function with similar flexibility) or "kdeplot' (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 sn. distplot(pred random, hist=False, color="b", label=" a", ax=ax1) plt.figure(figsize =(5,5) ) ax1 = sn.distplot (y_train, hist=False, color=" r ", label = "s") sn.distplot (pred_random2, hist=False, color="b", label="a", ax=ax1) plt.show() 'distplot' is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either 'displot' (a figure-level function with similar flexibility) or 'kdeplot' (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 ax1 = sn.distplot (y_train, hist=False, color=" r ", label = " s") 'distplot' is a deprecated function and will be removed in seaborn v 0.14.0. Please adapt your code to use either "displot' (a figure-level function with similar flexibility) or 'kdeplot' (an axes-level function for kernel density plots). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 sn.distplot (pred_random2, hist=False, color="b", label="a", ax=ax1) Windows'u Etkinletir Windows'u etkinletirmek iin Ayarlar'a gidin

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Organizing Your Speech Points

Answered: 1 week ago