Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Regplot | Regression Models
Deep Dive into the seaborn Visualization

book
Regplot

The regplot is used to plot data and a linear regression model fit. There are a number of mutually exclusive options for estimating the regression model.

carousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-imgcarousel-img
Oppgave

Swipe to start coding

  1. Set the 'darkgrid' style with the 'tan' figure facecolor and 'cornsilk' axes .facecolor.
  2. Create a regplot using the seaborn library:
  • Set the x parameter equals the 'total_bill';
  • Set the y parameter equals the 'tip';
  • Set the marker parameter equals the '+';
  • Set the 'green' color;
  • Disable the fit_reg parameter;
  • Set the data;
  • Display the plot.

Løsning

# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/tips.csv')

# Set the 'darkgrid' style with the 'tan' figure facecolor and 'cornsilk' axes facecolor
sns.set_style('darkgrid',
{'figure.facecolor' : 'tan',
'axes.facecolor' : 'cornsilk'})

# Create a regplot
sns.regplot(# Set the x
x = 'total_bill',
# Set the y
y = 'tip',
# Set the marker
marker = '+',
# Set the color
color = 'green',
# Disable the fit_reg
fit_reg = False,
# Set the data
data = df)

# Display the data
plt.show()

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 6. Kapittel 1
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/tips.csv')

# Set the 'darkgrid' style with the 'tan' figure facecolor and 'cornsilk' axes facecolor
sns.set_style('___',
{'figure.___' : '___',
'___' : '___'})

# Create a regplot
___(# Set the x
___,
# Set the y
y = '___',
# Set the marker
___ = '+',
# Set the color
___,
# Disable the fit_reg
fit_reg = ___,
# Set the data
___)

# Display the data
___

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

some-alt