百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

seaborn-analyzer

> 编程语言
开源

seaborn-analyzer 使用 Seaborn 库的数据分析和可视化工具。本文档是日语版。英文版可在以下链接查看:

99 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

seaborn-analyzer 使用 Seaborn 库的数据分析和可视化工具。本文档是日语版。英文版可在以下链接查看:

seaborn-analyzer

A data analysis and visualization tool using Seaborn library.

This documentation is Japanese language version. English version is here

API reference is here

使用法

CustomPairPlotクラスの使用例

python
from seaborn_analyzer import CustomPairPlot
import seaborn as sns

titanic = sns.load_dataset("titanic")
cp = CustomPairPlot()
cp.pairanalyzer(titanic, hue='survived')

※その他のクラスの使用法は構成の項を参照ください

※Qiitaにも記事を作成している ので、こちらもご覧ください

必要要件

  • Python >=3.6
  • Numpy >=1.20.3
  • Pandas >=1.2.4
  • Matplotlib >=3.1.3
  • Seaborn >=0.11.0
  • Scipy >=1.6.3
  • Scikit-learn >=0.24.2

インストール方法

$ pip install seaborn-analyzer

サポート

バグ等はIssuesで報告してください

構成

seabornを利用して、各種データの可視化および評価指標の算出を実施します。 以下のクラスからなります

クラス名 パッケージ名 概要 使用法
CustomPairPlot custom_pair_plot.py 散布図行列と相関係数行列を同時に表示 リンク
hist custom_hist_plot.py ヒストグラムと各種分布のフィッティング リンク
classplot custom_class_plot.py 分類境界およびクラス確率の表示 リンク
regplot custom_reg_plot.py 相関・回帰分析の散布図・ヒートマップ表示 リンク

CustomPairPlotクラス (custom_pair_plot.py)

散布図行列と相関係数行列を同時に表示します。 1個のクラス「CustomPairPlot」からなります

・CustomPairPlotクラス内のメソッド一覧

メソッド名 機能
pairanalyzer 散布図行列と相関係数行列を同時に表示します

pairanalyzerメソッド

実行例

python
from seaborn_analyzer import CustomPairPlot
import seaborn as sns

titanic = sns.load_dataset("titanic")
cp = CustomPairPlot()
cp.pairanalyzer(titanic, hue='survived')

引数一覧

引数名 必須引数orオプション 型 デフォルト値 内容
data 必須 pd.DataFrame - 入力データ
hue オプション str None 色分けに指定するカラム名 (Noneなら色分けなし)
palette オプション str None hueによる色分け用のカラーパレット
vars オプション list[str] None グラフ化するカラム名 (Noneなら全ての数値型&Boolean型の列を使用)
lowerkind オプション str 'boxscatter' 左下に表示するグラフ種類 ('boxscatter', 'scatter', or 'reg')
diag_kind オプション str 'kde' 対角に表示するグラフ種類 ('kde' or 'hist')
markers オプション str or list[str] None hueで色分けしたデータの散布図プロット形状
height オプション float 2.5 グラフ1個の高さ
aspect オプション float 1 グラフ1個の縦横比
dropna オプション bool True seaborn.PairGridのdropna引数
lower_kws オプション dict {} seaborn.PairGrid.map_lowerの引数
diag_kws オプション dict {} seaborn.PairGrid.map_diag引数
grid_kws オプション dict {} seaborn.PairGridの上記以外の引数

CustomPairPlotクラス使用法詳細

こちらの記事にまとめました https://qiita.com/c60evaporator/items/20f11b6ee965cec48570

histクラス (custom_hist_plot.py)

ヒストグラム表示および各種分布のフィッティングを実行します。

・histクラス内のメソッド一覧

メソッド名 機能
plot_normality 正規性検定とQQプロット
fit_dist 各種分布のフィッティングと、評価指標(RSS, AIC, BIC)の算出

plot_normalityメソッド

実行例

python
from seaborn_analyzer import hist
from sklearn.datasets import load_boston
import pandas as pd
df = pd.DataFrame(load_boston().data, columns= load_boston().feature_names)
hist.plot_normality(df, x='LSTAT', norm_hist=False, rounddigit=5)

引数一覧

引数名 必須引数orオプション 型 デフォルト値 内容
data 必須 pd.DataFrame, pd.Series, or pd.ndarray - 入力データ
x オプション str None ヒストグラム作成対象のカラム名 (dataがpd.DataFrameのときは必須)
hue オプション str None 色分けに指定するカラム名 (Noneなら色分けなし)
binwidth オプション float None ビンの幅 (binsと共存不可)
bins オプション int 'auto' ビンの数 (bin_widthと共存不可、'auto'ならスタージェスの公式で自動決定)
norm_hist オプション bool False ヒストグラムを面積1となるよう正規化するか?
sigmarange オプション float 4 フィッティング線の表示範囲 (標準偏差の何倍まで表示するか指定)
linesplit オプション float 200 フィッティング線の分割数 (カクカクしたら増やす)
rounddigit オプション int 5 表示指標の小数丸め桁数
hist_kws オプション dict {} matplotlib.axes.Axes.histに渡す引数
subplot_kws オプション dict {} matplotlib.pyplot.subplotsに渡す引数

fit_distメソッド

実行例

python
from seaborn_analyzer import hist
from sklearn.datasets import load_boston
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
df = pd.DataFrame(load_boston().data, columns= load_boston().feature_names)
all_params, all_scores = hist.fit_dist(df, x='LSTAT', dist=['norm', 'gamma', 'lognorm', 'uniform'])
df_scores = pd.DataFrame(all_scores).T
df_scores

引数一覧

引数名 必須引数orオプション 型 デフォルト値 内容
data 必須 pd.DataFrame, pd.Series, or pd.ndarray - 入力データ
x オプション str None ヒストグラム作成対象のカラム名 (dataがpd.DataFrameのときは必須)
hue オプション str None 色分けに指定するカラム名 (Noneなら色分けなし)
binwidth オプション float None ビンの幅 (binsと共存不可)
bins オプション int 'auto' ビンの数 (bin_widthと共存不可、'auto'ならスタージェスの公式で自動決定)
norm_hist オプション bool False ヒストグラムを面積1となるよう正規化するか?
sigmarange オプション float 4 フィッティング線の表示範囲 (標準偏差の何倍まで表示するか指定)
linesplit オプション float 200 フィッティング線の分割数 (カクカクしたら増やす)
dist オプション str or list[str] 'norm' 分布の種類 ('norm', 'lognorm', 'gamma', 't', 'expon', 'uniform', 'chi2', 'weibull')
ax オプション matplotlib.axes.Axes None 表示対象のax (Noneならmatplotlib.pyplot.plotで1枚ごとにプロット)
linecolor オプション str or list[str] 'red' フィッティング線の色指定 (listで複数指定可)
floc オプション float None フィッティング時のX方向オフセット (Noneなら指定なし(weibullとexponは0))
hist_kws オプション dict {} matplotlib.axes.Axes.histに渡す引数

histクラス使用法詳細

こちらの記事にまとめました https://qiita.com/c60evaporator/items/fc531aff0cdbafac0f42

classplotクラス

分類の決定境界およびクラス確率の表示を実行します。

Scikit-Learn APIに対応した分類モデル (例: XGBoostパッケージのXGBoostClassifierクラス)が表示対象となります

・classplotクラス内のメソッド一覧

メソッド名 機能
class_separator_plot 決定境界プロット
class_proba_plot クラス確率プロット
plot_roc_curve_multiclass マルチクラス分類におけるROC曲線をプロット
roc_plot クロスバリデーションにおけるROC曲線をプロット

class_separator_plotメソッド

実行例

python
import seaborn as sns
from sklearn.svm import SVC
from seaborn_analyzer import classplot
iris = sns.load_dataset("iris")
clf = SVC()
classplot.class_separator_plot(clf, ['petal_width', 'petal_length'], 'species', iris)

引数一覧

引数名 必須引数orオプション 型 デフォルト値 内容
clf 必須 Scikit-learn API - 表示対象の分類モデル
x 必須 list[str] - 説明変数に指定するカラム名
y 必須 str - 目的変数に指定するカラム名
data 必須 pd.DataFrame - 入力データ
x_chart オプション list[str] None 説明変数のうちグラフ表示対象のカラム名
pair_sigmarange オプション float 1.5 グラフ非使用変数の分割範囲
pair_sigmainterval オプション float 0.5 グラフ非使用変数の1枚あたり表示範囲
chart_extendsigma オプション float 0.5 グラフ縦軸横軸の表示拡張範囲
chart_scale オプション int 1 グラフの描画倍率
plot_scatter オプション str 'true' 散布図の描画種類
rounddigit_x3 オプション int 2 グラフ非使用軸の小数丸め桁数
scatter_colors オプション list[str] None クラスごとのプロット色のリスト
true_marker オプション str None 正解クラスの散布図プロット形状
false_marker オプション str None 不正解クラスの散布図プロット形状
cv オプション int or sklearn.model_selection.* None クロスバリデーション分割法 (Noneのとき学習データから指標算出、int入力時はkFoldで分割)
cv_seed オプション int 42 クロスバリデーションの乱数シード
cv_group オプション str None クロスバリデーションのグルーピング対象カラム名、またはグルーピングのラベルデータ (GroupKFold,LeaveOneGroupOut等)
display_cv_indices オプション int 0 表示対象のクロスバリデーション番号
clf_params オプション dict None 分類モデルに渡すパラメータ
fit_params オプション dict None 学習時のパラメータ
subplot_kws オプション dict None matplotlib.pyplot.subplotsに渡す引数
contourf_kws オプション dict None グラフ表示用のmatplotlib.pyplot.contourfに渡す引数
scatter_kws オプション dict None 散布図用のmatplotlib.pyplot.scatterに渡す引数
legend_kws オプション dict None 凡例用のmatplotlib.axes.Axes.legendに渡す引数

class_proba_plotメソッド

実行例

python
import seaborn as sns
from sklearn.svm import SVC
from seaborn_analyzer import classplot
iris = sns.load_dataset("iris")
clf = SVC()
classplot.class_proba_plot(clf, ['petal_width', 'petal_length'], 'species', iris,
                           proba_type='imshow')

引数一覧

引数名 必須引数orオプション 型 デフォルト値 内容
clf 必須 Scikit-learn API - 表示対象の分類モデル
x 必須 list[str] - 説明変数に指定するカラム名
y 必須 str - 目的変数に指定するカラム名
data 必須 pd.DataFrame - 入力データ
x_chart オプション list[str] None 説明変数のうちグラフ表示対象のカラム名
pair_sigmarange オプション float 1.5 グラフ非使用変数の分割範囲
pair_sigmainterval オプション float 0.5 グラフ非使用変数の1枚あたり表示範囲
chart_extendsigma オプション float 0.5 グラフ縦軸横軸の表示拡張範囲
chart_scale オプション int 1 グラフの描画倍率
plot_scatter オプション str 'true' 散布図の描画種類
rounddigit_x3 オプション int 2 グラフ非使用軸の小数丸め桁数
scatter_colors オプション list[str] None クラスごとのプロット色のリスト
true_marker オプション str None 正解クラスの散布図プロット形状
false_marker オプション str None 不正解クラスの散布図プロット形状
cv オプション int or sklearn.model_selection.* None クロスバリデーション分割法 (Noneのとき学習データから指標算出、int入力時はkFoldで分割)
cv_seed オプション int 42 クロスバリデーションの乱数シード
cv_group オプション str None クロスバリデーションのグルーピング対象カラム名、またはグルーピングのラベルデータ (GroupKFold,LeaveOneGroupOut等)
display_cv_indices オプション int 0 表示対象のクロスバリデーション番号
clf_params オプション dict None 分類モデルに渡すパラメータ
fit_params オプション dict None 学習時のパラメータ
subplot_kws オプション dict None matplotlib.pyplot.subplotsに渡す引数
contourf_kws オプション dict None proba_type='contour'のときmatplotlib.pyplot.contourf、 proba_type='contour'のときcontour)に渡す引数
scatter_kws オプション dict None 散布図用のmatplotlib.pyplot.scatterに渡す引数
plot_border オプション bool True 決定境界線の描画有無
proba_class オプション str or list[str] None 確率表示対象のクラス名
proba_cmap_dict オプション dict[str, str] None クラス確率図のカラーマップ(クラス名とcolormapをdict指定)
proba_type オプション str 'contourf' クラス確率図の描画種類
(等高線'contourf', 'contour', or RGB画像'imshow')
imshow_kws オプション dict None proba_type='imshow'のときmatplotlib.pyplot.imshowに渡す引数
legend_kws オプション dict None 凡例用のmatplotlib.axes.Axes.legendに渡す引数

plot_roc_curve_multiclassメソッド

マルチクラス分類でのROC曲線をプロットします(2クラス分類もプロット可)

実行例

…

引数一覧

引数名 必須引数orオプション 型 デフォルト値 内容
estimator 必須 Scikit-learn API - 表示対象の分類モデル(未学習かつパラメータ入力済の分類器を渡してください)
X_train 必須 np.ndarray - 学習用データのうち説明変数
y_train 必須 np.ndarray - 学習用データのうち目的変数
X_test オプション np.ndarray - ROC曲線評価用データのうち説明変数
y_test オプション np.ndarray None ROC曲線評価用データのうち目的変数
sample_weight オプション list[float] None ROC曲線算出時のクラスごとの重みづけ
drop_intermediate オプション bool True ROC曲線の形状に影響しない点の計算を省略するか
response_method オプション {'predict_proba', 'decision_function'} 'predict_proba' クラス確率算出に使用するメソッド名
name オプション str None 学習器の名称
ax オプション matplotlib.axes.Axes None 表示対象のax (Noneならmatplotlib.pyplot.plotで1枚ごとにプロット)
pos_label オプション str or int None Positive判定するラベル番号、2クラス分類のみ有効
average オプション list[str] None クラスごとのプロット色のリスト
fit_params オプション dict None 学習器のfit()メソッドに渡すパラメータ
plot_roc_kws オプション dict None クラスごとROC曲線描画用のax.plot()メソッドに渡すパラメータ
class_average_kws オプション dict None 全

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言