# snippets Misc code snippets I sometimes need and always have to look up how it works... ## linear_regression.py Calculate the linear regression on two columns of a data frame. The resulting object has the function `predict()` to calculate x or y values for a given counterpart. ```python from linear_regression import linear_regression df = pd.DataFrame({"temperature":[...], "signal":[...]}) regression = linear_regression(df, x="temperature", y="signal") repr(regression) == "Regression(intercept=1, coefficient=3, score=0.9998)" regression.predict(x=3) == 10 regression.predict(y=7) == 2 ```