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.
 
 
Holger Frey 9bac352e05 renamed some internal variables 2 years ago
.gitignore Initial commit 2 years ago
LICENSE Initial commit 2 years ago
Makefile setup of infrastructure 2 years ago
README.md added `to_dict()` method to the `Regression` result class 2 years ago
linear_regression.py renamed some internal variables 2 years ago
pytest.ini added test for the `to_dict()` method 2 years ago
requirements.txt setup of infrastructure 2 years ago
split_uniques.py added test for the `to_dict()` method 2 years ago

README.md

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