FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PythonForDataScience/makeSubmission.py at master · techinAI/PythonForDataScience · GitHub
techinAI
PythonForDataScience
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
PythonForDataScience
/
makeSubmission.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (18 loc) · 771 Bytes
Breadcrumbs
PythonForDataScience
/
makeSubmission.py
Copy path
File metadata and controls
25 lines (18 loc) · 771 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import
pandas
as
pd
from
sklearn
.
ensemble
import
RandomForestClassifier
def
main
():
# create the training & test sets
dataset
=
pd
.
read_csv
(
'Data/train.csv'
)
target
=
dataset
.
Activity
.
values
train
=
dataset
.
drop
(
'Activity'
,
axis
=
1
).
values
test
=
pd
.
read_csv
(
'Data/test.csv'
).
values
# create and train the random forest
# n_jobs set to -1 will use the number of cores present on your system.
rf
=
RandomForestClassifier
(
n_estimators
=
100
,
n_jobs
=
-
1
)
rf
.
fit
(
train
,
target
)
predicted_probs
=
[
x
[
1
]
for
x
in
rf
.
predict_proba
(
test
)]
predicted_probs
=
pd
.
Series
(
predicted_probs
)
predicted_probs
.
to_csv
(
'Data/submission.csv'
,
index
=
False
,
float_format
=
"%f"
)
if
__name__
==
"__main__"
:
main
()
Back
|
FazBrowse Home
|
New Git URL