### Install OCTIS from Source Source: https://github.com/mind-lab/octis/blob/master/docs/installation.rst Installs OCTIS after obtaining the source code, either by cloning the repository or downloading a tarball. This command should be run from the root directory of the source code. ```shell python setup.py install ``` -------------------------------- ### Install OCTIS Stable Release using pip Source: https://github.com/mind-lab/octis/blob/master/docs/installation.rst Installs the most recent stable release of OCTIS. This is the recommended installation method. Requires pip to be installed. ```shell pip install octis ``` -------------------------------- ### Clone OCTIS GitHub Repository Source: https://github.com/mind-lab/octis/blob/master/docs/installation.rst Clones the public GitHub repository for OCTIS to obtain the source code. This allows for installation directly from the development version. ```shell git clone git://github.com/mind-lab/octis ``` -------------------------------- ### Download OCTIS Source Tarball Source: https://github.com/mind-lab/octis/blob/master/docs/installation.rst Downloads the OCTIS source code as a tarball from the master branch on GitHub. This is an alternative method to obtain the source for installation. ```shell curl -OJL https://github.com/mind-lab/octis/tarball/master ``` -------------------------------- ### Setup OCTIS in Virtual Environment Source: https://github.com/mind-lab/octis/blob/master/CONTRIBUTING.rst These commands set up your local OCTIS fork within a virtual environment using virtualenvwrapper. It installs the project in development mode. ```shell mkvirtualenv OCTIS cd OCTIS/ python setup.py develop ``` -------------------------------- ### Create Datasets for Training - Python Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb This Python code snippet demonstrates the setup for data loading pipelines for model training. It calls a `create_datasets` function to generate training, testing, and validation data loaders, configured with a specified batch size. This is a prerequisite for the model training process. ```python batch_size = 256 n_epochs = 100 train_loader, test_loader, valid_loader = create_datasets(batch_size) ``` -------------------------------- ### Install OCTIS Library Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_LDA_training_only.ipynb Installs the OCTIS library using pip. This is a prerequisite for using OCTIS functionalities. No specific inputs or outputs are expected beyond the successful installation of the package. ```python !pip install octis ``` -------------------------------- ### Install Dependencies with Pip Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/README.md Installs the required Python packages for the project using pip. This command reads package names from the requirements.txt file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Import OCTIS Libraries for Topic Modeling Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_Optimizing_CTM.ipynb Imports necessary classes from the OCTIS library and scikit-optimize for topic modeling tasks. These include model definitions, dataset handling, optimization tools, and coherence metrics. ```python from octis.models.CTM import CTM from octis.dataset.dataset import Dataset from octis.optimization.optimizer import Optimizer from skopt.space.space import Real, Categorical, Integer from octis.evaluation_metrics.coherence_metrics import Coherence ``` -------------------------------- ### Launch Hyperparameter Optimization in Python Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_Optimizing_CTM.ipynb Launches the hyperparameter optimization process using the OCTIS Optimizer. It takes the model, dataset, metric, defined search space, and other parameters like optimization runs and model runs. Results are saved to a specified path. ```python optimizer=Optimizer() optimization_result = optimizer.optimize( model, dataset, npmi, search_space, number_of_call=optimization_runs, model_runs=model_runs, save_models=True, extra_metrics=None, # to keep track of other metrics save_path='results/test_ctm//') ``` -------------------------------- ### Initialize and Run Model Optimization Source: https://github.com/mind-lab/octis/blob/master/octis/optimization/README.md This code snippet demonstrates how to initialize the Optimizer class from the optimization module and then start the optimization process. It requires the model, dataset, metric, and the search space for hyperparameters. Dependencies include `Optimizer` from `optimization.optimizer` and `Real` from `skopt.space.space`. ```python from optimization.optimizer import Optimizer from skopt.space.space import Real search_space = { "alpha": Real(low=0.001, high=5.0), "eta": Real(low=0.001, high=5.0) } # Initialize an optimizer object and start the optimization. optimizer = Optimizer() result = optimizer.optimize(model, dataset, metric, search_space) ``` -------------------------------- ### Load Dataset in OCTIS Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_Optimizing_CTM.ipynb Loads a pre-processed dataset named 'M10' using the Dataset class from OCTIS. This dataset is required for training and evaluating topic models. ```python dataset = Dataset() dataset.fetch_dataset("M10") ``` -------------------------------- ### Initialize OCTIS Optimizer Source: https://github.com/mind-lab/octis/blob/master/docs/optimization.rst Initializes the main Optimizer class for hyper-parameter optimization in OCTIS. This is the starting point for any optimization task. ```python from octis.optimization.optimizer import Optimizer optimizer = Optimizer() ``` -------------------------------- ### Configure Contextualized Topic Model (CTM) Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_Optimizing_CTM.ipynb Initializes a Contextualized Topic Model (CTM) with specified hyperparameters. This configuration sets the number of topics, training epochs, inference type (e.g., 'zeroshot'), and the BERT model for contextual embeddings. ```python model = CTM(num_topics=10, num_epochs=30, inference_type='zeroshot', bert_model="bert-base-nli-mean-tokens") ``` -------------------------------- ### Import Libraries for PyTorch and Data Handling Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb Imports essential libraries including PyTorch for neural network operations, NumPy for numerical computations, and Matplotlib for plotting. These are foundational for building and visualizing the model. ```python # import libraries import torch import numpy as np import matplotlib.pyplot as plt ``` -------------------------------- ### Run OCTIS Local Dashboard Server Source: https://github.com/mind-lab/octis/blob/master/docs/dashboard.rst This command starts the local dashboard server for the OCTIS project. It allows users to specify a port for hosting the server and a file path for dashboard state information. The dashboard provides a graphical interface for experiment management. ```bash python OCTIS/dashboard/server.py --port [port number] --dashboardState [path to dashboard state file] ``` -------------------------------- ### Default Hyperparameters for Custom Topic Models Source: https://github.com/mind-lab/octis/blob/master/README.rst Shows an example of defining a dictionary for default hyperparameters when implementing a custom topic model in OCTIS. This includes parameters like corpus, number of topics, and callbacks. ```python hyperparameters = { 'corpus': None, 'num_topics': 100, 'id2word': None, 'alpha': 'symmetric', 'eta': None, 'callbacks': None } ``` -------------------------------- ### Experiment UI Update and Button Handling (JavaScript) Source: https://github.com/mind-lab/octis/blob/master/octis/dashboard/templates/ManageExperiments.html This snippet handles the dynamic creation and appending of experiment details and control buttons to the UI. It manages the display of progress, dataset information, and optimization metrics. It also includes logic for conditionally displaying a 'Start Experiment' button. ```javascript buttonsDiv.appendChild(deleteButton) if (i == 0 && running == null) { startButton = document.createElement("button") startButton.id = "startButton" startButton.classList.add("btn") startButton.classList.add("btn-success") startButton.innerHTML = "Start Experiment" startButton.addEventListener("click", start) buttonsDiv.appendChild(startButton) } div.appendChild(buttonsDiv) child.appendChild(div) element.appendChild(child) ``` -------------------------------- ### Specify Loss Function and Optimizer in PyTorch Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb Sets up the loss function and optimizer for the neural network. CrossEntropyLoss is used for classification tasks, and Adam is chosen as the optimizer to update model weights. These are standard components for training PyTorch models. ```python # specify loss function criterion = nn.CrossEntropyLoss() # specify optimizer optimizer = torch.optim.Adam(model.parameters()) ``` -------------------------------- ### Launch Hyper-parameter Optimization in OCTIS Source: https://github.com/mind-lab/octis/blob/master/docs/optimization.rst Launches the hyper-parameter optimization process using the configured model, dataset, metric, and search space. It allows specifying the number of iterations, random starts, model runs, and optimization strategy parameters like surrogate model and acquisition function. ```python optimization_result=optimizer.optimize(model, dataset, npmi, search_space, number_of_call=10, n_random_starts=3, model_runs=3, save_name="result", surrogate_model="RF", acq_func="LCB" ) ``` -------------------------------- ### Load and Batch MNIST Data with PyTorch Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb This function loads the MNIST dataset, applies transformations, and creates data loaders for training, validation, and testing sets. It splits the training data to create a validation set and uses samplers to ensure random batches. Dependencies include torchvision and torch.utils.data. ```python from torchvision import datasets import torchvision.transforms as transforms from torch.utils.data.sampler import SubsetRandomSampler def create_datasets(batch_size): # percentage of training set to use as validation valid_size = 0.2 # convert data to torch.FloatTensor transform = transforms.ToTensor() # choose the training and test datasets train_data = datasets.MNIST(root='data', train=True, download=True, transform=transform) test_data = datasets.MNIST(root='data', train=False, download=True, transform=transform) # obtain training indices that will be used for validation num_train = len(train_data) indices = list(range(num_train)) np.random.shuffle(indices) split = int(np.floor(valid_size * num_train)) train_idx, valid_idx = indices[split:], indices[:split] # define samplers for obtaining training and validation batches train_sampler = SubsetRandomSampler(train_idx) valid_sampler = SubsetRandomSampler(valid_idx) # load training data in batches train_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, sampler=train_sampler, num_workers=0) # load validation data in batches valid_loader = torch.utils.data.DataLoader(train_data, batch_size=batch_size, sampler=valid_sampler, num_workers=0) # load test data in batches test_loader = torch.utils.data.DataLoader(test_data, batch_size=batch_size, num_workers=0) return train_loader, test_loader, valid_loader ``` -------------------------------- ### Save Optimization Results to CSV in Python Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_Optimizing_CTM.ipynb Saves the main results of the hyperparameter optimization to a CSV file. This allows for easy analysis and retrieval of the best performing hyperparameter configurations and their corresponding metrics. ```python optimization_result.save_to_csv("results_ctm.csv") ``` -------------------------------- ### Create Search Space for Hyper-parameter Optimization (skopt) Source: https://github.com/mind-lab/octis/blob/master/docs/optimization.rst Defines the hyper-parameter search space using scikit-optimize's (skopt) space module. This example shows a search space for 'alpha' and 'eta' with defined lower and upper bounds. ```python from skopt.space.space import Real search_space = { "alpha": Real(low=0.001, high=5.0), "eta": Real(low=0.001, high=5.0) } ``` -------------------------------- ### Visualize Sample Test Results with Predictions (Python) Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb This snippet visualizes a batch of test images along with their predicted and true labels. It fetches a batch from `test_loader`, obtains model predictions, and displays the images using Matplotlib. Predicted labels are shown in green if correct and red if incorrect. Dependencies include `test_loader`, `model`, `torch`, `np`, and `plt`. ```python # obtain one batch of test images dataiter = iter(test_loader) images, labels = dataiter.next() # get sample outputs output = model(images) # convert output probabilities to predicted class _, preds = torch.max(output, 1) # prep images for display images = images.numpy() # plot the images in the batch, along with predicted and true labels fig = plt.figure(figsize=(25, 4)) for idx in np.arange(20): ax = fig.add_subplot(2, 20/2, idx+1, xticks=[], yticks=[]) ax.imshow(np.squeeze(images[idx]), cmap='gray') ax.set_title("{} ({})".format(str(preds[idx].item()), str(labels[idx].item())), color=("green" if preds[idx]==labels[idx] else "red")) ``` -------------------------------- ### Import Early Stopping Class for PyTorch Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb Imports the EarlyStopping class from the pytorchtools library. This class is crucial for implementing the early stopping mechanism to prevent model overfitting by monitoring validation loss. ```python # import EarlyStopping from pytorchtools import EarlyStopping ``` -------------------------------- ### Visualize Training and Validation Loss with Early Stopping Checkpoint (Python) Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb This snippet visualizes the training and validation loss over epochs, highlighting the point of early stopping. It uses Matplotlib for plotting and assumes `train_loss`, `valid_loss`, and `plt` are defined. The output is a plot saved as 'loss_plot.png'. ```python # visualize the loss as the network trained fig = plt.figure(figsize=(10,8)) plt.plot(range(1,len(train_loss)+1),train_loss, label='Training Loss') plt.plot(range(1,len(valid_loss)+1),valid_loss,label='Validation Loss') # find position of lowest validation loss minposs = valid_loss.index(min(valid_loss))+1 plt.axvline(minposs, linestyle='--', color='r',label='Early Stopping Checkpoint') plt.xlabel('epochs') plt.ylabel('loss') plt.ylim(0, 0.5) # consistent scale plt.xlim(0, len(train_loss)+1) # consistent scale plt.grid(True) plt.legend() plt.tight_layout() plt.show() fig.savefig('loss_plot.png', bbox_inches='tight') ``` -------------------------------- ### Test Trained Network for Loss and Accuracy (Python) Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb This code evaluates a trained PyTorch model on a test dataset, calculating and printing the overall test loss and accuracy per class. It iterates through the `test_loader`, computes predictions, and compares them to true labels. Dependencies include `model`, `criterion`, `test_loader`, `torch`, and `np`. ```python # initialize lists to monitor test loss and accuracy test_loss = 0.0 class_correct = list(0. for i in range(10)) class_total = list(0. for i in range(10)) model.eval() # prep model for evaluation for data, target in test_loader: if len(target.data) != batch_size: break # forward pass: compute predicted outputs by passing inputs to the model output = model(data) # calculate the loss loss = criterion(output, target) # update test loss test_loss += loss.item()*data.size(0) # convert output probabilities to predicted class _, pred = torch.max(output, 1) # compare predictions to true label correct = np.squeeze(pred.eq(target.data.view_as(pred))) # calculate test accuracy for each object class for i in range(batch_size): label = target.data[i] class_correct[label] += correct[i].item() class_total[label] += 1 # calculate and print avg test loss test_loss = test_loss/len(test_loader.dataset) print('Test Loss: {:.6f}\n'.format(test_loss)) for i in range(10): if class_total[i] > 0: print('Test Accuracy of %5s: %2d%% (%2d/%2d)' % ( str(i), 100 * class_correct[i] / class_total[i], np.sum(class_correct[i]), np.sum(class_total[i]))) else: print('Test Accuracy of %5s: N/A (no training examples)' % (classes[i])) print('\nTest Accuracy (Overall): %2d%% (%2d/%2d)' % ( 100. * np.sum(class_correct) / np.sum(class_total), np.sum(class_correct), np.sum(class_total))) ``` -------------------------------- ### Model Training Log with Early Stopping Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb This output log showcases a typical model training process with early stopping enabled. It displays the training and validation loss for each epoch, indicating when the validation loss decreased and the model was saved. The 'EarlyStopping counter' tracks the number of epochs without improvement, and 'Early stopping' is triggered when the patience limit is reached. ```text [ 1/100] train_loss: 0.84499 valid_loss: 0.29977 [ 2/100] train_loss: 0.36182 valid_loss: 0.22742 Validation loss decreased (inf --> 0.227419). Saving model ... [ 3/100] train_loss: 0.29205 valid_loss: 0.19163 Validation loss decreased (0.227419 --> 0.191628). Saving model ... [ 4/100] train_loss: 0.25390 valid_loss: 0.16771 Validation loss decreased (0.191628 --> 0.167714). Saving model ... [ 5/100] train_loss: 0.22671 valid_loss: 0.15422 Validation loss decreased (0.167714 --> 0.154222). Saving model ... [ 6/100] train_loss: 0.20862 valid_loss: 0.14546 Validation loss decreased (0.154222 --> 0.145459). Saving model ... [ 7/100] train_loss: 0.19482 valid_loss: 0.13821 Validation loss decreased (0.145459 --> 0.138206). Saving model ... [ 8/100] train_loss: 0.18431 valid_loss: 0.13398 Validation loss decreased (0.138206 --> 0.133979). Saving model ... [ 9/100] train_loss: 0.17554 valid_loss: 0.12953 Validation loss decreased (0.133979 --> 0.129535). Saving model ... [ 10/100] train_loss: 0.16785 valid_loss: 0.12202 Validation loss decreased (0.129535 --> 0.122023). Saving model ... [ 11/100] train_loss: 0.16202 valid_loss: 0.12249 EarlyStopping counter: 1 out of 20 [ 12/100] train_loss: 0.15300 valid_loss: 0.11852 Validation loss decreased (0.122023 --> 0.118516). Saving model ... [ 13/100] train_loss: 0.14965 valid_loss: 0.11560 Validation loss decreased (0.118516 --> 0.115598). Saving model ... [ 14/100] train_loss: 0.14680 valid_loss: 0.11387 Validation loss decreased (0.115598 --> 0.113867). Saving model ... [ 15/100] train_loss: 0.13988 valid_loss: 0.11728 EarlyStopping counter: 1 out of 20 [ 16/100] train_loss: 0.13641 valid_loss: 0.11269 Validation loss decreased (0.113867 --> 0.112686). Saving model ... [ 17/100] train_loss: 0.12957 valid_loss: 0.11237 Validation loss decreased (0.112686 --> 0.112374). Saving model ... [ 18/100] train_loss: 0.12862 valid_loss: 0.11198 Validation loss decreased (0.112374 --> 0.111975). Saving model ... [ 19/100] train_loss: 0.12581 valid_loss: 0.10924 Validation loss decreased (0.111975 --> 0.109242). Saving model ... [ 20/100] train_loss: 0.12171 valid_loss: 0.10836 Validation loss decreased (0.109242 --> 0.108363). Saving model ... [ 21/100] train_loss: 0.12191 valid_loss: 0.10922 EarlyStopping counter: 1 out of 20 [ 22/100] train_loss: 0.11935 valid_loss: 0.10976 EarlyStopping counter: 2 out of 20 [ 23/100] train_loss: 0.11901 valid_loss: 0.11053 EarlyStopping counter: 3 out of 20 [ 24/100] train_loss: 0.11420 valid_loss: 0.10901 EarlyStopping counter: 4 out of 20 [ 25/100] train_loss: 0.11089 valid_loss: 0.10837 EarlyStopping counter: 5 out of 20 [ 26/100] train_loss: 0.11008 valid_loss: 0.10944 EarlyStopping counter: 6 out of 20 [ 27/100] train_loss: 0.10801 valid_loss: 0.10665 Validation loss decreased (0.108363 --> 0.106647). Saving model ... [ 28/100] train_loss: 0.10433 valid_loss: 0.10248 Validation loss decreased (0.106647 --> 0.102475). Saving model ... [ 29/100] train_loss: 0.10323 valid_loss: 0.10621 EarlyStopping counter: 1 out of 20 [ 30/100] train_loss: 0.10484 valid_loss: 0.10775 EarlyStopping counter: 2 out of 20 [ 31/100] train_loss: 0.09985 valid_loss: 0.10616 EarlyStopping counter: 3 out of 20 [ 32/100] train_loss: 0.09898 valid_loss: 0.10479 EarlyStopping counter: 4 out of 20 [ 33/100] train_loss: 0.10062 valid_loss: 0.10576 EarlyStopping counter: 5 out of 20 [ 34/100] train_loss: 0.09704 valid_loss: 0.10770 EarlyStopping counter: 6 out of 20 [ 35/100] train_loss: 0.09850 valid_loss: 0.10542 EarlyStopping counter: 7 out of 20 [ 36/100] train_loss: 0.09561 valid_loss: 0.10619 EarlyStopping counter: 8 out of 20 [ 37/100] train_loss: 0.09381 valid_loss: 0.10745 EarlyStopping counter: 9 out of 20 [ 38/100] train_loss: 0.09363 valid_loss: 0.10487 EarlyStopping counter: 10 out of 20 [ 39/100] train_loss: 0.09263 valid_loss: 0.10763 EarlyStopping counter: 11 out of 20 [ 40/100] train_loss: 0.09234 valid_loss: 0.10778 EarlyStopping counter: 12 out of 20 [ 41/100] train_loss: 0.08485 valid_loss: 0.10319 EarlyStopping counter: 13 out of 20 [ 42/100] train_loss: 0.09105 valid_loss: 0.10305 EarlyStopping counter: 14 out of 20 [ 43/100] train_loss: 0.08963 valid_loss: 0.10952 EarlyStopping counter: 15 out of 20 [ 44/100] train_loss: 0.08887 valid_loss: 0.10615 EarlyStopping counter: 16 out of 20 [ 45/100] train_loss: 0.08704 valid_loss: 0.10870 EarlyStopping counter: 17 out of 20 [ 46/100] train_loss: 0.08477 valid_loss: 0.10877 EarlyStopping counter: 18 out of 20 [ 47/100] train_loss: 0.08397 valid_loss: 0.10682 EarlyStopping counter: 19 out of 20 [ 48/100] train_loss: 0.08630 valid_loss: 0.10565 EarlyStopping counter: 20 out of 20 Early stopping ``` -------------------------------- ### Define MLP Network Architecture in PyTorch Source: https://github.com/mind-lab/octis/blob/master/octis/models/early_stopping/MNIST_Early_Stopping_example.ipynb Defines a simple Multi-Layer Perceptron (MLP) model with three linear layers and ReLU activation functions. It includes dropout for regularization and a method to flatten the input image. Dependencies: torch.nn and torch.nn.functional. ```python import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.fc1 = nn.Linear(28 * 28, 128) self.fc2 = nn.Linear(128, 128) self.fc3 = nn.Linear(128, 10) self.dropout = nn.Dropout(0.5) def forward(self, x): # flatten image input x = x.view(-1, 28 * 28) # add hidden layer, with relu activation function x = F.relu(self.fc1(x)) x = self.dropout(x) # add hidden layer, with relu activation function x = F.relu(self.fc2(x)) x = self.dropout(x) # add output layer x = self.fc3(x) return x # initialize the NN model = Net() print(model) ``` -------------------------------- ### Run OCTIS Dashboard Server in Bash Source: https://github.com/mind-lab/octis/blob/master/README.rst This bash command initiates the OCTIS dashboard server. It requires cloning the OCTIS repository and running the server script from the project's root directory. Once executed, the dashboard will open in a browser, providing a user interface for creating, monitoring, and visualizing experiments. ```bash python OCTIS/dashboard/server.py ``` -------------------------------- ### Define NPMI Coherence Metric for Evaluation Source: https://github.com/mind-lab/octis/blob/master/examples/OCTIS_Optimizing_CTM.ipynb Initializes the Normalized Pointwise Mutual Information (NPMI) topic coherence metric using the corpus from the loaded dataset. This metric is used to evaluate the quality of the topics discovered by the model. ```python npmi = Coherence(texts=dataset.get_corpus()) ``` -------------------------------- ### Initialize Popovers and Event Listeners in JavaScript Source: https://github.com/mind-lab/octis/blob/master/octis/dashboard/templates/CreateExperiments.html Initializes jQuery popovers and sets up an event listener for a button click to select a file path. Upon successful AJAX response, it updates input fields and display elements with the selected path. ```javascript function getParams(vars) { return vars; } $(function () { $('[data-toggle="popover"]').popover() }); $(document).ready(function () { document.getElementById("selpath").addEventListener("click", selectPath) function selectPath() { $.ajax( { type: 'POST', url: "/selectPath", success: function (data) { console.log(data) document.getElementById("path").value = data["path"] document.getElementById("showPath").innerHTML = data["path"] } }); } //Get dataset names dataset = getParams({{ datasets| tojson}}); imgPath = "{{ url_for('static', filename='images/dataset.png') }}"; rBtnName = "dataset" father = document.getElementById("datasetSelector"); createCoolSelection(dataset, imgPath, rBtnName, father) model = getParams({{ models| tojson}}); father = document.getElementById("modelForm"); modelNames = [] for (const [key, value] of Object.entries(model)) { modelNames.push(key) } rBtnName = "model" imgPath = "{{ url_for('static', filename='images/model.png') }}"; createCoolSelection(modelNames, imgPath, rBtnName, father) metrics = getParams({{ metrics| tojson}}); for (const [key, value] of Object.entries(metrics)) { addMetricBox(key, value, "optimizeMetrics") addMetricBox(key, value, "trackMetrics") } BO = getParams({{ optimization| tojson}}); boSelector = document.getElementById("boSelector"); surrogateModelInput = document.createElement("select") surrogateModelInput.classList.add("coolSelect") surrogateModelInput.name = "surrogateModel" for (const val of BO["surrogate_models"]) { var option = document.createElement("option"); option.text = val["name"] option.value = val["id"] surrogateModelInput.appendChild(option) } div = document.getElementById("boRow"); new_div = document.createElement("div") new_div.classList.add("form-group") new_div.classList.add("col-lg-3") new_div.innerHTML = new_div.innerHTML + "
Surrogate model
" new_div.appendChild(surrogateModelInput) div.appendChild(new_div) boSelector.appendChild(div) $(function () { $('[data-toggle="popover"]').popover() }); AcqFuncInput = document.createElement("select") AcqFuncInput.classList.add("coolSelect") AcqFuncInput.name = "acquisitionFunction" for (const val of BO["acquisition_functions"]) { var option = document.createElement("option"); option.text = val["name"] option.value = val["id"] AcqFuncInput.appendChild(option) } div = document.getElementById("boRow"); new_div = document.createElement("div") new_div.classList.add("form-group") new_div.classList.add("col-lg-3") new_div.innerHTML = new_div.innerHTML + "Acquisition function
" new_div.appendChild(AcqFuncInput) div.appendChild(new_div) boSelector.appendChild(div) function addMetricBox(name, info, where) { fat = document.getElementById(where) box = document.createElement("div") box.classList.add("singleMetric") fat.appendChild(box) box_body = document.createElement("div") box_body.classList.add("singleMetricBody") box.appendChild(box_body) box_title = "