Package: seaborn-analyzer
seaborn-analyzerA data analysis and visualization tool using Seaborn library.UsageAn example of using CustomPairPlot classfromseaborn_analyzerimportCustomPairPlotimportseabornassnstitanic=sns.load_dataset("titanic")cp=CustomPairPlot()cp.pairanalyzer(titanic,hue='survived')If you want to know the usage of the other classes, seeAPI ReferenceandExamplesRequirementsseaborn-analyzer 0.3.6 requiresPython >=3.6Numpy >=1.20.3Pandas >=1.2.4Matplotlib >=3.1.3Seaborn >=0.11.1Scipy >=1.6.3Scikit-learn >=0.24.2LightGBM >=3.3.2Installing seaborn-analyzerUse pip to install the binary wheels onPyPI$pipinstallseaborn-analyzerSupportBugs may be reported athttps://github.com/c60evaporator/seaborn-analyzer/issuesAPI ReferenceThe following classes and methods are included in seaborn-analyzerCustomPairPlot classMethod nameSummaryAPI DocumentationExamplepairanalyzerPlot pair plot including scatter plot and correlation coefficient matrix simultaneously.CustomPairPlot.pairanalyzerexamplehist classMethod nameSummaryAPI DocumentationExampleplot_normalityPlot normality test result and QQ plot.hist.plot_normalityexamplefit_distFit distributions by maximum likelihood estimation and calculate fitting scores.hist.fit_distexampleclassplot classMethod nameSummaryAPI DocumentationExampleclass_separator_plotPlot class separation lines of any scikit-learn classifier.hist.class_separator_plotexampleclass_proba_plotPlot class prediction probability of any scikit-learn classifier.hist.class_proba_plotexampleplot_roc_curve_multiclassPlot ROC curve in multiclass classifier.hist.class_separator_plotexampleroc_plotPlot ROC curve with cross validation.hist.class_proba_plotexampleregplot classMethod nameSummaryAPI DocumentationExamplelinear_plotPlot linear regression line and calculate Pearson correlation coefficient.regplot.linear_plotexampleregression_pred_truePlot prediction vs. true scatter plots of any scikit-learn regressor.regplot.regression_pred_trueexampleregression_plot_1dPlot regression lines of any scikit-learn regressor with 1D explanatory variable.regplot.regression_plot_1dexampleregression_heat_plotPlot regression heatmaps of any scikit-learn regressor with 2 to 4D explanatory variables.regplot.regression_heat_plotexampleaverage_plotPlot relationship between one explanatory variable and predicted value by line graph.regplot.average_plotexampleExamplesCustomPairPlot.pairanalyzerfromseaborn_analyzerimportCustomPairPlotimportseabornassnstitanic=sns.load_dataset("titanic")cp=CustomPairPlot()cp.pairanalyzer(titanic,hue='survived')hist.plot_normalityfromseaborn_analyzerimporthistfromsklearn.datasetsimportload_bostonimportpandasaspddf=pd.DataFrame(load_boston().data,columns=load_boston().feature_names)hist.plot_normality(df,x='LSTAT',norm_hist=False,rounddigit=5)hist.fit_distfromseaborn_analyzerimporthistfromsklearn.datasetsimportload_bostonimportpandasaspdimportmatplotlib.pyplotaspltfromscipyimportstatsdf=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).Tdf_scoresclassplot.class_separator_plotimportseabornassnsfromsklearn.svmimportSVCfromseaborn_analyzerimportclassplotiris=sns.load_dataset("iris")clf=SVC()classplot.class_separator_plot(clf,['petal_width','petal_length'],'species',iris)classplot.class_proba_plotimportseabornassnsfromsklearn.svmimportSVCfromseaborn_analyzerimportclassplotiris=sns.load_dataset("iris")clf=SVC()classplot.class_proba_plot(clf,['petal_width','petal_length'],'species',iris,proba_type='imshow')classplot.plot_roc_curve_multiclassimportseabornassnsfromsklearn.svmimportSVCfromsklearn.model_selectionimporttrain_test_splitimportnumpyasnpimportmatplotlib.pyplotaspltfromseaborn_analyzerimportclassplot# Load datasetiris=sns.load_dataset("iris")OBJECTIVE_VARIALBLE='species'# Objective variableUSE_EXPLANATORY=['petal_width','petal_length','sepal_width','sepal_length']# Explantory variablesy=iris[OBJECTIVE_VARIALBLE].valuesX=iris[USE_EXPLANATORY].values# Add random noise featuresrandom_state=np.random.RandomState(0)n_samples,n_features=X.shapeX=np.c_[X,random_state.randn(n_samples,10*n_features)]# Plot ROC curve in multiclass classificationX_train,X_test,y_train,y_test=train_test_split(X,y,shuffle=True,random_state=42)estimator=SVC(probability=True,random_state=42)classplot.plot_roc_curve_multiclass(estimator,X_train,y_train,X_test=X_test,y_test=y_test)plt.plot([0,1],[0,1],label='Chance',alpha=0.8,lw=2,color='red',linestyle='--')plt.legend(loc='lower right')classplot.roc_plotfromlightgbmimportLGBMClassifierimportseabornassnsimportmatplotlib.pyplotaspltfromseaborn_analyzerimportclassplot# Load datasetiris=sns.load_dataset("iris")OBJECTIVE_VARIALBLE='species'# Objective variableUSE_EXPLANATORY=['petal_width','petal_length','sepal_width','sepal_length']# Explantory variablesy=iris[OBJECTIVE_VARIALBLE].valuesX=iris[USE_EXPLANATORY].valuesfit_params={'verbose':0,'early_stopping_rounds':10,'eval_metric':'rmse','eval_set':[(X,y)]}# Plot ROC curve with cross validation in multiclass classificationestimator=LGBMClassifier(random_state=42,n_estimators=10000)fig,axes=plt.subplots(4,1,figsize=(6,24))classplot.roc_plot(estimator,X,y,ax=axes,cv=3,fit_params=fit_params)regplot.linear_plotfromseaborn_analyzerimportregplotimportseabornassnsiris=sns.load_dataset("iris")regplot.linear_plot(x='petal_length',y='sepal_length',data=iris)regplot.regression_pred_trueimportpandasaspdfromseaborn_analyzerimportregplotimportseabornassnsfromsklearn.linear_modelimportLinearRegressiondf_temp=pd.read_csv(f'./sample_data/temp_pressure.csv')regplot.regression_pred_true(LinearRegression(),x=['altitude','latitude'],y='temperature',data=df_temp)regplot.regression_plot_1dfromseaborn_analyzerimportregplotimportseabornassnsfromsklearn.svmimportSVRiris=sns.load_dataset("iris")regplot.regression_plot_1d(SVR(),x='petal_length',y='sepal_length',data=iris)regplot.regression_heat_plotimportpandasaspdfromsklearn.linear_modelimportLinearRegressionfromseaborn_analyzerimportregplotdf_temp=pd.read_csv(f'./sample_data/temp_pressure.csv')regplot.regression_heat_plot(LinearRegression(),x=['altitude','latitude'],y='temperature',data=df_temp)regplot.average_plotimportseabornassnsfromsklearn.svmimportSVRfromseaborn_analyzerimportregplotiris=sns.load_dataset("iris")svr=SVR()features=['petal_width','petal_length','sepal_width']X=iris[features].valuesy=iris['sepal_length'].valuesregplot.average_plot(svr,X,y,x_colnames=features,cv=3)ContactIf you have any questions or comments about seaborn-analyzer,
please feel free to contact me via
eMail:c60evaporator@gmail.comor Twitter:https://twitter.com/c60evaporatorThis project is hosted athttps://github.com/c60evaporator/seaborn-analyzer