Commit d255442c authored by Joseph Larralde's avatar Joseph Larralde
Browse files

apply forgotten commits

parent a02032fc
File added
This diff is collapsed.
......@@ -2,56 +2,55 @@
#include <iostream>
#include "regression.h"
#include "classification.h"
#include "json.h"
#include "gmmClassification.h"
#include "gmmRegression.h"
int main(int argc, const char * argv[]) {
// insert code here...
regression myNN;
classification myKnn;
std::vector<trainingExample> trainingSet;
trainingExample tempExample;
tempExample.input = { 0.2, 0.7 };
tempExample.output = { 3.0 };
trainingSet.push_back(tempExample);
tempExample.input = { 2.0, 44.2 };
tempExample.output = { 20.14 };
trainingSet.push_back(tempExample);
myNN.train(trainingSet);
std::cout << myNN.getJSON() << std::endl;
std::string filepath = "/var/tmp/modelSetDescription.json";
myNN.writeJSON(filepath);
//#include "json.h" // not needed, avoid potential conflicts with xmm
regression myNNfromString;
myNNfromString.putJSON(myNN.getJSON());
regression myNNfromFile;
myNNfromFile.readJSON(filepath);
std::vector<double> inputVec = { 2.0, 44.2 };
std::cout << "before: " << myNN.process(inputVec)[0] << std::endl;
std::cout << "from string: " << myNNfromString.process(inputVec)[0] << std::endl;
std::cout << "from file: " << myNNfromFile.process(inputVec)[0] << std::endl;
///////////////////////////
myKnn.train(trainingSet);
std::cout << myKnn.getJSON() << std::endl;
std::string filepath2 = "/var/tmp/modelSetDescription_knn.json";
myKnn.writeJSON(filepath2);
classification myKnnFromString;
myKnnFromString.putJSON(myKnn.getJSON());
classification myKnnfromFile;
myKnnfromFile.readJSON(filepath2);
std::cout << "knn before: " << myKnn.process(inputVec)[0] << std::endl;
std::cout << "knn from string: " << myKnnFromString.process(inputVec)[0] << std::endl;
std::cout << "knn from file: " << myKnnfromFile.process(inputVec)[0] << std::endl;
return 0;
int main(int argc, const char * argv[]) {
// insert code here...
regression myNN;
classification myKnn;
gmmClassification myGmm;
gmmRegression myGmr;
std::vector<trainingExample> trainingSet;
trainingExample tempExample;
tempExample.input = { 0.2, 0.7 };
tempExample.output = { 3.0 };
trainingSet.push_back(tempExample);
tempExample.input = { 2.0, 44.2 };
tempExample.output = { 20.14 };
trainingSet.push_back(tempExample);
myGmm.train(trainingSet);
myGmr.train(trainingSet);
myNN.train(trainingSet);
// std::cout << myNN.getJSON() << std::endl;
std::string filepath = "/var/tmp/modelSetDescription.json";
myNN.writeJSON(filepath);
regression myNNfromString;
myNNfromString.putJSON(myNN.getJSON());
regression myNNfromFile;
myNNfromFile.readJSON(filepath);
std::vector<double> inputVec = { 2.0, 44.2 };
// std::cout << "before: " << myNN.process(inputVec)[0] << std::endl;
// std::cout << "from string: " << myNNfromString.process(inputVec)[0] << std::endl;
// std::cout << "from file: " << myNNfromFile.process(inputVec)[0] << std::endl;
// std::vector<double> out = myGmm.process(inputVec);
// std::cout << "GMM : " << out[0] << std::endl;
// std::cout << out.size() << std::endl;
std::cout << "GMM : " << myGmm.process(inputVec)[0] << std::endl;
std::cout << "GMR : " << myGmr.process(inputVec)[0] << std::endl;
inputVec = { 0.2, 0.7 };
std::cout << "GMM : " << myGmm.process(inputVec)[0] << std::endl;
std::cout << "GMR : " << myGmr.process(inputVec)[0] << std::endl;
return 0;
}
......@@ -87,9 +87,9 @@
<div class="col-md-6" id="machineLearning" >
<h2>Machine Learning</h2>
<div class="row controls btn-group" >
<button class="btn btn-default" onclick="togRecord()">Record</button>
<button class="btn btn-default" onclick="train()">Train</button>
<button class="btn btn-default" onclick="togRun()">Run</button>
<button class="btn btn-default" onclick="randomize()">Record</button>
<button class="btn btn-default" onclick="togMute()">Train</button>
<button class="btn btn-default" onclick="randomize()">Run</button>
</div>
</div>
<div class="col-md-6" id="synth" >
......
{
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 7,
"minor" : 3,
"revision" : 1,
"architecture" : "x64",
"modernui" : 1
}
,
"rect" : [ 115.0, 142.0, 926.0, 491.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 1,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 1,
"objectsnaponopen" : 1,
"statusbarvisible" : 2,
"toolbarvisible" : 1,
"lefttoolbarpinned" : 0,
"toptoolbarpinned" : 0,
"righttoolbarpinned" : 0,
"bottomtoolbarpinned" : 0,
"toolbars_unpinned_last_save" : 0,
"tallnewobj" : 0,
"boxanimatetime" : 200,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"description" : "",
"digest" : "",
"tags" : "",
"style" : "",
"subpatcher_template" : "",
"boxes" : [ {
"box" : {
"id" : "obj-28",
"maxclass" : "toggle",
"numinlets" : 1,
"numoutlets" : 1,
"outlettype" : [ "int" ],
"parameter_enable" : 0,
"patching_rect" : [ 461.0, 36.0, 24.0, 24.0 ],
"style" : ""
}
}
, {
"box" : {
"id" : "obj-26",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 461.0, 65.0, 61.0, 22.0 ],
"style" : "",
"text" : "record $1"
}
}
, {
"box" : {
"id" : "obj-24",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 653.5, 278.5, 29.5, 22.0 ],
"presentation_rect" : [ 603.5, 255.5, 0.0, 0.0 ],
"style" : "",
"text" : "4 5"
}
}
, {
"box" : {
"format" : 6,
"id" : "obj-23",
"maxclass" : "flonum",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 590.0, 406.0, 50.0, 22.0 ],
"style" : ""
}
}
, {
"box" : {
"id" : "obj-20",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 610.5, 278.5, 29.5, 22.0 ],
"presentation_rect" : [ 612.0, 278.5, 0.0, 0.0 ],
"style" : "",
"text" : "7 8"
}
}
, {
"box" : {
"id" : "obj-21",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 568.5, 278.5, 29.5, 22.0 ],
"presentation_rect" : [ 570.0, 278.5, 0.0, 0.0 ],
"style" : "",
"text" : "1 2"
}
}
, {
"box" : {
"id" : "obj-19",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 721.5, 440.0, 61.0, 22.0 ],
"style" : "",
"text" : "print out4"
}
}
, {
"box" : {
"id" : "obj-18",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 645.0, 440.0, 61.0, 22.0 ],
"style" : "",
"text" : "print out3"
}
}
, {
"box" : {
"id" : "obj-17",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 568.5, 440.0, 61.0, 22.0 ],
"style" : "",
"text" : "print out2"
}
}
, {
"box" : {
"id" : "obj-16",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 492.0, 440.0, 61.0, 22.0 ],
"style" : "",
"text" : "print out1"
}
}
, {
"box" : {
"id" : "obj-15",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 798.0, 440.0, 34.0, 22.0 ],
"style" : "",
"text" : "print"
}
}
, {
"box" : {
"id" : "obj-14",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 492.0, 299.5, 34.0, 22.0 ],
"style" : "",
"text" : "train"
}
}
, {
"box" : {
"id" : "obj-12",
"linecount" : 2,
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 5,
"outlettype" : [ "", "", "", "", "" ],
"patching_rect" : [ 492.0, 336.5, 409.0, 35.0 ],
"style" : "",
"text" : "mubu.gmr gmr-test input output @varianceoffset 0.001 0.001 @mixtures 1 @play 1"
}
}
, {
"box" : {
"id" : "obj-9",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 52.0, 88.0, 80.0, 22.0 ],
"style" : "",
"text" : "numbuffers 1"
}
}
, {
"box" : {
"id" : "obj-7",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 534.0, 118.5, 37.0, 22.0 ],
"presentation_rect" : [ 515.0, 120.0, 0.0, 0.0 ],
"style" : "",
"text" : "7 8 1"
}
}
, {
"box" : {
"id" : "obj-6",
"maxclass" : "number",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "bang" ],
"parameter_enable" : 0,
"patching_rect" : [ 562.0, 158.0, 50.0, 22.0 ],
"style" : ""
}
}
, {
"box" : {
"id" : "obj-4",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 492.0, 118.5, 37.0, 22.0 ],
"style" : "",
"text" : "1 2 5"
}
}
, {
"box" : {
"id" : "obj-2",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 0,
"patcher" : {
"fileversion" : 1,
"appversion" : {
"major" : 7,
"minor" : 3,
"revision" : 1,
"architecture" : "x64",
"modernui" : 1
}
,
"rect" : [ 110.0, 155.0, 1066.0, 547.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
"default_fontface" : 0,
"default_fontname" : "Arial",
"gridonopen" : 1,
"gridsize" : [ 15.0, 15.0 ],
"gridsnaponopen" : 1,
"objectsnaponopen" : 1,
"statusbarvisible" : 2,
"toolbarvisible" : 1,
"lefttoolbarpinned" : 0,
"toptoolbarpinned" : 0,
"righttoolbarpinned" : 0,
"bottomtoolbarpinned" : 0,
"toolbars_unpinned_last_save" : 0,
"tallnewobj" : 0,
"boxanimatetime" : 200,
"enablehscroll" : 1,
"enablevscroll" : 1,
"devicewidth" : 0.0,
"description" : "",
"digest" : "",
"tags" : "",
"style" : "",
"subpatcher_template" : "",
"boxes" : [ {
"box" : {
"id" : "obj-10",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 88.0, 136.0, 75.0, 22.0 ],
"style" : "",
"text" : "route record"
}
}
, {
"box" : {
"id" : "obj-9",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 68.0, 175.0, 61.0, 22.0 ],
"style" : "",
"text" : "record $1"
}
}
, {
"box" : {
"id" : "obj-6",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 3,
"outlettype" : [ "int", "", "int" ],
"patching_rect" : [ 68.0, 102.0, 40.0, 22.0 ],
"style" : "",
"text" : "t 0 l 1"
}
}
, {
"box" : {
"comment" : "",
"id" : "obj-5",
"maxclass" : "inlet",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 286.0, 50.0, 30.0, 30.0 ],
"presentation_rect" : [ 285.0, 49.0, 0.0, 0.0 ],
"style" : ""
}
}
, {
"box" : {
"id" : "obj-4",
"maxclass" : "message",
"numinlets" : 2,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 286.0, 130.0, 86.0, 22.0 ],
"style" : "",
"text" : "bufferindex $1"
}
}
, {
"box" : {
"comment" : "",
"id" : "obj-2",
"maxclass" : "inlet",
"numinlets" : 0,
"numoutlets" : 1,
"outlettype" : [ "" ],
"patching_rect" : [ 122.0, 50.0, 30.0, 30.0 ],
"style" : ""
}
}
, {
"box" : {
"id" : "obj-1",
"maxclass" : "newobj",
"numinlets" : 2,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 152.0, 174.0, 57.0, 22.0 ],
"style" : "",
"text" : "zl slice 2"
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 11.0,
"id" : "obj-8",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 152.0, 261.511078, 838.0, 21.0 ],
"style" : "",
"text" : "mubu.record gmr-test 1 input @predef yes @samplerate 100 @matrixcols 2 @maxsize 1000 @info gui \"interface multiwave, bounds 0. 1., fgcolor green, shape envelope\""
}
}
, {
"box" : {
"fontname" : "Arial",
"fontsize" : 11.0,
"id" : "obj-19",
"maxclass" : "newobj",
"numinlets" : 1,
"numoutlets" : 2,
"outlettype" : [ "", "" ],
"patching_rect" : [ 190.0, 307.511078, 832.0, 21.0 ],
"style" : "",
"text" : "mubu.record gmr-test 2 output @predef yes @samplerate 100 @matrixcols 1 @maxsize 1000 @info gui \"interface multiwave, bounds 0. 1., fgcolor red, shape envelope\""
}
}
],
"lines" : [ {
"patchline" : {
"destination" : [ "obj-19", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-1", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-1", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-1", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-10", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-9", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-10", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-6", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-2", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-19", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-4", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-4", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-4", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-5", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-10", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-6", 1 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-19", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-9", 0 ]
}
}
, {
"patchline" : {
"destination" : [ "obj-8", 0 ],
"disabled" : 0,
"hidden" : 0,
"source" : [ "obj-9", 0 ]
}
}
]