plots2 Flashcards

1
Q

seaborn distribution plot

A

sns.distplot(df[‘col’])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

3 scatter plots side by side horizontally sharing the y axis.

A

f, (ax1, ax2, ax3) = plt.subplots(1, 3, sharey=True, figsize =(15,3))

ax1. scatter(df[‘col1’],df[‘value’])
ax1. set_title(‘value and col1’)
ax2. scatter(df[‘col2’],df[‘value’])
ax2. set_title(‘value and col2’)
ax3. scatter(df[‘col3’],df[‘value’])
ax3. set_title(‘value and col3’)

plt.show()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

scatter plot after linear regression model is trained to compare the prediction and the target

A

y_hat = reg.predict(x_train)

plt. scatter(y_train, y_hat)
plt. xlabel(‘Targets (y_train)’,size=18)
plt. ylabel(‘Predictions (y_hat)’,size=18)
plt. xlim(min(y_train),max(y_train))
plt. ylim(min(y_train),max(y_train))
plt. show()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

residual plot after regression model is trained

A

sns. distplot(y_train - y_hat)

plt. title(“Residuals PDF”, size=18)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

plot logistic regression

A
reg_log = sm.Logit(y,x)
results_log = reg_log.fit()
def f(x,b0,b1):
    return np.array(np.exp(b0+x*b1) / (1 + np.exp(b0+x*b1)))
# Sorting the y and x, so we can plot the curve
f_sorted = np.sort(f(x1,results_log.params[0],results_log.params[1]))
x_sorted = np.sort(np.array(x1))
ax = plt.scatter(x1,y,color='C0')
plt.xlabel('X', fontsize = 20)
plt.ylabel('Target', fontsize = 20)
ax2 = plt.plot(x_sorted,f_sorted,color='red')
plt.figure(figsize=(20,20))
plt.show()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly