direct-manager
TypeScript icon, indicating that this package has built-in type declarations

0.0.9 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i direct-manager

Weekly Downloads

1

Version

0.0.9

License

MIT

Unpacked Size

67.5 kB

Total Files

57

Last publish

Collaborators

  • josoriom