Commit 034268b7 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Add a sample notebook. Refactor regression out.

parent 0feb1cbc
build/
dist/
xlap.egg-info/
.ipynb_checkpoints/
\ No newline at end of file
%% Cell type:code id: tags:
``` python
from xlap.parse import evaluate, parse_config
import xlap.analyse.jitter as jitter
from xlap.analyse.regress import linear as linear_regression
```
%% Cell type:code id: tags:
``` python
config = parse_config()
data_files = config["data_files"]
original = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)
df = jitter.prep(original, config=config)
```
%% Cell type:code id: tags:
``` python
jitter.trace_jitter(df)
```
%% Output
4018 / 4095 are no outliers.
/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:1742: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.
warnings.warn("This figure includes Axes that are not "
%% Cell type:code id: tags:
``` python
linear_regression(original,"Feedback_D")
```
%% Output
R-Score: 0.0444517602497
%% Cell type:code id: tags:
``` python
```
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()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment