修改圖片尺寸
from matplotlib import pyplot as plt
plt.figure(figsize=(100, 5))
經過以上兩行起做用
sns.barplot(x=age_survived.index, y=age_survived['Survived'] + age_survived['Dead'], color='red')
sns.barplot(x=age_survived.index, y=age_survived['Survived'], color='green')圖片
數據探索性分析ci
barplot與boxplot畫圖效果不一致,barplot不能顯示較高精度。boxplot能夠顯示均值範圍以及異常值個數。pandas
sns.pairplot(iris, hue='Name')
單個變量離散程度
sns.scatterplot(x=train.index, y=train.SibSp)it
由pandas提供boxplot方法
iris.boxplot(by="Name", figsize=(12, 6))io
y_test若不爲二分類label,則須要指定pos_label, pos_labelz做爲正例,其他class都做爲反例
fpr, tpr, threshold = roc_curve(y_test, svc.decision_function(X_test)[:, 1], pos_label=1)
sns.lineplot(x=fpr, y=tpr)function
sns.heatmap(confusion_matrix(y_test, svc.predict(X_test)), annot=True)class
y軸爲param_grid中第一個參數,x軸爲param_grid中第二個參數,但不能設置xlable, ylabel
sns.heatmap(scores, yticklabels=param_grid['C'], xticklabels=param_grid['gamma'],
annot=True, )test
設置orient,且交換x, y
sns.barplot(x=sorted_feature_importances, y=sorted_feature_names, orient='h')
sns.barplot(x=sorted_feature_names, y=sorted_feature_importances)import
構建一個DataFrame,x='epoches', y='acc'分別爲DataFrame key
sns.lineplot(x='epoches', y='acc', data=train_history_df, markers=True)變量
由dict構建一個DataFrame
history_dic = train_history.history
epochs = np.shape(train_history.history['acc'])[0]
history_dic['epoches'] = range(epochs)
ratings['rating']爲pandas中Series結構
sns.distplot(ratings['rating'])
matploitlib直方圖
plt.hist(ratings['rating'])
用barplot或者catplot,能夠引用hue屬性,查看3個變量狀況
sns.barplot(x='SibSp', y='Survived', hue='Sex', data=train_ready)
sns.catplot(x='SibSp', y='Survived', hue='Sex', data=train_ready, kind='bar')
sns.catplot(x='SibSp', y='Survived', hue='Sex', data=train_ready, kind='box')
不能用barplot,不然會因爲bar過多而密集
用distplot,不容許數據中有空值,須要先填充空值
sns.distplot(a=train_ready['Age'])
用FacetGrid,容許數據中有空值
g = sns.FacetGrid(train_ready, col='Survived')
g.map(sns.distplot, 'Age')
sns.barplot(x=sex_survived.index, y=sex_survived['Survived']+sex_survived['Dead'], color='red') sns.barplot(x=sex_survived.index, y=sex_survived['Survived'], color='green')