0.0.9 • Published 8 months ago

direct-manager v0.0.9

Weekly downloads
3
License
MIT
Repository
github
Last release
8 months ago

direct-manager

NPM version build status Test coverage npm download

Installation

$ npm i direct-manager

Usage

import direct from 'ml-direct';
import DirectManager from 'direct-manager';
import SD from 'spectra-data';

// The prediction should be obtained with SPINUS.
const directManager = new DirectManager(prediction);
const boundaries = directManager.getBoundaries();
const buildPredictionFile = directManager.tidyUpParameters();

const spectraProperties = {
  frequency: 400,
  from: 0,
  to: 10,
  lineWidth: 3,
  nbPoints: 4096,
  maxClusterSize: 8,
  output: 'xy',
};

const predicted = direct(
  objectiveFunction,
  boundaries.lower,
  boundaries.upper,
  { iterations: 10 },
);

// target: Experimental spectrum.
function objectiveFunction(parameters) {
  const testSignals = buildPredictionFile(parameters);
  const simulation = SD.NMR.fromSignals(testSignals, spectraProperties);
  simulation.setMinMax(0, 1);
  const simulated = simulation.getYData();
  let result = 0;
  for (let i = 0; i < target.length; i++) {
    result += (target[i] - simulated[i]) ** 2;
  }
  return result;
}

Cheminfo tools

License

MIT

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

9 months ago

0.0.6

2 years ago

0.0.5

3 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago