Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102782953
create_submission.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 03:39
Size
910 B
Mime Type
text/x-python
Expires
Wed, Feb 26, 03:39 (1 d, 18 h)
Engine
blob
Format
Raw Data
Handle
24422947
Attached To
rTZUCT ML_Project1
create_submission.py
View Options
import
numpy
as
np
from
proj1_helpers
import
*
from
functions
import
*
import
datetime
def
predict_labels_modified
(
weights
,
data
):
"""Generates class predictions given weights, and a test data matrix"""
y_pred
=
np
.
dot
(
data
,
weights
)
y_pred
[
np
.
where
(
y_pred
<=
0.5
)]
=
-
1
y_pred
[
np
.
where
(
y_pred
>
0.5
)]
=
1
return
y_pred
def
normalize2
(
x
,
x_helper
):
minimum
=
min
(
np
.
min
(
x
),
np
.
min
(
x_helper
))
maximum
=
max
(
np
.
max
(
x
),
np
.
max
(
x_helper
))
range_x
=
maximum
-
minimum
x
-=
minimum
x
=
x
/
range_x
return
x
#y_tr, x_tr_noisy, ids_tr = load_csv_data("train.csv")
#y_te,x_te,ids_te = load_csv_data("test.csv")
x_tr1
=
real_mean
(
x_tr
)
x_te1
=
real_mean2
(
x_te
,
x_tr
)
#format_data2(xx,x_tr_noisy)
x_te_touse
=
normalize2
(
x_te1
,
x_tr1
)
tx_te
=
np
.
c_
[
np
.
ones
((
yy
.
shape
[
0
],
1
)),
x_te_touse
]
y_pred
=
predict_labels
(
w_final
,
tx_te
)
create_csv_submission
(
ids_te
,
y_pred
,
"new_submission"
)
Event Timeline
Log In to Comment