### Add a sample notebook. Refactor regression out.

parent 0feb1cbc
 build/ dist/ xlap.egg-info/ .ipynb_checkpoints/ \ No newline at end of file
notebook.ipynb 0 → 100644
This diff is collapsed.
 import math import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model plt.rcParams["figure.figsize"] = (16, 9) plt.rcParams.update({'figure.autolayout': True}) ... ... @@ -9,16 +8,6 @@ plt.rcParams.update({'figure.autolayout': True}) # TODO: Refactor. def regress(df, column): x = df.index.values.reshape(-1, 1) y = df[column].values model = linear_model.LinearRegression() model.fit(x, y) print("R-Score:", model.score(x, y)) plt.scatter(x, y) plt.grid() plt.plot(x, model.predict(x), color="red", linewidth=3) def trace(df, title, export=False): ... ...
 from sklearn import linear_model import matplotlib.pyplot as plt def linear(data_frame, column): """ Execute a simple linear regression on the given column for the passed data_frame. :param data_frame: :param column: :return: """ x = data_frame.index.values.reshape(-1, 1) y = data_frame[column].values model = linear_model.LinearRegression() model.fit(x, y) print("R-Score:", model.score(x, y)) plt.scatter(x, y) plt.grid() plt.plot(x, model.predict(x), color="red", linewidth=3) plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!