From 1dd01a06992fe19c3364c61ad97bbaf419b4899c Mon Sep 17 00:00:00 2001 From: Joey Lee Date: Wed, 2 Oct 2019 19:20:38 -0400 Subject: [PATCH] Refactors examples to match diy-nn-refactor branch (#195) * neural noteplayer example * example inspired by Eyeo 2019 Rebecca Fiebrink talk * rename musical mouse example * example tweaks and oscillator * adds refactoring examples * updates examples based in refactor * updates xor" * rm unused co2net * updates examples for regression * updates musical note example * adds experimental normalizationOptions * adds example of multi layered network * changes activations * adds simple classification example * changes .normalize() to .normalizeData() * updates all examples to handle array of .predict() or .classify() output --- .../index.html | 19 + .../sketch.js | 56 + .../NeuralNetwork_Simple-Regression/sketch.js | 4 +- .../NeuralNetwork/NeuralNetwork_XOR/sketch.js | 19 +- .../NeuralNetwork_basics/sketch.js | 10 +- .../data/co2stats.json | 2105 ----------------- .../NeuralNetwork_co2net-training/index.html | 69 - .../NeuralNetwork_co2net-training/sketch.js | 101 - .../data/co2stats.csv | 0 .../NeuralNetwork_co2net/model/model.json | 1 - .../model/model.weights.bin | 1 - .../NeuralNetwork_co2net/sketch.js | 257 +- .../NeuralNetwork_color_classifier/sketch.js | 2 +- .../NeuralNetwork_lowres_pixels/index.html | 27 + .../NeuralNetwork_lowres_pixels/sketch.js | 119 + .../NeuralNetwork_multiple-layers/index.html | 18 + .../NeuralNetwork_multiple-layers/sketch.js | 72 + .../NeuralNetwork_musical_mouse/index.html | 31 + .../NeuralNetwork_musical_mouse/sketch.js | 62 + .../NeuralNetwork_titanic/sketch.js | 4 +- 20 files changed, 487 insertions(+), 2490 deletions(-) create mode 100755 p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/index.html create mode 100644 p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/sketch.js delete mode 100644 p5js/NeuralNetwork/NeuralNetwork_co2net-training/data/co2stats.json delete mode 100755 p5js/NeuralNetwork/NeuralNetwork_co2net-training/index.html delete mode 100644 p5js/NeuralNetwork/NeuralNetwork_co2net-training/sketch.js rename p5js/NeuralNetwork/{NeuralNetwork_co2net-training => NeuralNetwork_co2net}/data/co2stats.csv (100%) delete mode 100644 p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.json delete mode 100644 p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.weights.bin create mode 100755 p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/index.html create mode 100644 p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/sketch.js create mode 100644 p5js/NeuralNetwork/NeuralNetwork_multiple-layers/index.html create mode 100644 p5js/NeuralNetwork/NeuralNetwork_multiple-layers/sketch.js create mode 100755 p5js/NeuralNetwork/NeuralNetwork_musical_mouse/index.html create mode 100644 p5js/NeuralNetwork/NeuralNetwork_musical_mouse/sketch.js diff --git a/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/index.html b/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/index.html new file mode 100755 index 00000000..ecce4686 --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/index.html @@ -0,0 +1,19 @@ + + + + + Neural Network + + + + + + + +

Neural Network Classification

+ + + + + + \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/sketch.js new file mode 100644 index 00000000..9096d96c --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_Simple-Classification/sketch.js @@ -0,0 +1,56 @@ +// Copyright (c) 2018 ml5 +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +/* === +ml5 Example +Image classification using MobileNet and p5.js +This example uses a callback pattern to create the classifier +=== */ +let nn; + +const options = { + inputs: 1, + outputs: 2, + task: 'classification', + debug: true +} + +function setup(){ + createCanvas(400, 400); + nn = ml5.neuralNetwork(options); + + + console.log(nn) + createTrainingData(); + nn.normalizeData(); + + const trainingOptions={ + batchSize: 24, + epochs: 32 + } + + nn.train(trainingOptions,finishedTraining); // if you want to change the training options + // nn.train(finishedTraining); // use the default training options +} + +function finishedTraining(){ + + nn.classify([300], function(err, result){ + console.log(result); + }) + +} + +function createTrainingData(){ + for(let i = 0; i < 400; i++){ + if(i%2 === 0){ + const x = random(0, width/2); + nn.addData( [x], ['left']) + } else { + const x = random(width/2, width); + nn.addData( [x], ['right']) + } + } +} diff --git a/p5js/NeuralNetwork/NeuralNetwork_Simple-Regression/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_Simple-Regression/sketch.js index d21a1dad..47f82dd5 100644 --- a/p5js/NeuralNetwork/NeuralNetwork_Simple-Regression/sketch.js +++ b/p5js/NeuralNetwork/NeuralNetwork_Simple-Regression/sketch.js @@ -23,7 +23,7 @@ function setup(){ console.log(nn) createTrainingData(); - nn.data.normalize(); + nn.normalizeData(); const trainingOptions={ batchSize: 24, @@ -39,7 +39,7 @@ async function finishedTraining(){ await Promise.all( [...new Array(400).fill(null).map( async (item, idx) => { let results = await nn.predict([idx]); - let prediction = results.outputs + let prediction = results[0] let x = idx let y = prediction.value fill(255, 0, 0); diff --git a/p5js/NeuralNetwork/NeuralNetwork_XOR/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_XOR/sketch.js index cb93aac4..6d29adb9 100644 --- a/p5js/NeuralNetwork/NeuralNetwork_XOR/sketch.js +++ b/p5js/NeuralNetwork/NeuralNetwork_XOR/sketch.js @@ -15,17 +15,18 @@ function setup() { inputs: 2, outputs: 1, learningRate: 0.25, + debug:true // hiddenUnits: 2 } model = ml5.neuralNetwork(options); //model = ml5.neuralNetwork(2, 1); - model.data.addData([0, 0], [0]); - model.data.addData([1, 0], [1]); - model.data.addData([0, 1], [1]); - model.data.addData([1, 1], [0]); - model.data.normalize(); - model.train({ epochs: 200 }, whileTraining, finishedTraining); + model.addData([0, 0], [0]); + model.addData([1, 0], [1]); + model.addData([0, 1], [1]); + model.addData([1, 1], [0]); + model.normalizeData(); + model.train({ epochs: 50 }, whileTraining, finishedTraining); } @@ -50,7 +51,11 @@ function finishedTraining() { } function gotResults(error, results) { - console.log(results.values[0]); + if(error){ + console.log(err) + return + } + console.log(results[0].value); } function draw() { diff --git a/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js index 9a9d0607..3fea81b1 100644 --- a/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js +++ b/p5js/NeuralNetwork/NeuralNetwork_basics/sketch.js @@ -16,8 +16,7 @@ function setup() { inputs: 3, outputs: 2, task: 'regression', - // activationOutput: 'sigmoid', - // activationHidden: 'sigmoid' + debug:true }; // Create Neural Network nn = ml5.neuralNetwork(options); @@ -96,7 +95,7 @@ function trainModel() { // output1: training_target[1], // }); - nn.data.addData(training_input, training_target) + nn.addData(training_input, training_target) } @@ -105,7 +104,7 @@ function trainModel() { batchSize: 12 } // Train - nn.data.normalize(); + nn.normalizeData(); nn.train(trainingOptions, finishedTraining); } @@ -127,6 +126,7 @@ function predict() { function gotResults(error, results) { if (error) console.log(error); if (results) { - console.log(results.output); + console.log(results); + results.tensor.print() } } \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/data/co2stats.json b/p5js/NeuralNetwork/NeuralNetwork_co2net-training/data/co2stats.json deleted file mode 100644 index d21bf662..00000000 --- a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/data/co2stats.json +++ /dev/null @@ -1,2105 +0,0 @@ -{ - "meta":"https://doi.pangaea.de/10.1594/PANGAEA.884141", - "data":[ - { - "val": 1, - "city_name": "Abington", - "city_name_cdp": "Abington Township", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 193345, - "year_of_emission": 2010, - "latitude_degrees": 40.1, - "longitude_degrees": -75.099722, - "country": "USA", - "region": "North America", - "population_cdp": 55310, - "population_year_cdp": 2010 - }, - { - "val": 2, - "city_name": "Addis Ababa", - "city_name_cdp": "Addis Ababa City Administration", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3708292, - "year_of_emission": 2012, - "latitude_degrees": 9.03, - "longitude_degrees": 38.74, - "country": "Ethiopia", - "region": "Africa", - "population_cdp": 3384569, - "population_year_cdp": 2008 - }, - { - "val": 3, - "city_name": "Adelaide", - "city_name_cdp": "City of Adelaide", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 63724, - "year_of_emission": 2013, - "latitude_degrees": -34.929, - "longitude_degrees": 138.601, - "country": "Australia", - "region": "Oceania", - "population_cdp": 23169, - "population_year_cdp": 2015 - }, - { - "val": 7, - "city_name": "Ajax, ON", - "city_name_cdp": "Town of Ajax, ON", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6354, - "year_of_emission": 2008, - "latitude_degrees": 43.858, - "longitude_degrees": -79.036389, - "country": "Canada", - "region": "North America", - "population_cdp": 109600, - "population_year_cdp": 2011 - }, - { - "val": 8, - "city_name": "Albany", - "city_name_cdp": "City of Albany", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 663997, - "year_of_emission": 2010, - "latitude_degrees": 42.653, - "longitude_degrees": -73.757222, - "country": "USA", - "region": "North America", - "population_cdp": 97856, - "population_year_cdp": 2010 - }, - { - "val": 9, - "city_name": "Alton, IL", - "city_name_cdp": "City of Alton, IL", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 138542, - "year_of_emission": 2013, - "latitude_degrees": 38.901, - "longitude_degrees": -90.159722, - "country": "USA", - "region": "North America", - "population_cdp": 26581, - "population_year_cdp": 2015 - }, - { - "val": 10, - "city_name": "Amman", - "city_name_cdp": "Greater Amman Municipality", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3322603, - "year_of_emission": 2014, - "latitude_degrees": 31.95, - "longitude_degrees": 35.932778, - "country": "Jordan", - "region": "North Africa, Middle East, West Asia", - "population_cdp": 3604459, - "population_year_cdp": 2015 - }, - { - "val": 11, - "city_name": "Amsterdam", - "city_name_cdp": "City of Amsterdam", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2161000, - "year_of_emission": 2016, - "latitude_degrees": 52.367, - "longitude_degrees": 4.9, - "country": "Netherlands", - "region": "Europe", - "population_cdp": 822272, - "population_year_cdp": 2015 - }, - { - "val": 14, - "city_name": "Arlington, VA", - "city_name_cdp": "City of Arlington, VA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1257464, - "year_of_emission": 2015, - "latitude_degrees": 38.881, - "longitude_degrees": -77.1372613, - "country": "USA", - "region": "North America", - "population_cdp": 216700, - "population_year_cdp": 2015 - }, - { - "val": 16, - "city_name": "Athens", - "city_name_cdp": "City of Athens", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1260355, - "year_of_emission": 2014, - "latitude_degrees": 37.984, - "longitude_degrees": 23.727806, - "country": "Greece", - "region": "Europe", - "population_cdp": 664046, - "population_year_cdp": 2011 - }, - { - "val": 17, - "city_name": "Atlanta", - "city_name_cdp": "City of Atlanta", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3548215, - "year_of_emission": 2014, - "latitude_degrees": 33.755, - "longitude_degrees": -84.39, - "country": "USA", - "region": "North America", - "population_cdp": 443775, - "population_year_cdp": 2013 - }, - { - "val": 18, - "city_name": "Auckland", - "city_name_cdp": "Auckland Council", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 9133523, - "year_of_emission": 2013, - "latitude_degrees": -36.841, - "longitude_degrees": 174.74, - "country": "New Zealand", - "region": "Oceania", - "population_cdp": 1569900, - "population_year_cdp": 2015 - }, - { - "val": 19, - "city_name": "Austin", - "city_name_cdp": "City of Austin", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6439000, - "year_of_emission": 2013, - "latitude_degrees": 30.267, - "longitude_degrees": -97.733333, - "country": "USA", - "region": "North America", - "population_cdp": 888204, - "population_year_cdp": 2015 - }, - { - "val": 21, - "city_name": "Baltimore", - "city_name_cdp": "City of Baltimore", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 4019044, - "year_of_emission": 2014, - "latitude_degrees": 39.283, - "longitude_degrees": -76.616667, - "country": "USA", - "region": "North America", - "population_cdp": 614664, - "population_year_cdp": 2016 - }, - { - "val": 28, - "city_name": "Barreiro", - "city_name_cdp": "Barreiro", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 203441, - "year_of_emission": 2014, - "latitude_degrees": 38.667, - "longitude_degrees": -9.066667, - "country": "Portugal", - "region": "Europe", - "population_cdp": 78764, - "population_year_cdp": 2011 - }, - { - "val": 29, - "city_name": "Basel", - "city_name_cdp": "Basel-Stadt", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 783932, - "year_of_emission": 2016, - "latitude_degrees": 47.567, - "longitude_degrees": 7.6, - "country": "Switzerland", - "region": "Europe", - "population_cdp": 198206, - "population_year_cdp": 2016 - }, - { - "val": 30, - "city_name": "Batangas", - "city_name_cdp": "Batangas City", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 344419, - "year_of_emission": 2010, - "latitude_degrees": 13.83, - "longitude_degrees": 121, - "country": "Philippines", - "region": "Southeast Asia", - "population_cdp": 332458, - "population_year_cdp": 2015 - }, - { - "val": 32, - "city_name": "Belo Horizonte", - "city_name_cdp": "Municipality of Belo Horizonte", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2804787, - "year_of_emission": 2013, - "latitude_degrees": -19.917, - "longitude_degrees": -43.933333, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 2502557, - "population_year_cdp": 2015 - }, - { - "val": 38, - "city_name": "Blacksburg", - "city_name_cdp": "Town of Blacksburg", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 124461.79, - "year_of_emission": 2015, - "latitude_degrees": 37.23, - "longitude_degrees": -80.417778, - "country": "USA", - "region": "North America", - "population_cdp": 44215, - "population_year_cdp": 2015 - }, - { - "val": 39, - "city_name": "Bogor", - "city_name_cdp": "Bogor City Government", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 954020, - "year_of_emission": 2014, - "latitude_degrees": -6.597, - "longitude_degrees": 106.7972, - "country": "Indonesia", - "region": "Southeast Asia", - "population_cdp": 1047922, - "population_year_cdp": 2015 - }, - { - "val": 40, - "city_name": "Bogotá", - "city_name_cdp": "Bogotá Distrito Capital", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 10679585.14, - "year_of_emission": 2015, - "latitude_degrees": 4.711, - "longitude_degrees": -74.072222, - "country": "Colombia", - "region": "Latin America & Caribbean", - "population_cdp": 7878783, - "population_year_cdp": 2015 - }, - { - "val": 43, - "city_name": "Boston", - "city_name_cdp": "City of Boston", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3603270, - "year_of_emission": 2014, - "latitude_degrees": 42.358, - "longitude_degrees": -71.063611, - "country": "USA", - "region": "North America", - "population_cdp": 646000, - "population_year_cdp": 2013 - }, - { - "val": 44, - "city_name": "Boulder", - "city_name_cdp": "City of Boulder", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 741287, - "year_of_emission": 2012, - "latitude_degrees": 40.027, - "longitude_degrees": -105.251945, - "country": "USA", - "region": "North America", - "population_cdp": 104810, - "population_year_cdp": 2015 - }, - { - "val": 45, - "city_name": "Bournemouth", - "city_name_cdp": "City of Bournemouth", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 350775, - "year_of_emission": 2013, - "latitude_degrees": 50.72, - "longitude_degrees": -1.88, - "country": "United Kingdom", - "region": "Europe", - "population_cdp": 191400, - "population_year_cdp": 2015 - }, - { - "val": 46, - "city_name": "Brasília", - "city_name_cdp": "City of Brasília", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 7739830, - "year_of_emission": 2012, - "latitude_degrees": -15.79, - "longitude_degrees": -47.88, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 1409671, - "population_year_cdp": 2015 - }, - { - "val": 50, - "city_name": "Buenos Aires", - "city_name_cdp": "City of Buenos Aires", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 15561157, - "year_of_emission": 2014, - "latitude_degrees": -34.603, - "longitude_degrees": -58.381667, - "country": "Argentina", - "region": "Latin America & Caribbean", - "population_cdp": 3054267, - "population_year_cdp": 2015 - }, - { - "val": 52, - "city_name": "Burlington", - "city_name_cdp": "City of Burlington", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 368077, - "year_of_emission": 2010, - "latitude_degrees": 44.476, - "longitude_degrees": -73.211944, - "country": "USA", - "region": "North America", - "population_cdp": 42284, - "population_year_cdp": 2015 - }, - { - "val": 53, - "city_name": "Calgary", - "city_name_cdp": "City of Calgary", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 10448332, - "year_of_emission": 2015, - "latitude_degrees": 51.05, - "longitude_degrees": -114.066667, - "country": "Canada", - "region": "North America", - "population_cdp": 1203915, - "population_year_cdp": 2015 - }, - { - "val": 54, - "city_name": "Canberra", - "city_name_cdp": "Canberra", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1757500, - "year_of_emission": 2015, - "latitude_degrees": -35.307, - "longitude_degrees": 149.124417, - "country": "Australia", - "region": "Oceania", - "population_cdp": 400000, - "population_year_cdp": 2016 - }, - { - "val": 55, - "city_name": "Cape Town", - "city_name_cdp": "City of Cape Town", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 9783734, - "year_of_emission": 2012, - "latitude_degrees": -33.925, - "longitude_degrees": 18.423889, - "country": "South Africa", - "region": "Africa", - "population_cdp": 3918830, - "population_year_cdp": 2014 - }, - { - "val": 56, - "city_name": "Caracas", - "city_name_cdp": "Alcaldía Metropolitana de Caracas", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 14364103, - "year_of_emission": 2015, - "latitude_degrees": 10.481, - "longitude_degrees": -66.903611, - "country": "Venezuela", - "region": "Latin America & Caribbean", - "population_cdp": 3518590, - "population_year_cdp": 2015 - }, - { - "val": 58, - "city_name": "Cascais", - "city_name_cdp": "Cascais", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 565382, - "year_of_emission": 2010, - "latitude_degrees": 38.7, - "longitude_degrees": -9.416667, - "country": "Portugal", - "region": "Europe", - "population_cdp": 208122, - "population_year_cdp": 2014 - }, - { - "val": 63, - "city_name": "Chicago", - "city_name_cdp": "City of Chicago", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 16951471, - "year_of_emission": 2015, - "latitude_degrees": 41.837, - "longitude_degrees": -87.684722, - "country": "USA", - "region": "North America", - "population_cdp": 2720546, - "population_year_cdp": 2015 - }, - { - "val": 65, - "city_name": "Cleveland", - "city_name_cdp": "City of Cleveland", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 7750563, - "year_of_emission": 2010, - "latitude_degrees": 41.482, - "longitude_degrees": -81.669722, - "country": "USA", - "region": "North America", - "population_cdp": 396815, - "population_year_cdp": 2010 - }, - { - "val": 68, - "city_name": "Columbus", - "city_name_cdp": "City of Columbus", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 5487400, - "year_of_emission": 2015, - "latitude_degrees": 39.983, - "longitude_degrees": -82.983333, - "country": "USA", - "region": "North America", - "population_cdp": 835957, - "population_year_cdp": 2014 - }, - { - "val": 70, - "city_name": "Curitiba", - "city_name_cdp": "Municipality of Curitiba", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2686488, - "year_of_emission": 2013, - "latitude_degrees": -25.417, - "longitude_degrees": -49.25, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 1751907, - "population_year_cdp": 2010 - }, - { - "val": 72, - "city_name": "Dallas", - "city_name_cdp": "City of Dallas", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 119881, - "year_of_emission": 2010, - "latitude_degrees": 32.776, - "longitude_degrees": -96.796667, - "country": "USA", - "region": "North America", - "population_cdp": 1257676, - "population_year_cdp": 2013 - }, - { - "val": 76, - "city_name": "Davis, CA", - "city_name_cdp": "City of Davis, CA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 348437, - "year_of_emission": 2010, - "latitude_degrees": 38.554, - "longitude_degrees": -121.738056, - "country": "USA", - "region": "North America", - "population_cdp": 65600, - "population_year_cdp": 2010 - }, - { - "val": 78, - "city_name": "Denver", - "city_name_cdp": "City of Denver", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 4557000, - "year_of_emission": 2014, - "latitude_degrees": 39.762, - "longitude_degrees": -104.881105, - "country": "USA", - "region": "North America", - "population_cdp": 663862, - "population_year_cdp": 2014 - }, - { - "val": 79, - "city_name": "Detroit", - "city_name_cdp": "City of Detroit", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 5520240, - "year_of_emission": 2012, - "latitude_degrees": 42.331, - "longitude_degrees": -83.045833, - "country": "USA", - "region": "North America", - "population_cdp": 688701, - "population_year_cdp": 2013 - }, - { - "val": 80, - "city_name": "District of Columbia", - "city_name_cdp": "District of Columbia", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3132786, - "year_of_emission": 2013, - "latitude_degrees": 38.905, - "longitude_degrees": -77.016389, - "country": "USA", - "region": "North America", - "population_cdp": 672228, - "population_year_cdp": 2015 - }, - { - "val": 82, - "city_name": "Durban", - "city_name_cdp": "City of Durban", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 11681810, - "year_of_emission": 2014, - "latitude_degrees": -29.883, - "longitude_degrees": 31.05, - "country": "South Africa", - "region": "Africa", - "population_cdp": 3555868, - "population_year_cdp": 2015 - }, - { - "val": 83, - "city_name": "Durham", - "city_name_cdp": "City of Durham", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1973070, - "year_of_emission": 2015, - "latitude_degrees": 35.989, - "longitude_degrees": -78.907222, - "country": "USA", - "region": "North America", - "population_cdp": 250815, - "population_year_cdp": 2015 - }, - { - "val": 84, - "city_name": "Edmonton", - "city_name_cdp": "City of Edmonton", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 10215142, - "year_of_emission": 2014, - "latitude_degrees": 53.533, - "longitude_degrees": -113.5, - "country": "Canada", - "region": "North America", - "population_cdp": 878000, - "population_year_cdp": 2014 - }, - { - "val": 86, - "city_name": "Emeryville, CA", - "city_name_cdp": "City of Emeryville, CA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 127138, - "year_of_emission": 2014, - "latitude_degrees": 37.831, - "longitude_degrees": -122.285278, - "country": "USA", - "region": "North America", - "population_cdp": 10570, - "population_year_cdp": 2014 - }, - { - "val": 87, - "city_name": "Eugene", - "city_name_cdp": "City of Eugene", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1106250, - "year_of_emission": 2015, - "latitude_degrees": 44.052, - "longitude_degrees": -123.086667, - "country": "USA", - "region": "North America", - "population_cdp": 151190, - "population_year_cdp": 2013 - }, - { - "val": 88, - "city_name": "Faro", - "city_name_cdp": "Faro", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 128, - "year_of_emission": 2010, - "latitude_degrees": 37.033, - "longitude_degrees": -7.916667, - "country": "Portugal", - "region": "Europe", - "population_cdp": 61214, - "population_year_cdp": 2014 - }, - { - "val": 90, - "city_name": "Flagstaff", - "city_name_cdp": "City of Flagstaff", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 621293.07, - "year_of_emission": 2014, - "latitude_degrees": 35.199, - "longitude_degrees": -111.631111, - "country": "USA", - "region": "North America", - "population_cdp": 68667, - "population_year_cdp": 2013 - }, - { - "val": 91, - "city_name": "Florianópolis", - "city_name_cdp": "Prefeitura de Florianópolis", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1305206, - "year_of_emission": 2013, - "latitude_degrees": -27.572, - "longitude_degrees": -48.6256, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 550000, - "population_year_cdp": 2010 - }, - { - "val": 98, - "city_name": "Gladsaxe Kommune", - "city_name_cdp": "Gladsaxe Kommune", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 247599, - "year_of_emission": 2015, - "latitude_degrees": 55.733, - "longitude_degrees": 12.483333, - "country": "Denmark", - "region": "Europe", - "population_cdp": 67347, - "population_year_cdp": 2015 - }, - { - "val": 101, - "city_name": "Greater London", - "city_name_cdp": "Greater London Authority", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 20620000, - "year_of_emission": 2013, - "latitude_degrees": 51.507, - "longitude_degrees": -0.1275, - "country": "United Kingdom", - "region": "Europe", - "population_cdp": 8600000, - "population_year_cdp": 2015 - }, - { - "val": 110, - "city_name": "Hamilton, ON", - "city_name_cdp": "City of Hamilton", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6304593, - "year_of_emission": 2012, - "latitude_degrees": 43.25, - "longitude_degrees": -79.866667, - "country": "Canada", - "region": "North America", - "population_cdp": 519949, - "population_year_cdp": 2011 - }, - { - "val": 114, - "city_name": "Hayward", - "city_name_cdp": "City of Hayward", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 861854, - "year_of_emission": 2015, - "latitude_degrees": 37.669, - "longitude_degrees": -122.080796, - "country": "USA", - "region": "North America", - "population_cdp": 158985, - "population_year_cdp": 2015 - }, - { - "val": 119, - "city_name": "Helsinki", - "city_name_cdp": "City of Helsinki", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2096206, - "year_of_emission": 2014, - "latitude_degrees": 60.171, - "longitude_degrees": 24.9375, - "country": "Finland", - "region": "Europe", - "population_cdp": 612664, - "population_year_cdp": 2014 - }, - { - "val": 121, - "city_name": "Hermosa Beach, CA", - "city_name_cdp": "City of Hermosa Beach, CA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 123218, - "year_of_emission": 2012, - "latitude_degrees": 33.866, - "longitude_degrees": -118.399722, - "country": "USA", - "region": "North America", - "population_cdp": 19750, - "population_year_cdp": 2015 - }, - { - "val": 123, - "city_name": "Hjørring", - "city_name_cdp": "Municipality of Hjørring", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 289000, - "year_of_emission": 2014, - "latitude_degrees": 57.467, - "longitude_degrees": 9.983333, - "country": "Denmark", - "region": "Europe", - "population_cdp": 65308, - "population_year_cdp": 2016 - }, - { - "val": 124, - "city_name": "Hoeje-Taastrup Kommune", - "city_name_cdp": "Hoeje-Taastrup Kommune", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 173000, - "year_of_emission": 2014, - "latitude_degrees": 55.648, - "longitude_degrees": 12.27, - "country": "Denmark", - "region": "Europe", - "population_cdp": 50002, - "population_year_cdp": 2016 - }, - { - "val": 126, - "city_name": "Hong Kong", - "city_name_cdp": "Government of Hong Kong Special Administrative Region", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 44876460, - "year_of_emission": 2014, - "latitude_degrees": 22.3, - "longitude_degrees": 114.2, - "country": "China", - "region": "East Asia", - "population_cdp": 7336600, - "population_year_cdp": 2016 - }, - { - "val": 127, - "city_name": "Houston", - "city_name_cdp": "City of Houston", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 16075539, - "year_of_emission": 2014, - "latitude_degrees": 29.763, - "longitude_degrees": -95.383056, - "country": "USA", - "region": "North America", - "population_cdp": 2195914, - "population_year_cdp": 2013 - }, - { - "val": 133, - "city_name": "Incheon", - "city_name_cdp": "Incheon Metropolitan City", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 57719912, - "year_of_emission": 2015, - "latitude_degrees": 37.483, - "longitude_degrees": 126.633333, - "country": "South Korea", - "region": "East Asia", - "population_cdp": 2983484, - "population_year_cdp": 2015 - }, - { - "val": 134, - "city_name": "Indianapolis", - "city_name_cdp": "City of Indianapolis", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 726155.11, - "year_of_emission": 2013, - "latitude_degrees": 39.791, - "longitude_degrees": -86.148, - "country": "USA", - "region": "North America", - "population_cdp": 853000, - "population_year_cdp": 2015 - }, - { - "val": 136, - "city_name": "Iowa", - "city_name_cdp": "City of Iowa City", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 590282, - "year_of_emission": 2013, - "latitude_degrees": 41.66, - "longitude_degrees": -91.5342, - "country": "USA", - "region": "North America", - "population_cdp": 73415, - "population_year_cdp": 2015 - }, - { - "val": 149, - "city_name": "Johannesburg", - "city_name_cdp": "City of Johannesburg", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 9068358, - "year_of_emission": 2014, - "latitude_degrees": -26.204, - "longitude_degrees": 28.045556, - "country": "South Africa", - "region": "Africa", - "population_cdp": 4764381, - "population_year_cdp": 2015 - }, - { - "val": 150, - "city_name": "Kadiovacik", - "city_name_cdp": "Village of Kadiovacik", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 404.65, - "year_of_emission": 2015, - "latitude_degrees": 38.343, - "longitude_degrees": 26.553367, - "country": "Turkey", - "region": "North Africa, Middle East, West Asia", - "population_cdp": 216, - "population_year_cdp": 2016 - }, - { - "val": 152, - "city_name": "Kaohsiung", - "city_name_cdp": "Kaohsiung City Government", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 43502687.67, - "year_of_emission": 2014, - "latitude_degrees": 22.633, - "longitude_degrees": 120.266667, - "country": "Taiwan", - "region": "East Asia", - "population_cdp": 2778729, - "population_year_cdp": 2015 - }, - { - "val": 154, - "city_name": "Knoxville", - "city_name_cdp": "City of Knoxville", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2061435, - "year_of_emission": 2012, - "latitude_degrees": 35.973, - "longitude_degrees": -83.942222, - "country": "USA", - "region": "North America", - "population_cdp": 184281, - "population_year_cdp": 2014 - }, - { - "val": 158, - "city_name": "La Paz", - "city_name_cdp": "Municipalidad de La Paz", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1152922.4, - "year_of_emission": 2012, - "latitude_degrees": -16.5, - "longitude_degrees": -68.15, - "country": "Bolivia", - "region": "Latin America & Caribbean", - "population_cdp": 789541, - "population_year_cdp": 2015 - }, - { - "val": 159, - "city_name": "Lagos", - "city_name_cdp": "City of Lagos", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 29426266, - "year_of_emission": 2014, - "latitude_degrees": 6.455, - "longitude_degrees": 3.384082, - "country": "Nigeria", - "region": "Africa", - "population_cdp": 21000000, - "population_year_cdp": 2016 - }, - { - "val": 160, - "city_name": "Lahti", - "city_name_cdp": "City of Lahti", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 717200, - "year_of_emission": 2015, - "latitude_degrees": 60.983, - "longitude_degrees": 25.65, - "country": "Finland", - "region": "Europe", - "population_cdp": 119452, - "population_year_cdp": 2016 - }, - { - "val": 162, - "city_name": "Lakewood", - "city_name_cdp": "City of Lakewood", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 553900, - "year_of_emission": 2007, - "latitude_degrees": 39.705, - "longitude_degrees": -105.081389, - "country": "USA", - "region": "North America", - "population_cdp": 149643, - "population_year_cdp": 2014 - }, - { - "val": 164, - "city_name": "Lancaster, PA", - "city_name_cdp": "City of Lancaster, PA", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 364183, - "year_of_emission": 2016, - "latitude_degrees": 40.04, - "longitude_degrees": -76.304444, - "country": "USA", - "region": "North America", - "population_cdp": 60000, - "population_year_cdp": 2016 - }, - { - "val": 166, - "city_name": "Las Vegas", - "city_name_cdp": "City of Las Vegas", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 11002925, - "year_of_emission": 2014, - "latitude_degrees": 36.175, - "longitude_degrees": -115.136389, - "country": "USA", - "region": "North America", - "population_cdp": 621970, - "population_year_cdp": 2016 - }, - { - "val": 167, - "city_name": "Lausanne", - "city_name_cdp": "Ville de Lausanne", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 456843, - "year_of_emission": 2013, - "latitude_degrees": 46.52, - "longitude_degrees": 6.6335, - "country": "Switzerland", - "region": "Europe", - "population_cdp": 140000, - "population_year_cdp": 2015 - }, - { - "val": 171, - "city_name": "Lima", - "city_name_cdp": "Metropolitan Municipality of Lima", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 12378734, - "year_of_emission": 2012, - "latitude_degrees": -12.043, - "longitude_degrees": -77.028333, - "country": "Peru", - "region": "Latin America & Caribbean", - "population_cdp": 8755262, - "population_year_cdp": 2014 - }, - { - "val": 173, - "city_name": "Lisbon", - "city_name_cdp": "City of Lisbon", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1023910, - "year_of_emission": 2014, - "latitude_degrees": 38.714, - "longitude_degrees": -9.139444, - "country": "Portugal", - "region": "Europe", - "population_cdp": 547773, - "population_year_cdp": 2011 - }, - { - "val": 175, - "city_name": "Ljubljana", - "city_name_cdp": "City of Ljubljana", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 1829808, - "year_of_emission": 2014, - "latitude_degrees": 46.056, - "longitude_degrees": 14.508333, - "country": "Slovenia", - "region": "Europe", - "population_cdp": 288307, - "population_year_cdp": 2016 - }, - { - "val": 176, - "city_name": "London, ON", - "city_name_cdp": "City of London, ON", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2771000, - "year_of_emission": 2014, - "latitude_degrees": 42.984, - "longitude_degrees": -81.2497, - "country": "Canada", - "region": "North America", - "population_cdp": 375000, - "population_year_cdp": 2014 - }, - { - "val": 177, - "city_name": "Los Altos Hills", - "city_name_cdp": "Los Altos Hills", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 47552, - "year_of_emission": 2015, - "latitude_degrees": 37.371, - "longitude_degrees": -122.1375, - "country": "USA", - "region": "North America", - "population_cdp": 8334, - "population_year_cdp": 2013 - }, - { - "val": 178, - "city_name": "Los Angeles", - "city_name_cdp": "City of Los Angeles", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 19595119, - "year_of_emission": 2013, - "latitude_degrees": 34.05, - "longitude_degrees": -118.25, - "country": "USA", - "region": "North America", - "population_cdp": 3928864, - "population_year_cdp": 2014 - }, - { - "val": 181, - "city_name": "Madrid", - "city_name_cdp": "Ayuntamiento de Madrid", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6795577, - "year_of_emission": 2013, - "latitude_degrees": 40.383, - "longitude_degrees": -3.716667, - "country": "Spain", - "region": "Europe", - "population_cdp": 3156572, - "population_year_cdp": 2015 - }, - { - "val": 183, - "city_name": "Makati", - "city_name_cdp": "City Government of Makati", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 462586, - "year_of_emission": 2011, - "latitude_degrees": 14.55, - "longitude_degrees": 121.03, - "country": "Philippines", - "region": "Southeast Asia", - "population_cdp": 529039, - "population_year_cdp": 2010 - }, - { - "val": 185, - "city_name": "Manchester", - "city_name_cdp": "Greater Manchester", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 9587290, - "year_of_emission": 2013, - "latitude_degrees": 53.467, - "longitude_degrees": -2.233333, - "country": "United Kingdom", - "region": "Europe", - "population_cdp": 2762000, - "population_year_cdp": 2014 - }, - { - "val": 186, - "city_name": "Melbourne", - "city_name_cdp": "City of Melbourne", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 785326, - "year_of_emission": 2015, - "latitude_degrees": -37.814, - "longitude_degrees": 144.963056, - "country": "Australia", - "region": "Oceania", - "population_cdp": 137889, - "population_year_cdp": 2016 - }, - { - "val": 187, - "city_name": "Mexico City", - "city_name_cdp": "Mexico City", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 16842493.45, - "year_of_emission": 2014, - "latitude_degrees": 19.433, - "longitude_degrees": -99.133333, - "country": "Mexico", - "region": "Latin America & Caribbean", - "population_cdp": 8874724, - "population_year_cdp": 2014 - }, - { - "val": 188, - "city_name": "Milano", - "city_name_cdp": "Comune di Milano", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3728678, - "year_of_emission": 2013, - "latitude_degrees": 45.467, - "longitude_degrees": 9.183333, - "country": "Italy", - "region": "Europe", - "population_cdp": 1350680, - "population_year_cdp": 2014 - }, - { - "val": 189, - "city_name": "Minneapolis", - "city_name_cdp": "City of Minneapolis", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2890572, - "year_of_emission": 2014, - "latitude_degrees": 44.983, - "longitude_degrees": -93.266667, - "country": "USA", - "region": "North America", - "population_cdp": 407207, - "population_year_cdp": 2014 - }, - { - "val": 190, - "city_name": "Moita", - "city_name_cdp": "Município de Moita", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 49910, - "year_of_emission": 2013, - "latitude_degrees": 38.65, - "longitude_degrees": -8.983333, - "country": "Portugal", - "region": "Europe", - "population_cdp": 66029, - "population_year_cdp": 2011 - }, - { - "val": 191, - "city_name": "Montreal", - "city_name_cdp": "Ville de Montreal", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 13634331, - "year_of_emission": 2009, - "latitude_degrees": 45.5, - "longitude_degrees": -73.566667, - "country": "Canada", - "region": "North America", - "population_cdp": 1886481, - "population_year_cdp": 2011 - }, - { - "val": 195, - "city_name": "Nagoya", - "city_name_cdp": "City of Nagoya", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 7690000, - "year_of_emission": 2013, - "latitude_degrees": 35.183, - "longitude_degrees": 136.9, - "country": "Japan", - "region": "East Asia", - "population_cdp": 2274511, - "population_year_cdp": 2015 - }, - { - "val": 202, - "city_name": "Nashville and Davidson", - "city_name_cdp": "Metropolitan Government of Nashville and Davidson County", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 6680194, - "year_of_emission": 2014, - "latitude_degrees": 36.155, - "longitude_degrees": -86.761944, - "country": "USA", - "region": "North America", - "population_cdp": 678889, - "population_year_cdp": 2015 - }, - { - "val": 204, - "city_name": "New Orleans", - "city_name_cdp": "City of New Orleans", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2419891, - "year_of_emission": 2014, - "latitude_degrees": 29.95, - "longitude_degrees": -90.066667, - "country": "USA", - "region": "North America", - "population_cdp": 389617, - "population_year_cdp": 2015 - }, - { - "val": 205, - "city_name": "New Taipei", - "city_name_cdp": "New Taipei City Government", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6149934, - "year_of_emission": 2014, - "latitude_degrees": 25.011, - "longitude_degrees": 121.445833, - "country": "Taiwan", - "region": "East Asia", - "population_cdp": 3966818, - "population_year_cdp": 2014 - }, - { - "val": 206, - "city_name": "New York City", - "city_name_cdp": "New York City", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 38962264, - "year_of_emission": 2015, - "latitude_degrees": 40.713, - "longitude_degrees": -74.0059, - "country": "USA", - "region": "North America", - "population_cdp": 8537673, - "population_year_cdp": 2016 - }, - { - "val": 209, - "city_name": "North Vancouver", - "city_name_cdp": "City of North Vancouver", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 182896, - "year_of_emission": 2015, - "latitude_degrees": 49.317, - "longitude_degrees": -123.066667, - "country": "Canada", - "region": "North America", - "population_cdp": 52898, - "population_year_cdp": 2016 - }, - { - "val": 210, - "city_name": "Oakland", - "city_name_cdp": "City of Oakland", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 956414, - "year_of_emission": 2015, - "latitude_degrees": 37.804, - "longitude_degrees": -122.270833, - "country": "USA", - "region": "North America", - "population_cdp": 419000, - "population_year_cdp": 2015 - }, - { - "val": 211, - "city_name": "Okayama", - "city_name_cdp": "City of Okayama", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 114000, - "year_of_emission": 2013, - "latitude_degrees": 34.65, - "longitude_degrees": 133.916667, - "country": "Japan", - "region": "East Asia", - "population_cdp": 705917, - "population_year_cdp": 2015 - }, - { - "val": 213, - "city_name": "Oslo", - "city_name_cdp": "City of Oslo", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1094422, - "year_of_emission": 2013, - "latitude_degrees": 59.95, - "longitude_degrees": 10.75, - "country": "Norway", - "region": "Europe", - "population_cdp": 658390, - "population_year_cdp": 2016 - }, - { - "val": 214, - "city_name": "Palmas", - "city_name_cdp": "Prefeitura de Palmas", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 589055.31, - "year_of_emission": 2013, - "latitude_degrees": -10.184, - "longitude_degrees": -48.333611, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 272726, - "population_year_cdp": 2015 - }, - { - "val": 215, - "city_name": "Palo Alto", - "city_name_cdp": "City of Palo Alto", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 152631, - "year_of_emission": 2015, - "latitude_degrees": 37.429, - "longitude_degrees": -122.138056, - "country": "USA", - "region": "North America", - "population_cdp": 66955, - "population_year_cdp": 2015 - }, - { - "val": 216, - "city_name": "Paris", - "city_name_cdp": "City of Paris", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3359242, - "year_of_emission": 2014, - "latitude_degrees": 48.857, - "longitude_degrees": 2.3508, - "country": "France", - "region": "Europe", - "population_cdp": 2265886, - "population_year_cdp": 2015 - }, - { - "val": 219, - "city_name": "Philadelphia", - "city_name_cdp": "City of Philadelphia", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 12397594.06, - "year_of_emission": 2012, - "latitude_degrees": 39.95, - "longitude_degrees": -75.166667, - "country": "USA", - "region": "North America", - "population_cdp": 1560297, - "population_year_cdp": 2014 - }, - { - "val": 222, - "city_name": "Piedmont, CA", - "city_name_cdp": "City of Piedmont, CA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 17876, - "year_of_emission": 2011, - "latitude_degrees": 37.817, - "longitude_degrees": -122.233333, - "country": "USA", - "region": "North America", - "population_cdp": 11082, - "population_year_cdp": 2013 - }, - { - "val": 225, - "city_name": "Pingtung", - "city_name_cdp": "Pingtung County Government", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 2768427.4, - "year_of_emission": 2013, - "latitude_degrees": 22.675, - "longitude_degrees": 120.491414, - "country": "Taiwan", - "region": "East Asia", - "population_cdp": 835792, - "population_year_cdp": 2016 - }, - { - "val": 226, - "city_name": "Pittsburgh", - "city_name_cdp": "City of Pittsburgh", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2073556, - "year_of_emission": 2013, - "latitude_degrees": 40.44, - "longitude_degrees": -79.976389, - "country": "USA", - "region": "North America", - "population_cdp": 305704, - "population_year_cdp": 2016 - }, - { - "val": 227, - "city_name": "Portland, OR", - "city_name_cdp": "City of Portland, OR", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 4610317, - "year_of_emission": 2014, - "latitude_degrees": 45.52, - "longitude_degrees": -122.681944, - "country": "USA", - "region": "North America", - "population_cdp": 619360, - "population_year_cdp": 2014 - }, - { - "val": 230, - "city_name": "Pretoria Tshwane", - "city_name_cdp": "Pretoria - Tshwane", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 4648959, - "year_of_emission": 2015, - "latitude_degrees": -25.667, - "longitude_degrees": 28.333333, - "country": "South Africa", - "region": "Africa", - "population_cdp": 3200000, - "population_year_cdp": 2016 - }, - { - "val": 236, - "city_name": "Quito", - "city_name_cdp": "Distrito Metropolitano de Quito", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 4653611, - "year_of_emission": 2011, - "latitude_degrees": -0.217, - "longitude_degrees": -78.516667, - "country": "Ecuador", - "region": "Latin America & Caribbean", - "population_cdp": 2239191, - "population_year_cdp": 2010 - }, - { - "val": 238, - "city_name": "Ravenna", - "city_name_cdp": "Comune di Ravenna", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 11115, - "year_of_emission": 2014, - "latitude_degrees": 44.417, - "longitude_degrees": 12.2, - "country": "Italy", - "region": "Europe", - "population_cdp": 158911, - "population_year_cdp": 2015 - }, - { - "val": 239, - "city_name": "Recife", - "city_name_cdp": "Municipality of Recife", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 1333830, - "year_of_emission": 2015, - "latitude_degrees": -8.05, - "longitude_degrees": -34.9, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 1625583, - "population_year_cdp": 2016 - }, - { - "val": 240, - "city_name": "Reno", - "city_name_cdp": "City of Reno", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 1371400, - "year_of_emission": 2014, - "latitude_degrees": 39.527, - "longitude_degrees": -119.821944, - "country": "USA", - "region": "North America", - "population_cdp": 236995, - "population_year_cdp": 2014 - }, - { - "val": 241, - "city_name": "Reykjavík", - "city_name_cdp": "City of Reykjavík", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 346630, - "year_of_emission": 2013, - "latitude_degrees": 64.133, - "longitude_degrees": -21.933333, - "country": "Iceland", - "region": "Europe", - "population_cdp": 122460, - "population_year_cdp": 2015 - }, - { - "val": 242, - "city_name": "Richmond, VA", - "city_name_cdp": "City of Richmond, VA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1470127, - "year_of_emission": 2013, - "latitude_degrees": 37.533, - "longitude_degrees": -77.466667, - "country": "USA", - "region": "North America", - "population_cdp": 217853, - "population_year_cdp": 2014 - }, - { - "val": 243, - "city_name": "Rio de Janeiro", - "city_name_cdp": "Prefeitura do Rio de Janeiro", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 16171534, - "year_of_emission": 2012, - "latitude_degrees": -22.908, - "longitude_degrees": -43.196389, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 6476631, - "population_year_cdp": 2015 - }, - { - "val": 247, - "city_name": "Rotterdam", - "city_name_cdp": "Gemeente Rotterdam", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 17840039, - "year_of_emission": 2016, - "latitude_degrees": 51.917, - "longitude_degrees": 4.5, - "country": "Netherlands", - "region": "Europe", - "population_cdp": 624000, - "population_year_cdp": 2014 - }, - { - "val": 248, - "city_name": "Salvador", - "city_name_cdp": "City of Salvador", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3242166, - "year_of_emission": 2013, - "latitude_degrees": -12.975, - "longitude_degrees": -38.476667, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 2902927, - "population_year_cdp": 2014 - }, - { - "val": 249, - "city_name": "San Antonio", - "city_name_cdp": "City of San Antonio", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 7214051, - "year_of_emission": 2013, - "latitude_degrees": 29.417, - "longitude_degrees": -98.5, - "country": "USA", - "region": "North America", - "population_cdp": 1400000, - "population_year_cdp": 2012 - }, - { - "val": 252, - "city_name": "San Francisco", - "city_name_cdp": "City of San Francisco", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 4186111, - "year_of_emission": 2012, - "latitude_degrees": 37.783, - "longitude_degrees": -122.416667, - "country": "USA", - "region": "North America", - "population_cdp": 864816, - "population_year_cdp": 2015 - }, - { - "val": 254, - "city_name": "San Luis Potosí", - "city_name_cdp": "Ayuntamiento de San Luis Potosí", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1096122.89, - "year_of_emission": 2015, - "latitude_degrees": 22.151, - "longitude_degrees": -100.976111, - "country": "Mexico", - "region": "Latin America & Caribbean", - "population_cdp": 824229, - "population_year_cdp": 2015 - }, - { - "val": 255, - "city_name": "Santa Monica", - "city_name_cdp": "City of Santa Monica", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 119026, - "year_of_emission": 2015, - "latitude_degrees": 34.022, - "longitude_degrees": -118.481389, - "country": "USA", - "region": "North America", - "population_cdp": 92000, - "population_year_cdp": 2014 - }, - { - "val": 257, - "city_name": "Santarém", - "city_name_cdp": "Santarém", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 245483, - "year_of_emission": 2006, - "latitude_degrees": 39.233, - "longitude_degrees": -8.683333, - "country": "Portugal", - "region": "Europe", - "population_cdp": 61752, - "population_year_cdp": 2011 - }, - { - "val": 258, - "city_name": "Santiago", - "city_name_cdp": "Región Metropolitana de Santiago", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 23120027.8, - "year_of_emission": 2013, - "latitude_degrees": -33.45, - "longitude_degrees": -70.666667, - "country": "Chile", - "region": "Latin America & Caribbean", - "population_cdp": 7314176, - "population_year_cdp": 2015 - }, - { - "val": 260, - "city_name": "Santiago de Guayaquil", - "city_name_cdp": "Santiago de Guayaquil", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 5429899, - "year_of_emission": 2014, - "latitude_degrees": -2.183, - "longitude_degrees": -79.883333, - "country": "Ecuador", - "region": "Latin America & Caribbean", - "population_cdp": 2350915, - "population_year_cdp": 2010 - }, - { - "val": 263, - "city_name": "Savannah", - "city_name_cdp": "City of Savannah", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 2381327, - "year_of_emission": 2014, - "latitude_degrees": 32.017, - "longitude_degrees": -81.116667, - "country": "USA", - "region": "North America", - "population_cdp": 145674, - "population_year_cdp": 2015 - }, - { - "val": 264, - "city_name": "Seattle", - "city_name_cdp": "City of Seattle", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 5150000, - "year_of_emission": 2012, - "latitude_degrees": 47.61, - "longitude_degrees": -122.333056, - "country": "USA", - "region": "North America", - "population_cdp": 662400, - "population_year_cdp": 2015 - }, - { - "val": 268, - "city_name": "Seoul", - "city_name_cdp": "Seoul Metropolitan Government", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 25082520, - "year_of_emission": 2013, - "latitude_degrees": 37.567, - "longitude_degrees": 126.966667, - "country": "South Korea", - "region": "East Asia", - "population_cdp": 10297138, - "population_year_cdp": 2015 - }, - { - "val": 276, - "city_name": "Somerville, MA", - "city_name_cdp": "City of Somerville, MA", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 461798, - "year_of_emission": 2014, - "latitude_degrees": 42.388, - "longitude_degrees": -71.1, - "country": "USA", - "region": "North America", - "population_cdp": 78900, - "population_year_cdp": 2014 - }, - { - "val": 277, - "city_name": "Sorocaba", - "city_name_cdp": "Prefeitura de Sorocaba", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 980290, - "year_of_emission": 2012, - "latitude_degrees": -23.502, - "longitude_degrees": -47.458056, - "country": "Brazil", - "region": "Latin America & Caribbean", - "population_cdp": 644919, - "population_year_cdp": 2015 - }, - { - "val": 278, - "city_name": "St Louis", - "city_name_cdp": "City of St Louis", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2481945.42, - "year_of_emission": 2014, - "latitude_degrees": 38.627, - "longitude_degrees": -90.197778, - "country": "USA", - "region": "North America", - "population_cdp": 319294, - "population_year_cdp": 2010 - }, - { - "val": 279, - "city_name": "Stockholm", - "city_name_cdp": "City of Stockholm", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 1834343, - "year_of_emission": 2015, - "latitude_degrees": 59.329, - "longitude_degrees": 18.068611, - "country": "Sweden", - "region": "Europe", - "population_cdp": 923516, - "population_year_cdp": 2015 - }, - { - "val": 281, - "city_name": "Suwon", - "city_name_cdp": "Suwon City", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 3670140, - "year_of_emission": 2013, - "latitude_degrees": 37.267, - "longitude_degrees": 127.016667, - "country": "South Korea", - "region": "East Asia", - "population_cdp": 1221973, - "population_year_cdp": 2015 - }, - { - "val": 283, - "city_name": "Sydney", - "city_name_cdp": "City of Sydney", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 359064, - "year_of_emission": 2015, - "latitude_degrees": -33.865, - "longitude_degrees": 151.209444, - "country": "Australia", - "region": "Oceania", - "population_cdp": 205339, - "population_year_cdp": 2015 - }, - { - "val": 285, - "city_name": "Taipei City", - "city_name_cdp": "Taipei City Government", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6493593, - "year_of_emission": 2014, - "latitude_degrees": 25.033, - "longitude_degrees": 121.633333, - "country": "Taiwan", - "region": "East Asia", - "population_cdp": 2704810, - "population_year_cdp": 2015 - }, - { - "val": 288, - "city_name": "Taoyuan", - "city_name_cdp": "Taoyuan City Hall", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 21143194.6, - "year_of_emission": 2014, - "latitude_degrees": 24.991, - "longitude_degrees": 121.314328, - "country": "Taiwan", - "region": "East Asia", - "population_cdp": 2153521, - "population_year_cdp": 2017 - }, - { - "val": 291, - "city_name": "Tokyo", - "city_name_cdp": "Tokyo Metropolitan Government", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 27611000, - "year_of_emission": 2014, - "latitude_degrees": 35.683, - "longitude_degrees": 139.683333, - "country": "Japan", - "region": "East Asia", - "population_cdp": 13513734, - "population_year_cdp": 2015 - }, - { - "val": 294, - "city_name": "Toronto", - "city_name_cdp": "City of Toronto", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 16151019, - "year_of_emission": 2013, - "latitude_degrees": 43.7, - "longitude_degrees": -79.4, - "country": "Canada", - "region": "North America", - "population_cdp": 2753100, - "population_year_cdp": 2011 - }, - { - "val": 296, - "city_name": "Tucson", - "city_name_cdp": "City of Tucson", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2571089, - "year_of_emission": 2012, - "latitude_degrees": 32.222, - "longitude_degrees": -110.926389, - "country": "USA", - "region": "North America", - "population_cdp": 529845, - "population_year_cdp": 2015 - }, - { - "val": 297, - "city_name": "Turku", - "city_name_cdp": "City of Turku", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 421200, - "year_of_emission": 2013, - "latitude_degrees": 60.45, - "longitude_degrees": 22.266667, - "country": "Finland", - "region": "Europe", - "population_cdp": 186000, - "population_year_cdp": 2015 - }, - { - "val": 300, - "city_name": "Udine", - "city_name_cdp": "Comune di Udine", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 438005, - "year_of_emission": 2013, - "latitude_degrees": 46.067, - "longitude_degrees": 13.233333, - "country": "Italy", - "region": "Europe", - "population_cdp": 99528, - "population_year_cdp": 2013 - }, - { - "val": 302, - "city_name": "University City, MO", - "city_name_cdp": "University City, MO", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 266265, - "year_of_emission": 2005, - "latitude_degrees": 38.664, - "longitude_degrees": -90.327778, - "country": "USA", - "region": "North America", - "population_cdp": 35371, - "population_year_cdp": 2010 - }, - { - "val": 305, - "city_name": "Vancouver", - "city_name_cdp": "City of Vancouver", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2389748, - "year_of_emission": 2014, - "latitude_degrees": 49.25, - "longitude_degrees": -123.1, - "country": "Canada", - "region": "North America", - "population_cdp": 603500, - "population_year_cdp": 2011 - }, - { - "val": 306, - "city_name": "Venezia", - "city_name_cdp": "Comune di Venezia", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 955471, - "year_of_emission": 2005, - "latitude_degrees": 45.438, - "longitude_degrees": 12.335833, - "country": "Italy", - "region": "Europe", - "population_cdp": 263104, - "population_year_cdp": 2016 - }, - { - "val": 307, - "city_name": "Vilnius", - "city_name_cdp": "Vilnius City Municipality", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1994560, - "year_of_emission": 2013, - "latitude_degrees": 54.683, - "longitude_degrees": 25.283333, - "country": "Lithuania", - "region": "Europe", - "population_cdp": 542626, - "population_year_cdp": 2015 - }, - { - "val": 309, - "city_name": "Warsaw", - "city_name_cdp": "City of Warsaw", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 7930452, - "year_of_emission": 2014, - "latitude_degrees": 52.233, - "longitude_degrees": 21.016667, - "country": "Poland", - "region": "Europe", - "population_cdp": 1626514, - "population_year_cdp": 2016 - }, - { - "val": 311, - "city_name": "Wellington", - "city_name_cdp": "Wellington City Council", - "reporting_year_cdp": 2017, - "scope1_ghg_emissions_tons_co2e": 621179, - "year_of_emission": 2014, - "latitude_degrees": -41.289, - "longitude_degrees": 174.777222, - "country": "New Zealand", - "region": "Oceania", - "population_cdp": 209102, - "population_year_cdp": 2017 - }, - { - "val": 314, - "city_name": "Windsor, ON", - "city_name_cdp": "City of Windsor", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 2475703, - "year_of_emission": 2014, - "latitude_degrees": 42.283, - "longitude_degrees": -83, - "country": "Canada", - "region": "North America", - "population_cdp": 210891, - "population_year_cdp": 2011 - }, - { - "val": 315, - "city_name": "Winnipeg", - "city_name_cdp": "City of Winnipeg", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 5167453, - "year_of_emission": 1998, - "latitude_degrees": 49.899, - "longitude_degrees": -97.139167, - "country": "Canada", - "region": "North America", - "population_cdp": 718400, - "population_year_cdp": 2015 - }, - { - "val": 327, - "city_name": "Yilan", - "city_name_cdp": "Yilan County", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 6911264.55, - "year_of_emission": 2013, - "latitude_degrees": 24.751, - "longitude_degrees": 121.759167, - "country": "Taiwan", - "region": "East Asia", - "population_cdp": 458777, - "population_year_cdp": 2014 - }, - { - "val": 329, - "city_name": "Yokohama", - "city_name_cdp": "City of Yokohama", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 12572000, - "year_of_emission": 2013, - "latitude_degrees": 35.444, - "longitude_degrees": 139.638056, - "country": "Japan", - "region": "East Asia", - "population_cdp": 3719589, - "population_year_cdp": 2015 - }, - { - "val": 330, - "city_name": "Yonkers", - "city_name_cdp": "City of Yonkers", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 982940, - "year_of_emission": 2010, - "latitude_degrees": 40.941, - "longitude_degrees": -73.864444, - "country": "USA", - "region": "North America", - "population_cdp": 199766, - "population_year_cdp": 2013 - }, - { - "val": 331, - "city_name": "Zaragoza", - "city_name_cdp": "City of Zaragoza", - "reporting_year_cdp": 2016, - "scope1_ghg_emissions_tons_co2e": 1175162.74, - "year_of_emission": 2014, - "latitude_degrees": 41.65, - "longitude_degrees": -0.883333, - "country": "Spain", - "region": "Europe", - "population_cdp": 661108, - "population_year_cdp": 2015 - } - ] -} \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/index.html b/p5js/NeuralNetwork/NeuralNetwork_co2net-training/index.html deleted file mode 100755 index d3da7309..00000000 --- a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - co2Net - Neural Network - - - - - - - - - -

co2Net - Neural Network

-

Urban Population vs. CO2 Emissions

-

Population and CO2 emissions (in tons of CO2 or CO2 equivalent) are log10 transformed for this analysis.

- data: https://doi.pangaea.de/10.1594/PANGAEA.884141 -
-
-
-
predictions
-
-
-
-
actual
-
-
- - - - \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_co2net-training/sketch.js deleted file mode 100644 index 01e6bb7b..00000000 --- a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/sketch.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) 2018 ml5 -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - -/* === -ml5 Example -Image classification using MobileNet and p5.js -This example uses a callback pattern to create the classifier -// x: population_cdp -// y: scope1_ghg_emissions_tons_co2e -=== */ -let nn; -let data; - -let inputMeta; -let outputMeta; - -// Options for Neural Network -const options = { - inputs: ['population_cdp'], - outputs: ['scope1_ghg_emissions_tons_co2e'], - dataUrl:'data/co2stats.csv', - task:'regression', - debug: true -}; - - -function setup() { - createCanvas(400, 400); - // background(0, 27, 68); - background(244, 244, 244); - - // Step 1: Create Neural Network - nn = ml5.neuralNetwork(options, modelLoaded); - -} - -function modelLoaded(){ - console.log(nn.data); - // co2 data and population can be log10 transformed - // nn.data.data = nn.data.data.map( item => { - // item.xs.population_cdp = Math.log10(item.xs.population_cdp) - // item.ys.scope1_ghg_emissions_tons_co2e = Math.log10(item.ys.scope1_ghg_emissions_tons_co2e) - // return item; - // }) - nn.data.normalize(); - - const trainingOptions = { - epochs: 50, - batchSize:24 - } - nn.train(trainingOptions, finishedTraining) -} - -async function finishedTraining(){ - inputMeta = nn.data.meta.inputTypes[0] - outputMeta = nn.data.meta.outputTypes[0] - - nn.data.data.forEach( item => { - const normx = map(item.xs.population_cdp, inputMeta.min, inputMeta.max, 0, width); - const normy = map(item.ys.scope1_ghg_emissions_tons_co2e, outputMeta.min, outputMeta.max, height, 0); - fill(0,255,255); - ellipse(normx, normy, 4, 4); - }) - - await Promise.all( - [ - 100, - 50000, - 100000, - 500000, - 2500000, - 5000000, - 10000000, - 15000000, - ].map( (val, idx) => predict(val) ) - ) - - -} - -async function predict(val){ - // const input = Math.log10(val); - const input = val - const prediction = await nn.predict([input]); - const output = {x: val, y: prediction.outputs.value} - const x = map(output.x, inputMeta.min, inputMeta.max, 0, width); - const y = map(output.y, outputMeta.min, outputMeta.max, height, 0); - - - rectMode(CENTER); - fill(255,0,0); - rect(x, y, 6, 6); - text(`pop:${output.x}`, x, y) - text(`tons_co2e:${output.y}`, x, y+10) - - -} - - diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net-training/data/co2stats.csv b/p5js/NeuralNetwork/NeuralNetwork_co2net/data/co2stats.csv similarity index 100% rename from p5js/NeuralNetwork/NeuralNetwork_co2net-training/data/co2stats.csv rename to p5js/NeuralNetwork/NeuralNetwork_co2net/data/co2stats.csv diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.json b/p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.json deleted file mode 100644 index 74188fe9..00000000 --- a/p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.json +++ /dev/null @@ -1 +0,0 @@ -{"modelTopology":{"class_name":"Sequential","config":[{"class_name":"Dense","config":{"units":1,"activation":"sigmoid","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense1","trainable":true,"batch_input_shape":[null,1],"dtype":"float32"}},{"class_name":"Dense","config":{"units":1,"activation":"sigmoid","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense2","trainable":true}}],"keras_version":"tfjs-layers 1.1.2","backend":"tensor_flow.js"},"weightsManifest":[{"paths":["./model.weights.bin"],"weights":[{"name":"dense_Dense1/kernel","shape":[1,1],"dtype":"float32"},{"name":"dense_Dense1/bias","shape":[1],"dtype":"float32"},{"name":"dense_Dense2/kernel","shape":[1,1],"dtype":"float32"},{"name":"dense_Dense2/bias","shape":[1],"dtype":"float32"}]}]} \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.weights.bin b/p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.weights.bin deleted file mode 100644 index 07b6db8a..00000000 --- a/p5js/NeuralNetwork/NeuralNetwork_co2net/model/model.weights.bin +++ /dev/null @@ -1 +0,0 @@ -Öõz@ÙÀ"À_`œ@!@À¿ \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_co2net/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_co2net/sketch.js index 243c8121..02f2e1a1 100644 --- a/p5js/NeuralNetwork/NeuralNetwork_co2net/sketch.js +++ b/p5js/NeuralNetwork/NeuralNetwork_co2net/sketch.js @@ -10,21 +10,21 @@ This example uses a callback pattern to create the classifier // x: population_cdp // y: scope1_ghg_emissions_tons_co2e === */ -let neuralNetwork; +let nn; let data; -let predictions = []; -const margins = 40; + +let inputMeta; +let outputMeta; // Options for Neural Network const options = { - input: 1, - output: 1, - // activation: 'sig' + inputs: ['population_cdp'], + outputs: ['scope1_ghg_emissions_tons_co2e'], + dataUrl:'data/co2stats.csv', + task:'regression', + debug: true }; -function preload(){ - data = loadJSON('data/co2stats.json') -} function setup() { createCanvas(400, 400); @@ -32,209 +32,74 @@ function setup() { background(244, 244, 244); // Step 1: Create Neural Network - neuralNetwork = ml5.neuralNetwork(options); - - // Step 2: Prepare the data - prepData() - - // Step 3: inspect the data - inspectData(data.normalized_input, data.normalized_target); - - // Step 4A: Inspect the data - // trainModel() - - // Step 4B: Load a pre-trained model - // visualize the predictions; - // the population input needs to be log10 transformed - neuralNetwork.load('model/model.json', function() { - console.log('model loaded') - - for(let i = 500; i < 10000000; i*=2){ - predict(Math.log10(i)); - } - // vancouver - predict(Math.log10(603500)); - // NYC - predict(Math.log10(8537673)); - }); + nn = ml5.neuralNetwork(options, modelLoaded); } -// Inspect the input data -function inspectData(_x, _y){ - fill(204, 204, 204); - stroke(0, 27, 68); - for(let i = 0; i < _x.length; i++){ - const xData = _x[i]; - const yData = _y[i]; - const x = mapToCanvas(xData, margins, width - margins) - const y = mapToCanvas(yData, height - margins, margins); - ellipse(x, y, 10, 10) +function modelLoaded(){ + // console.log(nn.data.data.raw); + // co2 data and population can be log10 transformed + // nn.data.data = nn.data.data.map( item => { + // item.xs.population_cdp = Math.log10(item.xs.population_cdp) + // item.ys.scope1_ghg_emissions_tons_co2e = Math.log10(item.ys.scope1_ghg_emissions_tons_co2e) + // return item; + // }) + nn.normalizeData(); + + const trainingOptions = { + epochs: 50, + batchSize:12 } - - // create axes - createAxes(); - + nn.train(trainingOptions, finishedTraining) } -function createAxes(){ - // y - stroke(0); - line(margins, margins, margins, height - margins); - // x - stroke(0); - line(margins, height - margins, width - margins, height - margins); +async function finishedTraining(){ + inputMin = nn.data.data.inputMin; + inputMax = nn.data.data.inputMax; + outputMin = nn.data.data.outputMin; + outputMax = nn.data.data.outputMax; - fill(0) - for(let i = 0.1; i <= 1; i+=0.1){ - push() - const x = mapToCanvas(i, margins, width - margins) - const y = height - margins; - translate(x, y); - rotate(radians(-90)); - stroke(0); - line(0,0, 10, 0); - // rotate(radians(90)); - textAlign(RIGHT) - const val = nfc(unNormalize(i, data.stats.x_min, data.stats.x_max), 1) - noStroke(); - text( val, -2, 4) - pop(); - } - for(let i = 0.1; i <= 1; i+=0.1){ - push() - const x = margins; - const y = mapToCanvas(i, height-margins, margins) - translate(x, y); - stroke(0); - line(0,0, 10, 0); - // rotate(radians(90)); - textAlign(RIGHT) - const val = nfc(unNormalize(i, data.stats.y_min, data.stats.y_max), 1) - noStroke(); - text( val, -2, 4) - pop(); - } -} - -// Train the model -function trainModel() { - // Add training data - // push x and y values - for(let i = 0; i < data.training_input.length; i++){ - const xs = data.normalized_input[i]; - const ys = data.normalized_target[i]; - neuralNetwork.addData([xs],[ys]); - } - // Train - neuralNetwork.train(4000, whileTraining); -} + nn.data.data.raw.forEach( item => { + const normx = map(item.xs.population_cdp, inputMin[0], inputMax[0], 0, width); + const normy = map(item.ys.scope1_ghg_emissions_tons_co2e, outputMin[0], outputMax[0], height, 0); + fill(0,255,255); + ellipse(normx, normy, 4, 4); + }) -// Training callback -function whileTraining(error, progress) { - if (progress.status == 'training') { - console.log(progress.epoch, progress.loss); - } else if (progress.status == 'complete') { - // Run prediction when complete + await Promise.all( + [ + 100, + 50000, + 100000, + 500000, + 2500000, + 5000000, + 10000000, + 15000000, + ].map( (val, idx) => predict(val) ) + ) - for(let i = 10000; i < 10000000; i*=2){ - predict(Math.log10(i)); - } - } -} - -function predict(val) { - let input = [val]; - input = normalizeArray(input, data.stats.x_max, data.stats.x_min) - neuralNetwork.predict(input, (err, results) => { - const x = mapToCanvas(input[0], margins, width - margins ); - const y = mapToCanvas(results.output[0], height - margins, margins); - predictions.push({x, y,}); - - const xUnorm = Math.pow(10,val); - const yUnorm = Math.pow(10, unNormalize(results.output[0],data.stats.y_min, data.stats.y_max )) - console.log(`pop:${xUnorm}, emissions:${yUnorm}`) - - displayPredictions(x, y); - - }); -} - - -// show the fitting points -function displayPredictions(_x, _y){ - // show points - fill(213, 0, 143); - stroke(255, 128, 204); - rectMode(CENTER); - rect(_x, _y, 10, 10) } -function showFit(){ - if(predictions.length > 2){ - noFill(); - stroke(255, 0, 0); - beginShape(); - predictions.forEach(item => { - vertex(item.x, item.y) - }) - endShape(); - } -} +async function predict(val){ + // const input = Math.log10(val); + const input = val + const prediction = await nn.predict([input]); + const output = {x: val, y: prediction[0].value} + const x = map(output.x, inputMin[0], inputMax[0], 0, width); + const y = map(output.y, outputMin[0], outputMax[0], height, 0); + console.log(output) -// Normalize the array -function normalizeArray(_arr, _min, _max){ - const output = _arr.map(item => { - return normalize(item, _max, _min) - }) - - return output -} + rectMode(CENTER); + fill(255,0,0); + rect(x, y, 6, 6); + text(`pop:${output.x}`, x, y) + text(`tons_co2e:${output.y}`, x, y+10) -// Normalize value -function normalize(_item, _min, _max){ - return (_item - _min) / (_max - _min) + } -// UnNormalize the value -function unNormalize(_item, _min, _max){ - return (_item * (_max - _min)) + _min; -} - -// Translate normalized data to canvas -function mapToCanvas(_val, _min, _max){ - return map(_val, 0, 1, _min, _max); -} - - -// Prepare the data -function prepData(){ - // get the data array - const stats = data.data; - - // store the x and y stats - data.stats = { - x_max:null, - x_min:null, - y_max:null, - y_min:null - } - - // step 1: add data to the training input - data.training_input = stats.map(item => Math.log10(item.population_cdp)) - data.training_target = stats.map(item => Math.log10(item.scope1_ghg_emissions_tons_co2e)) - - // step 2: get the min and max for x and y - data.stats.x_max = max(data.training_input) - data.stats.x_min = min(data.training_input) - data.stats.y_max = max(data.training_target) - data.stats.y_min = min(data.training_target) - - // step 3: get the normalized values - data.normalized_input = normalizeArray(data.training_input, data.stats.x_max, data.stats.x_min) - data.normalized_target = normalizeArray(data.training_target, data.stats.y_max, data.stats.y_min) -} \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_color_classifier/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_color_classifier/sketch.js index 591ecc1f..988beac4 100644 --- a/p5js/NeuralNetwork/NeuralNetwork_color_classifier/sketch.js +++ b/p5js/NeuralNetwork/NeuralNetwork_color_classifier/sketch.js @@ -28,7 +28,7 @@ function setup() { } function modelReady() { - neuralNetwork.data.normalize(); + neuralNetwork.normalizeData(); const trainingOptions = { epochs: 20, batchSize: 64 diff --git a/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/index.html b/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/index.html new file mode 100755 index 00000000..c76027ae --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/index.html @@ -0,0 +1,27 @@ + + + + + Neural Network Sound Player + + + + + + + + +

Pixel Prediction

+ + +

+ Training frequency: + +

+

+ + Frequency prediction: +

+ + + \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/sketch.js new file mode 100644 index 00000000..24288100 --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_lowres_pixels/sketch.js @@ -0,0 +1,119 @@ + + +let pixelBrain; +let video; +let ready = false; +let w; +let playing = false; +let frequency; +let osc; + +function setup() { + createCanvas(200, 200); + video = createCapture(VIDEO, videoReady); + let res = 10; + video.size(res, res); + video.hide(); + let totalPixels = res * res * 3; + const options = { + inputs: totalPixels, + outputs: 1, + hiddenUnits: floor(totalPixels / 2), + normalizationOptions: { + inputMin: [...new Array(totalPixels).fill(0)], + inputMax: [...new Array(totalPixels).fill(255)] + }, + // activationHidden: 'relu', + learningRate: 0.01, + debug: true, + } + pixelBrain = ml5.neuralNetwork(options); + select('#addExample').mousePressed(addExample); + select('#train').mousePressed(trainModel); + w = width / res; + osc = new p5.Oscillator(); + osc.setType('sine'); + osc.amp(0.5); + osc.freq(440); +} + +function videoReady() { + ready = true; +} + +function draw() { + background(0); + if (ready) { + video.loadPixels(); + for (let x = 0; x < video.width; x++) { + for (let y = 0; y < video.height; y++) { + let index = (x + y * video.width) * 4; + let r = video.pixels[index + 0]; + let g = video.pixels[index + 1]; + let b = video.pixels[index + 2]; + noStroke(); + fill(r, g, b); + rect(x * w, y * w, w, w); + } + } + } + +} + +function getInputs() { + video.loadPixels(); + let inputs = []; + for (let i = 0; i < video.width * video.height; i++) { + let index = i * 4; + inputs.push(video.pixels[index + 0]); + inputs.push(video.pixels[index + 1]); + inputs.push(video.pixels[index + 2]); + } + return inputs; +} + +let firstTime = true; +function addExample() { + if (firstTime) { + osc.start(); + firstTime = false; + } + + let freq = select('#frequency').value(); + osc.freq(parseFloat(freq)); + video.loadPixels(); + let inputs = getInputs(); + pixelBrain.addData(inputs, [parseFloat(freq)]); +} + +function trainModel() { + osc.amp(0); + pixelBrain.normalizeData(); + const trainingOptions = { + epochs: 50 + } + pixelBrain.train(trainingOptions, finishedTraining); +} + +function finishedTraining() { + console.log('done'); + osc.amp(0.5); + predict(); +} + +function predict() { + let inputs = getInputs(); + pixelBrain.predict(inputs, gotFrequency); +} + +function gotFrequency(error, results) { + if (error) { + console.error(error); + } else { + frequency = parseFloat(results[0].value); + select('#prediction').html(frequency.toFixed(2)); + osc.freq(parseFloat(frequency)); + predict(); + } +} + diff --git a/p5js/NeuralNetwork/NeuralNetwork_multiple-layers/index.html b/p5js/NeuralNetwork/NeuralNetwork_multiple-layers/index.html new file mode 100644 index 00000000..98213dfd --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_multiple-layers/index.html @@ -0,0 +1,18 @@ + + + + + Neural network with custom architecture + + + + + + + + +

Neural network with custom architecture

+ + + + \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_multiple-layers/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_multiple-layers/sketch.js new file mode 100644 index 00000000..57aa66d1 --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_multiple-layers/sketch.js @@ -0,0 +1,72 @@ +let nn; +const nn_options = { + inputs: 1, + outputs: 1, + layers: [ + ml5.tf.layers.dense({ + units: 16, + inputShape: [1], + activation: 'relu', + }), + ml5.tf.layers.dense({ + units: 16, + inputShape: [1], + activation: 'sigmoid', + }), + ml5.tf.layers.dense({ + units: 1, + activation: 'sigmoid', + }) + ], + debug: true +} + +function setup() { + createCanvas(400, 400); + background(240); + nn = ml5.neuralNetwork(nn_options); + console.log(nn); + createTrainingData(); + + nn.normalizeData(); + const train_options = { + epochs: 32 + } + nn.train(train_options, finishedTraining); +} + +function finishedTraining(){ + + nn.predict([10], function(err, result){ + if(err){ + console.log(err); + return + } + console.log(result) + }) + + nn.predict([390], function(err, result){ + if(err){ + console.log(err); + return + } + console.log(result) + }) +} + +function createTrainingData(){ + for(let i = 0; i < 400; i++){ + if(i%2){ + const x = floor(random(0, width/2)); + nn.addData([x], [0]) + }else { + const x = floor(random(width/2, width)); + nn.addData([x], [1]) + } + } + +} + +// function draw(){ + +// } \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_musical_mouse/index.html b/p5js/NeuralNetwork/NeuralNetwork_musical_mouse/index.html new file mode 100755 index 00000000..1e3de00a --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_musical_mouse/index.html @@ -0,0 +1,31 @@ + + + + + Neural Network Sound Player + + + + + + + + +

Neural Network Sound Player

+ + +

+ Training frequency: + +

+

+ Frequency prediction: +

+ +

+ Click in canvas to add training data. +

+ + + + \ No newline at end of file diff --git a/p5js/NeuralNetwork/NeuralNetwork_musical_mouse/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_musical_mouse/sketch.js new file mode 100644 index 00000000..d25b3cf6 --- /dev/null +++ b/p5js/NeuralNetwork/NeuralNetwork_musical_mouse/sketch.js @@ -0,0 +1,62 @@ +let notePlayer; +let playing = false; +let frequency; +let osc; + +function setup() { + createCanvas(400, 400).mousePressed(addData);; + const options = { + inputs: 2, // what about allowing ['x', 'y']? + outputs: 1, // what about allowing ['x', 'y']? + debug: true, + } + background(0); + notePlayer = ml5.neuralNetwork(options); + select('#train').mousePressed(trainModel); +} + +function addData() { + + let freq = select('#frequency').value(); + stroke(255); + noFill(); + ellipse(mouseX, mouseY, 32); + fill(255); + textSize(16); + console.log(freq); + textAlign(CENTER, CENTER); + text(freq, mouseX, mouseY); + notePlayer.data.addData([mouseX, mouseY], [parseFloat(freq)]); +} + +function trainModel() { + notePlayer.normalizeData(); + const trainingOptions = { + batchSize: 24, + epochs: 20 + } + notePlayer.train(trainingOptions, finishedTraining); +} + +function finishedTraining() { + console.log('done'); + osc = new p5.Oscillator(); + osc.setType('sine'); + osc.amp(0.5); + osc.freq(440); + osc.start(); + notePlayer.predict([mouseX, mouseY], gotFrequency); +} + +function gotFrequency(error, results) { + if (error) { + console.error(error); + } else { + frequency = parseFloat(results[0].value); + console.log(results); + select('#prediction').html(frequency.toFixed(2)); + osc.freq(parseFloat(frequency)); + notePlayer.predict([mouseX, mouseY], gotFrequency); + } +} + diff --git a/p5js/NeuralNetwork/NeuralNetwork_titanic/sketch.js b/p5js/NeuralNetwork/NeuralNetwork_titanic/sketch.js index 075a121a..7661652d 100644 --- a/p5js/NeuralNetwork/NeuralNetwork_titanic/sketch.js +++ b/p5js/NeuralNetwork/NeuralNetwork_titanic/sketch.js @@ -6,7 +6,7 @@ function setup() { let nnOptions = { dataUrl: 'data/titanic_cleaned.csv', - inputs: ['fare_class', 'sex', 'age', 'fare'], + inputs: ['fare_class','sex', 'age', 'fare'], outputs: ['survived'], task: 'classification', debug: true @@ -19,7 +19,7 @@ function setup() { } function modelReady() { - neuralNetwork.data.normalize(); + neuralNetwork.normalizeData(); neuralNetwork.train({ epochs: 50 }, whileTraining, finishedTraining); }