Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
ML725
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SHREYANSH JAIN
ML725
Commits
1332f328
Commit
1332f328
authored
Sep 12, 2019
by
SHREYANSH JAIN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final logcosh leaderboard
parent
1b4341db
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
40116 additions
and
8012 deletions
+40116
-8012
Assignment1/data/plot1/logcosh.log
Assignment1/data/plot1/logcosh.log
+8000
-0
Assignment1/data/plot1/mae.log
Assignment1/data/plot1/mae.log
+8000
-0
Assignment1/data/plot1/mse.log
Assignment1/data/plot1/mse.log
+8000
-0
Assignment1/data/plot1/plot.py
Assignment1/data/plot1/plot.py
+53
-0
Assignment1/data/plot1/readme.txt
Assignment1/data/plot1/readme.txt
+3
-0
Assignment1/data/plot1/rmse.log
Assignment1/data/plot1/rmse.log
+8000
-0
Assignment1/demo.py
Assignment1/demo.py
+39
-5
Assignment1/error.log
Assignment1/error.log
+8000
-8000
Assignment1/main.py
Assignment1/main.py
+21
-7
No files found.
Assignment1/data/plot1/logcosh.log
0 → 100644
View file @
1332f328
This diff is collapsed.
Click to expand it.
Assignment1/data/plot1/mae.log
0 → 100644
View file @
1332f328
This diff is collapsed.
Click to expand it.
Assignment1/data/plot1/mse.log
0 → 100644
View file @
1332f328
This diff is collapsed.
Click to expand it.
Assignment1/data/plot1/plot.py
0 → 100644
View file @
1332f328
import
matplotlib.pyplot
as
plt
import
csv
x
=
[]
y
=
[]
i
=
1
with
open
(
'logcosh.log'
,
'r'
)
as
csvfile
:
for
row
in
csvfile
:
x
.
append
(
i
)
i
+=
1
y
.
append
(
float
(
row
[:
-
1
]))
plt
.
plot
(
x
,
y
,
label
=
'LOGCOSH'
)
plt
.
xlabel
(
'epoch'
)
plt
.
ylabel
(
'Error'
)
x
=
[]
y
=
[]
i
=
1
with
open
(
'mae.log'
,
'r'
)
as
csvfile
:
for
row
in
csvfile
:
x
.
append
(
i
)
i
+=
1
y
.
append
(
float
(
row
[:
-
1
]))
plt
.
plot
(
x
,
y
,
label
=
'MAE'
)
x
=
[]
y
=
[]
i
=
1
with
open
(
'rmse.log'
,
'r'
)
as
csvfile
:
for
row
in
csvfile
:
x
.
append
(
i
)
i
+=
1
y
.
append
(
float
(
row
[:
-
1
]))
plt
.
plot
(
x
,
y
,
label
=
'RMSE'
)
plt
.
plot
(
x
,
y
,
label
=
''
)
plt
.
legend
()
plt
.
show
()
\ No newline at end of file
Assignment1/data/plot1/readme.txt
0 → 100644
View file @
1332f328
python3 main.py --train_file train.csv --test_file test.csv --epoch 8000 --lr 0.4 --loss rmse
python3 main.py --train_file train.csv --test_file test.csv --epoch 8000 --lr 0.3 --loss mse
python3 main.py --train_file train.csv --test_file test.csv --epoch 8000 --lr 0.4 --loss logcosh
Assignment1/data/plot1/rmse.log
0 → 100644
View file @
1332f328
This diff is collapsed.
Click to expand it.
Assignment1/demo.py
View file @
1332f328
...
...
@@ -5,15 +5,49 @@ x = []
y
=
[]
i
=
1
with
open
(
'
error
.log'
,
'r'
)
as
csvfile
:
with
open
(
'
logcosh
.log'
,
'r'
)
as
csvfile
:
for
row
in
csvfile
:
x
.
append
(
i
)
i
+=
1
y
.
append
(
float
(
row
[:
-
1
]))
plt
.
plot
(
x
,
y
,
label
=
'Loaded from file!'
)
plt
.
xlabel
(
'x'
)
plt
.
ylabel
(
'y'
)
plt
.
title
(
'Interesting Graph
\n
Check it out'
)
plt
.
plot
(
x
,
y
,
label
=
'LOGCOSH'
)
plt
.
xlabel
(
'epoch'
)
plt
.
ylabel
(
'Error'
)
x
=
[]
y
=
[]
i
=
1
with
open
(
'mae.log'
,
'r'
)
as
csvfile
:
for
row
in
csvfile
:
x
.
append
(
i
)
i
+=
1
y
.
append
(
float
(
row
[:
-
1
]))
plt
.
plot
(
x
,
y
,
label
=
'MAE'
)
x
=
[]
y
=
[]
i
=
1
with
open
(
'rmse.log'
,
'r'
)
as
csvfile
:
for
row
in
csvfile
:
x
.
append
(
i
)
i
+=
1
y
.
append
(
float
(
row
[:
-
1
]))
plt
.
plot
(
x
,
y
,
label
=
'RMSE'
)
plt
.
plot
(
x
,
y
,
label
=
''
)
plt
.
legend
()
plt
.
show
()
\ No newline at end of file
Assignment1/error.log
View file @
1332f328
This diff is collapsed.
Click to expand it.
Assignment1/main.py
View file @
1332f328
import
numpy
as
np
import
argparse
import
csv
import
warnings
# import matplotlib.pyplot as plt
'''
You are only required to fill the following functions
...
...
@@ -24,7 +25,7 @@ def mean_squared_loss(xdata, ydata, weights):
guess
=
np
.
dot
(
xdata
,
weights
)
samples
=
np
.
shape
(
guess
)[
0
]
err
=
(
0.5
/
samples
)
*
np
.
sum
(
np
.
square
(
ydata
-
guess
))
err
=
(
1
/
samples
)
*
np
.
sum
(
np
.
square
(
ydata
-
guess
))
return
err
raise
NotImplementedError
...
...
@@ -32,7 +33,7 @@ def mean_squared_gradient(xdata, ydata, weights):
samples
=
np
.
shape
(
xdata
)[
0
]
guess
=
np
.
dot
(
xdata
,
weights
)
gradient
=
(
1
/
samples
)
*
np
.
dot
(
xdata
.
T
,(
guess
-
ydata
))
gradient
=
(
2
/
samples
)
*
np
.
dot
(
xdata
.
T
,(
guess
-
ydata
))
return
gradient
raise
NotImplementedError
...
...
@@ -60,7 +61,11 @@ def mean_log_cosh_loss(xdata, ydata, weights):
guess
=
np
.
dot
(
xdata
,
weights
)
samples
=
np
.
shape
(
guess
)[
0
]
err
=
(
1
/
samples
)
*
np
.
sum
(
np
.
square
(
ydata
-
guess
))
warnings
.
filterwarnings
(
"error"
)
try
:
err
=
np
.
sum
(
np
.
log
(
np
.
cosh
(
guess
-
ydata
)))
/
samples
except
Exception
as
e
:
err
=
np
.
sum
(
np
.
absolute
(
guess
-
ydata
)
+
np
.
log
(
2
))
/
samples
return
err
raise
NotImplementedError
...
...
@@ -68,7 +73,7 @@ def mean_log_cosh_gradient(xdata, ydata, weights):
guess
=
np
.
dot
(
xdata
,
weights
)
samples
=
np
.
shape
(
guess
)[
0
]
gradient
=
np
.
dot
(
xdata
.
T
,
np
.
tanh
(
guess
-
ydata
))
gradient
=
np
.
dot
(
xdata
.
T
,
np
.
tanh
(
guess
-
ydata
))
/
samples
return
gradient
raise
NotImplementedError
...
...
@@ -84,7 +89,8 @@ def root_mean_squared_loss(xdata, ydata, weights):
def
root_mean_squared_gradient
(
xdata
,
ydata
,
weights
):
samples
=
np
.
shape
(
xdata
)[
0
]
gradient
=
-
weights
.
T
/
np
.
sqrt
(
samples
)
guess
=
np
.
dot
(
xdata
,
weights
)
gradient
=
mean_squared_gradient
(
xdata
,
ydata
,
weights
)
/
(
2
*
root_mean_squared_loss
(
xdata
,
ydata
,
weights
))
return
gradient
raise
NotImplementedError
...
...
@@ -277,7 +283,15 @@ def main():
output
=
[(
i
,
np
.
absolute
(
ytest
[
i
]))
for
i
in
range
(
len
(
ytest
))]
np
.
savetxt
(
"output.csv"
,
output
,
delimiter
=
','
,
fmt
=
"
%
d"
,
header
=
"instance (id),count"
,
comments
=
''
)
np
.
savetxt
(
"error.log"
,
errlog
,
delimiter
=
'
\n
'
,
fmt
=
"
%
f"
)
x
,
y
,
z
=
np
.
array
([[
1
,
0
,
2
,
-
3
],
[
1
,
-
1
,
0
,
-
3
],
[
-
2
,
-
5
,
1
,
-
3
],
[
0
,
-
5
,
3
,
-
3
],
[
0
,
-
4
,
3
,
-
2
]]),
np
.
array
(
[
-
2
,
1
,
1
,
2
,
0
]),
np
.
array
(
[
1
,
0
,
-
2
,
-
1
])
print
(
mean_absolute_loss
(
x
,
y
,
z
))
print
(
mean_absolute_gradient
(
x
,
y
,
z
))
print
(
mean_squared_loss
(
x
,
y
,
z
))
print
(
mean_squared_gradient
(
x
,
y
,
z
))
print
(
root_mean_squared_loss
(
x
,
y
,
z
))
print
(
root_mean_squared_gradient
(
x
,
y
,
z
))
print
(
mean_log_cosh_loss
(
x
,
y
,
z
))
print
(
mean_log_cosh_gradient
(
x
,
y
,
z
))
if
__name__
==
'__main__'
:
...
...
@@ -291,4 +305,4 @@ if __name__ == '__main__':
args
=
parser
.
parse_args
()
main
()
\ No newline at end of file
main
()
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