Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import datasets, linear_model
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
# Create a data set for analysis
x, y = make_regression(n_samples=500, n_features = 1, noise=25, random_state=0)
# Split the data set into testing and training data
x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=0)
# Plot the data
sns.set_style("darkgrid")
sns.regplot(x_test, y_test, fit_reg=False)
# Remove ticks from the plot
plt.xticks([])
plt.yticks([])
plt.tight_layout()
plt.show()
'Original introns',
'Intron annotation support',
'Intron RNA support',
'transMap alignment goodness',
'Alignment goodness']
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(ncols=2, nrows=2)
for ax in [ax1, ax2, ax3, ax4]:
ax.set_xlim(0, 100)
ax.set_ylim(0, 100)
do_kdeplot(data['transMap original introns'], data['Original introns'], ax1, n_levels=25, bw=2)
sns.regplot(x=data['transMap original introns'], y=data['Original introns'], ax=ax1,
color='#A9B36F', scatter_kws={"s": 3, 'alpha': 0.7, 'rasterized': True}, fit_reg=False)
do_kdeplot(data['transMap intron annotation support'], data['Intron annotation support'], ax2,
n_levels=25, bw=2)
sns.regplot(x=data['transMap intron annotation support'], y=data['Intron annotation support'], ax=ax2,
color='#A9B36F', scatter_kws={"s": 3, 'alpha': 0.7, 'rasterized': True}, fit_reg=False)
do_kdeplot(data['transMap intron RNA support'], data['Intron RNA support'], ax3, n_levels=25, bw=2)
sns.regplot(x=data['transMap intron RNA support'], y=data['Intron RNA support'], ax=ax3,
color='#A9B36F', scatter_kws={"s": 3, 'alpha': 0.7, 'rasterized': True}, fit_reg=False)
do_kdeplot(data['transMap alignment goodness'], data['Alignment goodness'], ax4, n_levels=20, bw=1)
sns.regplot(x=data['transMap alignment goodness'], y=data['Alignment goodness'], ax=ax4,
color='#A9B36F', scatter_kws={"s": 3, 'alpha': 0.7, 'rasterized': True}, fit_reg=False)
fig.suptitle('AUGUSTUS metric improvements for {:,} transcripts in {}.\n'
'{:,} transMap transcripts were chosen.'.format(len(data), genome, unchanged))
for ax in [ax1, ax2, ax3, ax4]:
ax.set(adjustable='box-forced', aspect='equal')
fig.subplots_adjust(hspace=0.3)
def cumulative_yield(dfs, path, figformat, title, color):
cum_yield_gb = Plot(path=path + "CumulativeYieldPlot_Gigabases." + figformat,
title="Cumulative yield")
s = dfs.loc[:, "lengths"].cumsum().resample('1T').max() / 1e9
ax = sns.regplot(x=s.index.total_seconds() / 3600,
y=s,
x_ci=None,
fit_reg=False,
color=color,
scatter_kws={"s": 3})
ax.set(xlabel='Run time (hours)',
ylabel='Cumulative yield in gigabase',
title=title or cum_yield_gb.title)
cum_yield_gb.fig = ax.get_figure()
cum_yield_gb.save(format=figformat)
plt.close("all")
cum_yield_reads = Plot(path=path + "CumulativeYieldPlot_NumberOfReads." + figformat,
title="Cumulative yield")
s = dfs.loc[:, "lengths"].resample('10T').count().cumsum()
ax = sns.regplot(x=s.index.total_seconds() / 3600,
y_limit :: int or list with two ints
outliers :: Remove outliers using either 'zscore' or 'iqr'
'''
# HEADER STARTS >>>
palette = _header(palette, style, n_colors=1, dpi=dpi) # NOTE: y exception
# <<< HEADER ENDS
# # # # # # PLOT CODE STARTS # # # # # #
p, ax = plt.subplots(figsize=(params()['fig_width'],
params()['fig_height']))
sns.regplot(data=data,
x=x, y=y,
fit_reg=fit_reg,
scatter=draw_scatter,
color=palette[0],
marker=marker,
logistic=logres)
# # # # # # PLOT CODE ENDS # # # # # #
# SCALING AND LIMITS STARTS >>>
if x_scale != 'linear' or y_scale != 'linear':
_scaler(p, x_scale, y_scale)
if x_limit != None or y_limit != None:
_limiter(data=data, x=x, y=y, x_limit=x_limit, y_limit=y_limit)
# START OF TITLES >>>
def _plot_number(self, name):
data = self._train_features_df.dropna(subset=[name])
self._plot(sns.distplot(data[name]))
self._plot(sns.regplot(x=name, y=self._target_col,
data=data))
### AUROC PLOTS
n_clases = 3
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(n_classes):
Y_test = np.array(Y_test)
Y_pred = np.array(Y_pred)
fpr[i], tpr[i], _ = roc_curve(Y_test[:, i], Y_pred[:, i])
roc_auc[i] = auc(fpr[i], tpr[i])
import seaborn as sns
sns.regplot(x=fpr[0], y = tpr[0])
import seaborn as sns
sns.set('talk', 'whitegrid', 'dark', font_scale=0.70, font='Ricty',
rc={"lines.linewidth": 2, 'grid.linestyle': '--'})
def plot_roc_auroc_curves(tpr, fpr, roc_auc, title):
plt.figure()
plt.plot(fpr[1], tpr[1], color='green',
lw=lw, label='ROC Curve (AUC = %0.2f)' % roc_auc[1])
plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title(title)
data = data[[x, y]]
# Find extreme values to make axes equal.
min_limit = np.ceil(min(data.min()) - 2)
max_limit = np.floor(max(data.max()) + 2)
axes_limits = np.array([min_limit, max_limit])
if kind == 'joint':
grid = sns.jointplot(x=x, y=y, data=data,
kind='reg', joint_kws={'ci': None}, stat_func=None,
xlim=axes_limits, ylim=axes_limits, color=color)
ax = grid.ax_joint
grid.fig.subplots_adjust(top=0.95)
grid.fig.suptitle(title)
elif kind == 'reg':
ax = sns.regplot(x=x, y=y, data=data, color=color, ax=ax)
ax.set_title(title)
# Add diagonal line.
ax.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7)
# Add shaded area for 0.5-1 pKa error.
palette = sns.color_palette('BuGn_r')
ax.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2])
ax.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3])
def subplot(self, axes, subfigure):
xdata, ydata, xlabel, ylabel, title, transform = subfigure
color = axes._get_lines.color_cycle #pylint:disable=W0212
xdata, ydata = self.prepareData(xdata, ydata, transform)
k = next(color)
scatter_kws = {'color':k,
'alpha':0.5}
sns.regplot(xdata, ydata, ax=axes, scatter_kws=scatter_kws)
self.formatAxes(axes, xdata, ydata)
axes.set_xlabel(xlabel)
axes.set_ylabel(ylabel)
axes.set_title(title)
legend = axes.legend(loc=2)
legend.get_frame().set_alpha(0.5)
high = wine_set[wine_set['quality'] > 7]
print('association between wine`s density and residual sugar for wines \nof `low` quality')
print(scipy.stats.pearsonr(low['density'], low["residual_sugar"]))
print('\nof `medium` quality')
print(scipy.stats.pearsonr(medium['density'], medium["residual_sugar"]))
print('\nof `high` quality')
print(scipy.stats.pearsonr(high['density'], high["residual_sugar"]))
scat0 = seaborn.regplot(x="density", y="residual_sugar", fit_reg=True, data=low)
plt.xlabel("Density of wine")
plt.ylabel("Residual sugar in wine, gram")
plt.title("Association between wine's density and residual sugar for wines of `low` quality")
plt.show()
scat0 = seaborn.regplot(x="density", y="residual_sugar", fit_reg=True, data=medium)
plt.xlabel("Density of wine")
plt.ylabel("Residual sugar in wine, gram")
plt.title("Association between wine's density and residual sugar for wines of `medium` quality")
plt.show()
scat0 = seaborn.regplot(x="density", y="residual_sugar", fit_reg=True, data=high)
plt.xlabel("Density of wine")
plt.ylabel("Residual sugar in wine, gram")
plt.title("Association between wine's density and residual sugar for wines of `high` quality")
plt.show()
def scatter_plot(data, col1, col2, file_name=None):
sns.regplot(x=col1, y=col2, data=data, fit_reg=False)
sns.despine(left=True)