Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Challenge Week 10 #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 43 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,150 @@
# Name

write-your-name
Daniel Nolan

# How many points have you earned?

0/100
100/100

(Make your own calculation and replace the number 0 with the points you think you've earned.)

# How many hours have you spent on this?

fill-in-your-answer
6

# When did you first start working on this week's learning challenges?

fill-in-your-answer
Late Saturday night

# What is the most difficult part about this week's challenge?

fill-in-your-answer
So far, getting the mongoimport to work on my Terminal because I keep coming up with a Syntax error.

# Show and tell (6 points)

## Link (2 points)

[title-of-the-article](http://link-to-an-interesting-D3-visualization-example)
[Airports in the US + Voronoi Diagram](http://mbostock.github.io/d3/talk/20111116/airports.html)

## Write down TWO D3 features you’d like to learn next . (4 points)

fill-in-your-answer
If it is possible, it would be really interesting to learn things that might be more dynamic in D3 relative to sensing and sound encoding.

Creating visual effects and more design-oriented things other than bar graphs.

Things that are very vital for internship/job market use. This would obviously be things that would give employers something that strikes their fancy.

# MongoDB III

## Checkpoints (4 points x 1 = 4 points)

# 1. (4 points)

![image](image.png?raw=true)
![image](http://i.imgur.com/UfDyTH2.png)

## Challenges (5 points x 5 = 25 points)

# 1. (5 points)

> db.aiddata.[complete this query]
> db.aiddata.find({ 'donor':'Belgium', 'disbursement_amount':{ $gt:0 }}, { '_id':1, 'recipient':1, 'disbursement_amount':1 });

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/OzNnkNx.png)

# 2. (5 points)

> db.aiddata.[complete this query]
> db.aiddata.find({ 'biodiversity':{$gt:0}}, { '_id':1, 'recipient':1, 'title':1 });

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/KtiaEXr.png)

# 3. (5 points)

> db.[complete this query]
> db.runCommand({distinct:'aiddata',key:'flow_type'})

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/z8nMUDn.png)

# 4. (5 points)
n stands for the number of objects that match the query command. In this case, it matches the data points that list the disbursement amount over $100000000. In the previous challenge, n is equal to nscanned which means that all of the data is included within the query.
> db.runCommand({distinct:'aiddata',key:'flow_type', query:{'disbursement_amount':{$gt:100000000}}})

> db.[complete this query]

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/elq5rcI.png)

# 5. (5 points)

> db.[complete this query]
> db.aiddata.aggregate([{ $match: { 'donor':'Belgium' }}, { $group: { '_id':'$year', total: {$sum: '$disbursement_amount' }}}]);

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/XbuG3Sn.png)

# Machine Learning (II)

## Challenge 1 (3 points x 4 = 12 points)

### a. (3 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/FWLUgIj.png)

### b. (3 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/Jw38xPg.png)

### c. (3 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/j2TDkzi.png)

### d. (3 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/6iHRbbf.png)

## Challenge 2 (8 points)

{text-and-images}
By Challenge 1a, we can see that the most pitch counts happened in the 0.7-0.8 range. By giving a shade range for the amount of time taken (in ms) since a started recording and incorporating the pitch, it can be observed that most happened within a few milliseconds. Obviously there were a few that longer (41 ms) which was most likely due in part to errors such as low voltage in a battery during a started recording. Also, there was no correlation in pitch between students that had recording data within this data file. This would seem to be normal considering all students used their data to prove different hypotheses.
![screenshot](http://i.imgur.com/UoQA4sL.png)
![screenshot](http://i.imgur.com/2A1TQCw.png)
The diagram for Challenge 1c concluded that there was not much of a difference in the average between touch labels. Label 0 (left) was had a slightly larger average, but not much more as we can tell. In Challenge 1d, we can observe the amount of sensor readings that were done per student. With this, we can see that student 2 had the greatest count whereas student 15 had the least amount. The students with smaller amounts might have had sensor errors relating to the Arduino and battery packs. We could possibly say that students 12 and 15 are the result of hardware problems and other possible factors.

# D3 (V)

## Checkpoints (5 points x 4 = 20 points)

# 1. (5 points)

![image](image.png?raw=true)
![image](http://i.imgur.com/WGR08M3.png)

[checkpoint](checkpoint.html)
[checkpoint](checkpoint1.html)

# 2. (5 points)

![image](image.png?raw=true)
![image](http://i.imgur.com/r3hNOq8.png)

[checkpoint](checkpoint.html)
[checkpoint](checkpoint2.html)

# 3. (5 points)

![image](image.png?raw=true)
![image](http://i.imgur.com/ph5US2z.png)

[checkpoint](checkpoint.html)
[checkpoint](checkpoint3.html)

# 4. (5 points)

![image](image.png?raw=true)
![image](http://i.imgur.com/WsK7Kyy.png)

[checkpoint](checkpoint.html)
[checkpoint](checkpoint4.html)

## Challenges (5 points x 3 + 10 points = 25 points)

### 1. (5 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/AaUcJjx.png)

### 2. (5 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/Wv253v0.png)

### 3. (5 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/BMR6eLo.png)

### 4. (10 points)

![screenshot](screenshot.png?raw=true)
![screenshot](http://i.imgur.com/rf3kwJm.png)

161 changes: 161 additions & 0 deletions checkpoint1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>D3: Updateable Bar Chart</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<style type="text/css">
</style>
</head>
<body>

<p> Click on this text to update the chart with new data values
as many times as you like!</p>

<script type="text/javascript">

//Width and height
var w = 600;
var h = 250;

var dataset = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13,
11, 12, 15, 20, 18, 17, 16, 18, 23, 25 ];
//Add one new value to dataset

var xScale = d3.scale.ordinal()
.domain(d3.range(dataset.length))
.rangeRoundBands([0, w], 0.05);

var yScale = d3.scale.linear()
.domain([0, d3.max(dataset)])
.range([0, h]);

//Create SVG element
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);

//Create bars
svg.selectAll("rect")
.data(dataset)//Hooray for changes!
.enter()
.append("rect")
.attr("x", function(d, i) {
return xScale(i);
})
.attr("y", function(d) {
return h - yScale(d);
})
.attr("width", xScale.rangeBand())
.attr("height", function(d) {
return yScale(d);
})
.attr("fill", function(d) {
return "rgb(0, 0, " + (d * 10) + ")";
});

//Create labels
svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.text(function(d) {
return d;
})
.attr("text-anchor", "middle")
.attr("x", function(d, i) {
return xScale(i) + xScale.rangeBand() / 2;
})
.attr("y", function(d) {
return h - yScale(d) + 14;
})
.attr("font-family", "sans-serif")
.attr("font-size", "9px")
.attr("fill", "white");




//On click, update with new data
d3.select("p")
.on("click", function() {

//New values for dataset
var maxValue = 25;
var newNumber = Math.floor(Math.random() * maxValue);
dataset.push(newNumber);

xScale.domain(d3.range(dataset.length));

var bars = svg.selectAll("rect")
.data(dataset);

bars.enter()
.append("rect")
.attr("x", w)
.attr("y", function(d) {
return h - yScale(d);
})
.attr("width", xScale.rangeBand())
.attr("height", function(d) {
return yScale(d);
})
.attr("fill", function(d) {
return "rgb(0, 0, " + (d * 10) + ")";
});

//Update…
bars.transition()
.duration(250)
.attr("x", function(d, i) {
return xScale(i);
})
.attr("y", function(d) {
return h - yScale(d);
})
.attr("width", xScale.rangeBand())
.attr("height", function(d) {
return yScale(d);
});

//Update all rects
svg.selectAll("rect")
.data(dataset)
.transition()
.delay(function(d, i) {
return i / dataset.length * 1000;
})
.duration(250)
.ease("linear")
.attr("y", function(d) {
return h - yScale(d);
})
.attr("height", function(d) {
return yScale(d);
})
.attr("fill", function(d){
return "rgb(0,0, " + (d*10) + ")";
});

svg.selectAll("text")
.data(dataset)
.transition()
.duration(250)
.delay(function(d, i) {
return i / dataset.length * 1000;
})
.ease("linear")
.text(function(d) {
return d;
})
.attr("x", function(d,i) {
return xScale(i) + xScale.rangeBand() / 2;
})
.attr("y", function(d,i){
return h - yScale(d) + 14;
});
});
</script>
</body>
</html>
Loading