-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodespace.html
50 lines (43 loc) · 1.88 KB
/
Codespace.html
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<title>Codespace</title>
</head>
<body>
<script type="text/javascript" src="//cdn.datacamp.com/dcl/latest/dcl-react.js.gz"></script>
<div class="exercise">
<div data-datacamp-exercise data-lang="python" data-lang-version="3.6" data-packages="sklearn, dash-bootstrap-components, tensorflow, skorch, omnixai, XAISuite" data-height="auto">
<code data-type="pre-exercise-code"></code>
<code data-type="sample-code">
import numpy as np
from sklearn.datasets import make_classification
from tensorflow import keras
from xaisuite import*
def get_model(hidden_layer_dim, meta):
# note that meta is a special argument that will be
# handed a dict containing input metadata
n_features_in_ = meta["n_features_in_"]
X_shape_ = meta["X_shape_"]
n_classes_ = meta["n_classes_"]
model = keras.models.Sequential()
model.add(keras.layers.Dense(n_features_in_, input_shape=X_shape_[1:]))
model.add(keras.layers.Activation("relu"))
model.add(keras.layers.Dense(hidden_layer_dim))
model.add(keras.layers.Activation("relu"))
model.add(keras.layers.Dense(n_classes_))
model.add(keras.layers.Activation("softmax"))
return model
train_and_explainModel("KerasClassifier"
, generate_data("classification", "target", n_samples = 1000, n_features = 20, n_informative=10, random_state=0)
, build_fn=get_model
, loss="sparse_categorical_crossentropy"
, hidden_layer_dim=100
, epochs = 51
)
</code>
<code data-type="solution"></code>
<code data-type="sct"></code>
</div>
</div>
</body>
</html>