Changed around line 1
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener("DOMContentLoaded", function () {
- const ctx = document.getElementById('lossChart').getContext('2d');
+ const ctx = document.getElementById("lossChart").getContext("2d");
- rangeInputs.forEach(input => {
- input.addEventListener('input', function() {
+ rangeInputs.forEach((input) => {
+ input.addEventListener("input", function () {
- document.getElementById('trainButton').addEventListener('click', async function() {
- this.disabled = true;
- this.textContent = 'Training...';
-
- const params = {
- innerUnits: parseInt(document.getElementById('innerUnits').value),
- outerUnits: parseInt(document.getElementById('outerUnits').value),
- learningRate: parseFloat(document.getElementById('learningRate').value),
- epochs: parseInt(document.getElementById('epochs').value),
- modelType: document.getElementById('modelType').value
- };
-
- try {
- // Simulate training process
- const epochs = params.epochs;
- const lossData = [];
-
- if (lossChart) {
- lossChart.destroy();
- }
+ document
+ .getElementById("trainButton")
+ .addEventListener("click", async function () {
+ this.disabled = true;
+ this.textContent = "Training...";
+
+ const params = {
+ innerUnits: parseInt(document.getElementById("innerUnits").value),
+ outerUnits: parseInt(document.getElementById("outerUnits").value),
+ learningRate: parseFloat(document.getElementById("learningRate").value),
+ epochs: parseInt(document.getElementById("epochs").value),
+ modelType: document.getElementById("modelType").value,
+ };
- lossChart = new Chart(ctx, {
- type: 'line',
- data: {
- labels: [],
- datasets: [{
- label: 'Training Loss',
- data: [],
- borderColor: '#2a6be6',
- tension: 0.4
- }]
- },
- options: {
- responsive: true,
- scales: {
- y: {
- beginAtZero: true
- }
- }
+ try {
+ // Simulate training process
+ const epochs = params.epochs;
+ const lossData = [];
+
+ if (lossChart) {
+ lossChart.destroy();
- });
-
- for (let i = 0; i < epochs; i++) {
- // Simulate training iteration
- const loss = Math.exp(-i/epochs) + Math.random() * 0.1;
- lossData.push(loss);
-
- lossChart.data.labels.push(i + 1);
- lossChart.data.datasets[0].data.push(loss);
- lossChart.update('none');
-
- await new Promise(resolve => setTimeout(resolve, 100));
+
+ lossChart = new Chart(ctx, {
+ type: "line",
+ data: {
+ labels: [],
+ datasets: [
+ {
+ label: "Training Loss",
+ data: [],
+ borderColor: "#2a6be6",
+ tension: 0.4,
+ },
+ ],
+ },
+ options: {
+ responsive: true,
+ scales: {
+ y: {
+ beginAtZero: true,
+ },
+ },
+ },
+ });
+
+ for (let i = 0; i < epochs; i++) {
+ // Simulate training iteration
+ const loss = Math.exp(-i / epochs) + Math.random() * 0.1;
+ lossData.push(loss);
+
+ lossChart.data.labels.push(i + 1);
+ lossChart.data.datasets[0].data.push(loss);
+ lossChart.update("none");
+
+ await new Promise((resolve) => setTimeout(resolve, 100));
+ }
+
+ // Update metrics
+ document.getElementById("aucValue").textContent = (
+ 0.85 +
+ Math.random() * 0.1
+ ).toFixed(4);
+ document.getElementById("ksValue").textContent = (
+ 0.75 +
+ Math.random() * 0.1
+ ).toFixed(4);
+ document.getElementById("logLossValue").textContent = (
+ 0.3 +
+ Math.random() * 0.1
+ ).toFixed(4);
+ } catch (error) {
+ console.error("Training error:", error);
+ } finally {
+ this.disabled = false;
+ this.textContent = "Train Model";
+ }
+ });
+ });
+
+ // Simple Chart implementation (since we can't use external libraries)
+ class Chart {
+ constructor(ctx, config) {
+ this.ctx = ctx;
+ this.config = config;
+ this.data = config.data;
+ this.canvas = ctx.canvas;
+ this.canvas.width = this.canvas.parentNode.offsetWidth;
+ this.canvas.height = 400;
+ }
+
+ update() {
+ this.draw();
+ }
+
+ destroy() {
+ this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
+ }
+
+ draw() {
+ const ctx = this.ctx;
+ const data = this.data.datasets[0].data;
+ const labels = this.data.labels;
+
+ ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
+
+ if (data.length < 2) return;
+
+ const padding = 40;
+ const width = this.canvas.width - 2 * padding;
+ const height = this.canvas.height - 2 * padding;
+
+ const xStep = width / (data.length - 1);
+ const yMax = Math.max(...data) * 1.1;
+ const yScale = height / yMax;
+
+ // Draw axes
+ ctx.beginPath();
+ ctx.strokeStyle = "#666";
+ ctx.moveTo(padding, padding);
+ ctx.lineTo(padding, this.canvas.height - padding);
+ ctx.lineTo(this.canvas.width - padding, this.canvas.height - padding);
+ ctx.stroke();
+
+ // Draw line
+ ctx.beginPath();
+ ctx.strokeStyle = this.data.datasets[0].borderColor;
+ ctx.lineWidth = 2;
+
+ data.forEach((point, i) => {
+ const x = padding + i * xStep;
+ const y = this.canvas.height - padding - point * yScale;
+
+ if (i === 0) {
+ ctx.moveTo(x, y);
+ } else {
+ ctx.lineTo(x, y);
+ });
+
+ ctx.stroke();
+ }
+ }
+ document.addEventListener("DOMContentLoaded", function () {
+ // Initialize chart
+ const ctx = document.getElementById("lossChart").getContext("2d");
+ let lossChart = null;
- // Update metrics
- document.getElementById('aucValue').textContent = (0.85 + Math.random() * 0.1).toFixed(4);
- document.getElementById('ksValue').textContent = (0.75 + Math.random() * 0.1).toFixed(4);
- document.getElementById('logLossValue').textContent = (0.3 + Math.random() * 0.1).toFixed(4);
-
- } catch (error) {
- console.error('Training error:', error);
- } finally {
- this.disabled = false;
- this.textContent = 'Train Model';
- }
+ // Update value displays
+ const rangeInputs = document.querySelectorAll('input[type="range"]');
+ rangeInputs.forEach((input) => {
+ input.addEventListener("input", function () {
+ const display = this.nextElementSibling;
+ display.textContent = this.value;
+ });
+
+ // Train button click handler
+ document
+ .getElementById("trainButton")
+ .addEventListener("click", async function () {
+ this.disabled = true;
+ this.textContent = "Training...";
+
+ const params = {
+ innerUnits: parseInt(document.getElementById("innerUnits").value),
+ outerUnits: parseInt(document.getElementById("outerUnits").value),
+ learningRate: parseFloat(document.getElementById("learningRate").value),
+ epochs: parseInt(document.getElementById("epochs").value),
+ modelType: document.getElementById("modelType").value,
+ };
+
+ try {
+ // Simulate training process
+ const epochs = params.epochs;
+ const lossData = [];
+
+ if (lossChart) {
+ lossChart.destroy();
+ }
+
+ lossChart = new Chart(ctx, {
+ type: "line",
+ data: {
+ labels: [],
+ datasets: [
+ {
+ label: "Training Loss",
+ data: [],
+ borderColor: "#2a6be6",
+ tension: 0.4,
+ },
+ ],
+ },
+ options: {
+ responsive: true,
+ scales: {
+ y: {
+ beginAtZero: true,
+ },
+ },
+ },
+ });
+
+ for (let i = 0; i < epochs; i++) {
+ // Simulate training iteration
+ const loss = Math.exp(-i / epochs) + Math.random() * 0.1;
+ lossData.push(loss);
+
+ lossChart.data.labels.push(i + 1);
+ lossChart.data.datasets[0].data.push(loss);
+ lossChart.update("none");
+
+ await new Promise((resolve) => setTimeout(resolve, 100));
+ }
+
+ // Update metrics
+ document.getElementById("aucValue").textContent = (
+ 0.85 +
+ Math.random() * 0.1
+ ).toFixed(4);
+ document.getElementById("ksValue").textContent = (
+ 0.75 +
+ Math.random() * 0.1
+ ).toFixed(4);
+ document.getElementById("logLossValue").textContent = (
+ 0.3 +
+ Math.random() * 0.1
+ ).toFixed(4);
+ } catch (error) {
+ console.error("Training error:", error);
+ } finally {
+ this.disabled = false;
+ this.textContent = "Train Model";
+ }
+ });
Changed around line 274: class Chart {
-
+
-
+
-
+
- ctx.strokeStyle = '#666';
+ ctx.strokeStyle = "#666";
Changed around line 299: class Chart {
-
+
- const y = this.canvas.height - padding - (point * yScale);
-
+ const y = this.canvas.height - padding - point * yScale;
+
-
+