ideaconsult / jToxKit

jToxKit new generation
MIT License
2 stars 2 forks source link

UI to run models #26

Open vedina opened 7 years ago

vedina commented 7 years ago

Moved from https://github.com/ideaconsult/Toxtree.js/issues/68 and https://github.com/ideaconsult/Toxtree.js/issues/110

vedina commented 7 years ago

See T171

thejonan commented 7 years ago

There are two more skills added to jToxKit: TaskPollng and ModelRunning - they work together to make the prediction running an easy task. (Check this commit: 504c6afc372dcc44677064e5a9ee7d9f0b029425)

If they are combined with the Running widget which automates the process of attaching a method invocations to UI element, the entire wiring to enable running predictions on datasets is very easy. There is an example in model_demo.html and it goes like this:

  <input type="text" placeholder="Dataset URI_" id="dataset-uri" size="100"/><br/>
  <input type="text" placeholder="Model URI_" id="model-uri" size="100"/><br/>
  <input type="button" value="Run" id="run-prediction"/>&nbsp;<span id="algorithms-count">0</span><br/>
  <textarea id="result-area" placeholder="Results_" cols="100" rows="20"></textarea>

<!-- referred scripts, including jtox-kit.js -->
  <script type="text/javascript">
    var Manager = new (a$(Solr.Management, Solr.QueryingURL, Solr.Configuring))({ 
          serverUrl: "https://apps.ideaconsult.net/data/",
          connector: $
        }),
        Runner = new (a$(jT.ModelRunning, jT.TaskPolling, jT.Running))({ 
          /* Running skill settings */
          runSelector: '#run-prediction',
          runMethod: "onRun",
          target: document,

          /* ModelRunning settings */
          algorithms: true, 
          listFilter: "ToxTree", 
          loadOnInit: true, id: 'toxtree',
//           forceCreate: true,
          onRun: function (e) {
            this.runPrediction(datasetUri, $('#model-uri').val(), function (results) {
              $('#result-area').html(JSON.stringify(results, null, 2));
            });
          },
          onLoaded: function (result) {
            var self = this;

            $('#algorithms-count').html(result.algorithm.length);

            self.getModel(result.algorithm[0].uri, function (modelUri) {
              $('#model-uri').val(modelUri);
            });
          }
        });

    Manager.addListeners(Runner);
    Manager.init();

Pay attention to the fact that this is an exemplary Manager object, and that it also refers to AMBIT server.

thejonan commented 7 years ago

The challenging part could be matching the proper column for each predicted feature.

This is actually easy, the features should have sameAs label which is the same as the endpoint category (which defines the column of the read across matrix)

thejonan commented 7 years ago

I've added some version of this functionality. It can be found on this commit: 33e6f9fe247c399e407dd407236058766937406a of the old repo (branch: feature/ui-model-running). It does the same: