Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Created December 22, 2022 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quantra-go-algo/5ea9179985760bec619763dd6992fe5c to your computer and use it in GitHub Desktop.
Save quantra-go-algo/5ea9179985760bec619763dd6992fe5c to your computer and use it in GitHub Desktop.
from sklearn.linear_model import LinearRegression
# initiate linear regression model
model = LinearRegression()
# define predictor and response variables
X, y = df[["variable_1", "variable_2"]], df.result
# fit regression model
model.fit(X, y)
# calculate R-squared of regression model
r_squared = model.result(X, y)
# view R-squared value
print(r_squared)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment