Section outline

    • If you want to perform linear regressions, Seaborn provides a dedicated function: regplot().

      Parameter name Explanations Required type Example
      data

      Table you are planning to use

      DataFrame, Series, dict, array, or list of arrays data=table
      x Variable of the table for the x-axis string corresponding to a variable of the table x="weight"
      y Variable of the table for the y-axis string corresponding to a variable of the table y=”height”
      ci Variable allowing to control the confidence interval Integer between 1 and 100 ci=99
      nboot Variable allowing to choose the number of bootstrap resampling done. Integer nboot=100
      seed Variable allowing reproductibility by choosing the seed of the bootstrap. Integer seed=42
      logistic Variable allowing to do a logistic regression Boolean logistic=True
      lowess Variable allowing to do a LOWESS regression Boolean lowess=True
      robust Variable allowing to do a robust regression. Higher computing cost Boolean robust=True
       

      regplot() can also display the confidence interval around the regression line, which is set to 95% by default.


       

      Here is an editable example of code:

      Importation code
      ← Running
      Cell 2
      ← Running
       
      Here, we are 70% confident that the true regression curve lies within the interval displayed on the graph. By default, n_boot is set to 1000. Increasing this value will necessarily increase the code's execution time, as additional resampling iterations will be performed. seed allows you to reproduce the same resampling results by using an integer as a seed, which is useful for reproducibility when writing a scientific paper or verifying that a method works correctly.
       

      The regression method can also be changed by selecting a different approach, for example by setting the lowess parameter to True:


      Cell 3
      ← Running

      The confidence interval is not displayed when using LOWESS.


      Another option is lmplot(), which is better suited for performing regressions across multiple plots:

       

      signature lmplot

      Parameter name Explanations Required type Example
      data

      Table you are planning to use

      DataFrame, Series, dict, array, or list of arrays data=tableau
      x Variable of the table for the x-axis string corresponding to a variable of the table x="weight"
      y Variable of the table for the y-axis string corresponding to a variable of the table y=”height”
      hue Variable of the table to distinguish with colors string corresponding to a variable of the table hue=”age”
      row Variable of the table that will be used to make different plots, in rows string corresponding to a variable of the table row=”category”
      col Variable of the table that will be used to make different plots, in columns string corresponding to a variable of the table col=”job”
      ci Variable allowing to control the confidence interval Integer between 1 and 100 ci=99
      nboot Variable allowing to choose the number of bootstrap resampling done. Integer nboot=100
      lowess Variable allowing to do a LOWESS regression Boolean lowess=True

      Here is an example of code:

      Cell 4
      ← Running

      Robust and logistic regressions are also available, just as with regplot(). The nboot and seed parameters are also available.