Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
tutorials
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rebecca Merrett
tutorials
Commits
bb3b1ef2
Commit
bb3b1ef2
authored
Mar 07, 2019
by
Rebecca Merrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3ce911fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
linear_regression.py
Getting Started/linear_regression.py
+27
-0
No files found.
Getting Started/linear_regression.py
0 → 100644
View file @
bb3b1ef2
from
sklearn
import
linear_model
from
pandas
import
DataFrame
import
pandas
as
pd
import
pandas
import
matplotlib.pyplot
as
plt
input_data
=
pandas
.
read_table
(
"height.csv"
,
header
=
0
,
sep
=
","
,
names
=
(
"weight"
,
"height"
))
plt
.
scatter
(
input_data
[
"weight"
],
input_data
[
"height"
])
#plt.show()
predictor
=
pd
.
DataFrame
(
input_data
,
columns
=
[
"weight"
])
outcome
=
pd
.
DataFrame
(
input_data
,
columns
=
[
"height"
])
lm
=
linear_model
.
LinearRegression
()
lm_model
=
lm
.
fit
(
predictor
,
outcome
)
predicted_heights
=
lm
.
predict
(
predictor
)
r_squared
=
lm
.
score
(
predictor
,
outcome
)
print
(
predicted_heights
)
#print("Predicted:")
#print(predicted_heights[0:6])
#print("Actual:")
#print(outcome[0:6])
#print(r_squared)
Write
Preview
Markdown
is supported
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