Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
X-Lap
Commits
034268b7
Commit
034268b7
authored
May 15, 2017
by
Andreas Schmidt
Browse files
Add a sample notebook. Refactor regression out.
parent
0feb1cbc
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
034268b7
build/
dist/
xlap.egg-info/
.ipynb_checkpoints/
\ No newline at end of file
notebook.ipynb
0 → 100644
View file @
034268b7
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
xlap/analyse/__init__.py
View file @
034268b7
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
):
...
...
xlap/analyse/regress.py
0 → 100644
View file @
034268b7
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
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment