Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4bf0c8b

Browse files
Prepare for publishing
1 parent 8ae780d commit 4bf0c8b

File tree

1 file changed

+43
-45
lines changed

1 file changed

+43
-45
lines changed

‎src/index.js‎

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,6 @@ const trainLogisticRegression = async (featureCount, trainDs, validDs) => {
188188
};
189189

190190
const trainComplexModel = async (featureCount, trainDs, validDs) => {
191-
// const arr = await ds.take(10).toArray();
192-
193-
// console.log(arr[0].xs.arraySync());
194-
195191
const model = tf.sequential();
196192
model.add(
197193
tf.layers.dense({
@@ -233,50 +229,37 @@ const trainComplexModel = async (featureCount, trainDs, validDs) => {
233229

234230
const run = async () => {
235231
const data = await prepareData();
236-
// console.log(data[0]);
237-
238-
// renderOutcomes(data);
239-
240-
// renderHistogram("insulin-cont", data, "Insulin", {
241-
// title: "Insulin levels",
242-
// xLabel: "Insulin 2-hour serum, mu U/ml"
243-
// });
244-
245-
// renderHistogram("glucose-cont", data, "Glucose", {
246-
// title: "Glucose concentration",
247-
// xLabel: "Plasma glucose concentration (2 hour after glucose tolerance test)"
248-
// });
249-
250-
// renderHistogram("age-cont", data, "Age", {
251-
// title: "Age",
252-
// xLabel: "age (years)"
253-
// });
254-
255-
// renderScatter("glucose-age-cont", data, ["Glucose", "Age"], {
256-
// title: "Glucose vs Age",
257-
// xLabel: "Glucose",
258-
// yLabel: "Age"
259-
// });
260-
261-
// renderScatter("skin-bmi-cont", data, ["SkinThickness", "BMI"], {
262-
// title: "Skin thickness vs BMI",
263-
// xLabel: "Skin thickness",
264-
// yLabel: "BMI"
265-
// });
266-
267-
// const [xTrain, xTest, yTrain, yTest] = toTensors(
268-
// data,
269-
// ["Glucose", "Age", "BMI"],
270-
// 0.1
271-
// );
272232

273-
// const features = ["Glucose"];
233+
renderOutcomes(data);
234+
235+
renderHistogram("insulin-cont", data, "Insulin", {
236+
title: "Insulin levels",
237+
xLabel: "Insulin 2-hour serum, mu U/ml"
238+
});
239+
240+
renderHistogram("glucose-cont", data, "Glucose", {
241+
title: "Glucose concentration",
242+
xLabel: "Plasma glucose concentration (2 hour after glucose tolerance test)"
243+
});
244+
245+
renderHistogram("age-cont", data, "Age", {
246+
title: "Age",
247+
xLabel: "age (years)"
248+
});
274249

275-
// const [trainDs, validDs] = createDataSets(data, features, 0.1, 16);
250+
renderScatter("glucose-age-cont", data, ["Glucose", "Age"], {
251+
title: "Glucose vs Age",
252+
xLabel: "Glucose",
253+
yLabel: "Age"
254+
});
276255

277-
// trainLogisticRegression(features.length, trainDs, validDs);
256+
renderScatter("skin-bmi-cont", data, ["SkinThickness", "BMI"], {
257+
title: "Skin thickness vs BMI",
258+
xLabel: "Skin thickness",
259+
yLabel: "BMI"
260+
});
278261

279-
const features = ["Glucose","Age","Insulin","BloodPressure"];
262+
const features = ["Glucose"];
280263

281264
const [trainDs, validDs, xTest, yTest] = createDataSets(
282265
data,
@@ -285,7 +268,22 @@ const run = async () => {
285268
16
286269
);
287270

288-
const model = await trainComplexModel(features.length, trainDs, validDs);
271+
const model = await trainLogisticRegression(
272+
features.length,
273+
trainDs,
274+
validDs
275+
);
276+
277+
// const features = ["Glucose", "Age", "Insulin", "BloodPressure"];
278+
279+
// const [trainDs, validDs, xTest, yTest] = createDataSets(
280+
// data,
281+
// features,
282+
// 0.1,
283+
// 16
284+
// );
285+
286+
// const model = await trainComplexModel(features.length, trainDs, validDs);
289287

290288
const preds = model.predict(xTest).argMax(-1);
291289
const labels = yTest.argMax(-1);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /