From ccd5b401f2ca8cc0202a7be39db3382d5b958b9f Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 17:15:15 +0700 Subject: [PATCH 1/9] Update C1_W1_Assignment.html --- .../W1/assignment/C1_W1_Assignment.html | 67 +++++++++++++------ 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index 023c6143..5c01faf1 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -11,9 +11,9 @@ // HINT: Remember that you are trying to build a classifier that // can predict from the data whether the diagnosis is malignant or benign. const trainingData = tf.data.csv(trainingUrl, { - - // YOUR CODE HERE - + columnConfigs: { + diagnosis: { isLabel: true } + } }); // Convert the training data into arrays in the space below. @@ -21,18 +21,23 @@ // Therefore, there is no need to convert string labels into // a one-hot encoded array of label values like we did in the // Iris dataset example. - const convertedTrainingData = // YOUR CODE HERE - + const convertedTrainingData = trainingData.map(({ xs, ys }) => { + return { + xs: Object.values(xs), + ys: Object.values(ys) + }; + }).batch(32); + const testingUrl = '/data/wdbc-test.csv'; - + // Take a look at the 'wdbc-test.csv' file and specify the column // that should be treated as the label in the space below.. // HINT: Remember that you are trying to build a classifier that // can predict from the data whether the diagnosis is malignant or benign. const testingData = tf.data.csv(testingUrl, { - - // YOUR CODE HERE - + columnConfigs: { + diagnosis: { isLabel: true } + } }); // Convert the testing data into arrays in the space below. @@ -40,13 +45,18 @@ // Therefore, there is no need to convert string labels into // a one-hot encoded array of label values like we did in the // Iris dataset example. - const convertedTestingData = // YOUR CODE HERE - + const convertedTestingData = testingData.map(({ xs, ys }) => { + return { + xs: Object.values(xs), + ys: Object.values(ys) + }; + }).batch(32); // Specify the number of features in the space below. // HINT: You can get the number of features from the number of columns // and the number of labels in the training data. - const numOfFeatures = // YOUR CODE HERE + const numOfFeatures = 30; + // In the space below create a neural network that predicts 1 if the diagnosis is malignant @@ -58,15 +68,34 @@ // using ReLu activation functions where applicable. For this dataset only a few // hidden layers should be enough to get a high accuracy. const model = tf.sequential(); - - // YOUR CODE HERE - - + // Input layer dan hidden layer pertama + model.add(tf.layers.dense({ + inputShape: [numOfFeatures], // Sesuaikan jumlah fitur + units: 16, + activation: 'relu' + })); + + // Hidden layer kedua + model.add(tf.layers.dense({ + units: 8, + activation: 'relu' + })); + + // Output layer + model.add(tf.layers.dense({ + units: 1, + activation: 'sigmoid' // Aktivasi sigmoid untuk output biner + })); + + // Compile the model using the binaryCrossentropy loss, // the rmsprop optimizer, and accuracy for your metrics. - model.compile(// YOUR CODE HERE); - + model.compile({ + loss: 'binaryCrossentropy', + optimizer: 'rmsprop', + metrics: ['accuracy'] + }); await model.fitDataset(convertedTrainingData, {epochs:100, @@ -82,4 +111,4 @@ - \ No newline at end of file + From 6f13d180c29f8d7401b5236ff2aeae898b07e9ab Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 17:52:27 +0700 Subject: [PATCH 2/9] Update C1_W1_Assignment.html From f00fdbbb396ad0d94d305abe3c22e2dc4208db2c Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 17:53:00 +0700 Subject: [PATCH 3/9] Update C1_W1_Assignment.html --- C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html | 1 + 1 file changed, 1 insertion(+) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index 5c01faf1..de471a7a 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -112,3 +112,4 @@ + From e47d24c468669bcb00075b303fe6b6f548416257 Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 17:53:21 +0700 Subject: [PATCH 4/9] Update C1_W1_Assignment.html --- C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index de471a7a..c5178a5d 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -111,5 +111,5 @@ - + From 5390a37cd854cb552e620ec6574cee84d70c34e8 Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 17:54:27 +0700 Subject: [PATCH 5/9] Update C1_W1_Assignment.html --- .../W1/assignment/C1_W1_Assignment.html | 88 ++++++------------- 1 file changed, 29 insertions(+), 59 deletions(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index c5178a5d..3532d507 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -1,26 +1,19 @@ + - - - From c3b68a4644760c2d1fe9eb28893ac0160880cd5d Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 18:01:45 +0700 Subject: [PATCH 6/9] Update C1_W1_Assignment.html --- .../W1/assignment/C1_W1_Assignment.html | 94 +++++++++++++------ 1 file changed, 66 insertions(+), 28 deletions(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index 3532d507..d458e65e 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -1,19 +1,32 @@ - + - + + + From db63336e0f10645d460ceb275e27927f42f4dd78 Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 18:02:37 +0700 Subject: [PATCH 7/9] Update C1_W1_Assignment.html --- C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index d458e65e..34f63764 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -12,9 +12,6 @@ // HINT: Remember that you are trying to build a classifier that // can predict from the data whether the diagnosis is malignant or benign. const trainingData = tf.data.csv(trainingUrl, { - - // YOUR CODE HERE - columnConfigs: { diagnosis: { isLabel: true } } From b85d1b4706060868479bdba56eccd1755dd4038d Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 18:12:25 +0700 Subject: [PATCH 8/9] Update C1_W1_Assignment.html --- .../W1/assignment/C1_W1_Assignment.html | 75 +++++++++---------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index 34f63764..8b56fddd 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -1,6 +1,5 @@ - - - From 943780b27b341adee4ad4deeb6971a4fe2e1f2f9 Mon Sep 17 00:00:00 2001 From: Mirandabangkitm197b4kx250 Date: Fri, 15 Nov 2024 18:16:44 +0700 Subject: [PATCH 9/9] Update C1_W1_Assignment.html --- .../W1/assignment/C1_W1_Assignment.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html index 8b56fddd..1e3a3aee 100755 --- a/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html +++ b/C1_Browser-based-TF-JS/W1/assignment/C1_W1_Assignment.html @@ -24,12 +24,12 @@ // Therefore, there is no need to convert string labels into // a one-hot encoded array of label values like we did in the // Iris dataset example. - const convertedTrainingData = trainingData.map(({ xs, ys }) => { // YOUR CODE HERE + const convertedTrainingData = trainingData.map(({ xs, ys }) => { return { xs: Object.values(xs), ys: Object.values(ys) }; - }).batch(32); + }).batch(32); // YOUR CODE HERE const testingUrl = '/data/wdbc-test.csv'; @@ -51,12 +51,12 @@ // Therefore, there is no need to convert string labels into // a one-hot encoded array of label values like we did in the // Iris dataset example. - const convertedTestingData = testingData.map(({ xs, ys }) => { // YOUR CODE HERE + const convertedTestingData = testingData.map(({ xs, ys }) => { return { xs: Object.values(xs), ys: Object.values(ys) }; - }).batch(32); + }).batch(32); // YOUR CODE HERE // Specify the number of features in the space below. @@ -98,7 +98,7 @@ loss: 'binaryCrossentropy', optimizer: 'rmsprop', metrics: ['accuracy'] - }); // YOUR CODE HERE); + }) // YOUR CODE HERE); await model.fitDataset(convertedTrainingData, {epochs:100,