Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
myProjects
Project
Project
Details
Activity
Releases
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
Antoine Rollet
myProjects
Commits
f9b5b621
Commit
f9b5b621
authored
Nov 27, 2019
by
Antoine Rollet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
5d6c4435
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
Deep_Learning_Resultats_matchs.py
Deep_Learning_Resultats_matchs.py
+57
-0
No files found.
Deep_Learning_Resultats_matchs.py
0 → 100644
View file @
f9b5b621
import
numpy
as
np
from
keras.models
import
Sequential
from
keras.layers
import
Dense
from
keras.callbacks
import
EarlyStopping
##Create a new model
predictors
=
np
.
array
(
X_train
)
target
=
np
.
array
(
y_train
)
n
=
len
(
predictors
[
0
])
model
=
Sequential
()
#adding layers
model
.
add
(
Dense
(
180
,
activation
=
'relu'
,
input_shape
=
(
n
,)))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
model
.
add
(
Dense
(
180
,
activation
=
'relu'
))
#output layer
model
.
add
(
Dense
(
3
,
activation
=
"softmax"
))
#compiling
model
.
compile
(
optimizer
=
"adam"
,
loss
=
"categorical_crossentropy"
,
metrics
=
[
'accuracy'
])
#fiting
early_stopping_monitor
=
EarlyStopping
(
patience
=
3
)
model
.
fit
(
predictors
,
target
,
epochs
=
100
,
validation_split
=
0.3
,
callbacks
=
[
early_stopping_monitor
])
## Score
import
sklearn.metrics
y_predicted
=
model
.
predict
(
X_test
)
y_predicted_maxs
=
np
.
max
(
y_predicted
,
axis
=
1
)
y_predicted_bool
=
np
.
zeros
(
y_test
.
shape
)
y_predicted_bool
[:,
0
]
=
(
y_predicted_maxs
==
y_predicted
[:,
0
])
y_predicted_bool
[:,
1
]
=
(
y_predicted_maxs
==
y_predicted
[:,
1
])
y_predicted_bool
[:,
2
]
=
(
y_predicted_maxs
==
y_predicted
[:,
2
])
print
(
accuracy_score
(
y_test
,
y_predicted_bool
))
## Saving the model
model
.
save
(
"c:/Users/Antoine Rollet/Documents/Midas_indecis-2.1.h5"
)
##Loading a model
from
keras.models
import
load_model
my_model
=
load_model
(
"c:/Users/Antoine Rollet/Documents/Midas-1.1.h5"
)
\ No newline at end of file
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