Misc code snippets
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

629 B

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.

    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