I've watched only a couple of your videos so far and have found them very helpful and succinct. I will be watching more in the future!
@DigitalSreeni5 жыл бұрын
Thanks Finn, the feedback definitely encourages me to create more videos.
@iwilld0it20 күн бұрын
Ok further analysis, you can do it with lmplot this way lmp = sns.lmplot(x='Manual', y='Auto_th_2', data=df, hue='Image_set') ax = lmp.axes[0, 0] line = ax.get_lines()[0] xdata = line.get_xdata() ydata = line.get_ydata() slope = (ydata[1] - ydata[0]) / (xdata[1] - xdata[0]) intercept = ydata[0] - slope * xdata[0] This example only looks at the first line, but get_lines() can be any number of lines, especially if you set the hue
@felip61804 жыл бұрын
Quite amazing tutorial and tool this seaborn! I've got curious about one thing. Does seaborn has a residual plot function? I mean, if I input the data, regress it, is there a possibility of it showing a plot of the residual values?
@DigitalSreeni4 жыл бұрын
Yes, I believe so. Check the documentation.... seaborn.pydata.org/generated/seaborn.residplot.html
@felip61804 жыл бұрын
@@DigitalSreeni Thank you very much!
@DigitalSreeni4 жыл бұрын
You’re welcome 😇
@iwilld0it20 күн бұрын
regplot appears to be the same regression line. Maybe this works? ax = sns.regplot(x='Manual', y='Auto_th_2', data=df) line = ax.get_lines()[0] xdata = line.get_xdata() ydata = line.get_ydata() slope = (ydata[1] - ydata[0]) / (xdata[1] - xdata[0]) intercept = ydata[0] - slope * xdata[0]
@chrisphayao Жыл бұрын
ChatGPT told me that seaborn doesn't provide the underlying equation for lmplot - there is an indirect way to find that out - but your way is easier ! import seaborn as sns import statsmodels.formula.api as smf # Generate a scatter plot with a regression line using lmplot sns.set(style="ticks") tips = sns.load_dataset("tips") lm = sns.lmplot(x="total_bill", y="tip", data=tips) # Extract the data from the lmplot figure x_data = lm.ax.collections[0].get_offsets()[:, 0] y_data = lm.ax.collections[0].get_offsets()[:, 1] # Fit a linear regression model using statsmodels model = smf.ols(formula='y ~ x', data=pd.DataFrame({'x': x_data, 'y': y_data})).fit() # Extract the coefficients from the model intercept = model.params['Intercept'] slope = model.params['x'] # Build the equation equation = f"y = {slope:.2f} * x + {intercept:.2f}" print(equation)