Skip to content

Commit 7d86a7a

Browse files
committed
Merge branch 'main' into joeyklee.637-refactor-tests-to-jest
2 parents da47933 + 388cc9a commit 7d86a7a

28 files changed

+708
-185
lines changed

.all-contributorsrc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,36 @@
12871287
"code",
12881288
"ideas"
12891289
]
1290+
},
1291+
{
1292+
"login": "asvsfs",
1293+
"name": "Amir",
1294+
"avatar_url": "https://avatars.githubusercontent.com/u/119840?v=4",
1295+
"profile": "https://github.com/asvsfs",
1296+
"contributions": [
1297+
"code",
1298+
"example"
1299+
]
1300+
},
1301+
{
1302+
"login": "lindapaiste",
1303+
"name": "lindapaiste",
1304+
"avatar_url": "https://avatars.githubusercontent.com/u/28965286?v=4",
1305+
"profile": "http://lindapaiste.com",
1306+
"contributions": [
1307+
"code",
1308+
"ideas",
1309+
"bug"
1310+
]
1311+
},
1312+
{
1313+
"login": "emwdx",
1314+
"name": "Evan Weinberg",
1315+
"avatar_url": "https://avatars.githubusercontent.com/u/1531831?v=4",
1316+
"profile": "http://evanweinberg.com",
1317+
"contributions": [
1318+
"doc"
1319+
]
12901320
}
12911321
],
12921322
"contributorsPerLine": 7,

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ Before getting started with ml5.js, review our [Code of Conduct](https://github.
5656

5757

5858

59+
60+
61+
62+
63+
64+
65+
5966

6067

6168

@@ -66,11 +73,11 @@ Before getting started with ml5.js, review our [Code of Conduct](https://github.
6673

6774
<p id="latest-version">
6875

69-
* You can use the latest version (0.10.1) by adding it to the head section of your HTML document:
76+
* You can use the latest version (0.11.1) by adding it to the head section of your HTML document:
7077

71-
**v0.10.1**
78+
**v0.11.1**
7279

73-
<script src="https://unpkg.com/ml5@0.10.1/dist/ml5.min.js" type="text/javascript"></script>
80+
<script src="https://unpkg.com/ml5@0.11.1/dist/ml5.min.js" type="text/javascript"></script>
7481

7582
</p data-id="latest-version">
7683

@@ -100,6 +107,13 @@ Before getting started with ml5.js, review our [Code of Conduct](https://github.
100107

101108

102109

110+
111+
112+
113+
114+
115+
116+
103117

104118

105119

@@ -136,11 +150,11 @@ For example:
136150

137151
## Resources
138152

139-
- [Getting Started](https://ml5js.org/getting-started/)
140-
- [API Reference](https://ml5js.org/reference/)
153+
- [Getting Started](https://learn.ml5js.org/)
154+
- [API Reference](https://learn.ml5js.org/#/reference/index)
141155
- [Examples](https://github.com/ml5js/ml5-library/tree/main/examples)
142156
- [Community](https://ml5js.org/community)
143-
- [FAQ](https://ml5js.org/getting-started/faq/)
157+
- [FAQ](https://learn.ml5js.org/#/faq)
144158

145159
## Standalone Examples
146160

@@ -332,6 +346,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
332346
<td align="center"><a href="https://github.com/amirfeqhi"><img src="https://avatars.githubusercontent.com/u/26363996?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amir Feqhi</b></sub></a><br /><a href="https://github.com/ml5js/ml5-library/commits?author=amirfeqhi" title="Code">💻</a></td>
333347
<td align="center"><a href="https://github.com/danidask"><img src="https://avatars.githubusercontent.com/u/9405129?v=4?s=100" width="100px;" alt=""/><br /><sub><b>DasK</b></sub></a><br /><a href="https://github.com/ml5js/ml5-library/commits?author=danidask" title="Code">💻</a> <a href="#ideas-danidask" title="Ideas, Planning, & Feedback">🤔</a></td>
334348
</tr>
349+
<tr>
350+
<td align="center"><a href="https://github.com/asvsfs"><img src="https://avatars.githubusercontent.com/u/119840?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Amir</b></sub></a><br /><a href="https://github.com/ml5js/ml5-library/commits?author=asvsfs" title="Code">💻</a> <a href="#example-asvsfs" title="Examples">💡</a></td>
351+
<td align="center"><a href="http://lindapaiste.com"><img src="https://avatars.githubusercontent.com/u/28965286?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lindapaiste</b></sub></a><br /><a href="https://github.com/ml5js/ml5-library/commits?author=lindapaiste" title="Code">💻</a> <a href="#ideas-lindapaiste" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ml5js/ml5-library/issues?q=author%3Alindapaiste" title="Bug reports">🐛</a></td>
352+
<td align="center"><a href="http://evanweinberg.com"><img src="https://avatars.githubusercontent.com/u/1531831?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Evan Weinberg</b></sub></a><br /><a href="https://github.com/ml5js/ml5-library/commits?author=emwdx" title="Documentation">📖</a></td>
353+
</tr>
335354
</table>
336355

337356
<!-- markdownlint-restore -->

docs/styleguide/maintenance-notes.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,28 @@
66

77
1. make sure to tag it with one of the following in the PR:
88
- SEMVER/patch
9+
- e.g. `SEMVER/patch`: `0.8.11` would become -> `0.8.12`
910
- SEMVER/minor
11+
- e.g. `SEMVER/minor`: `0.8.11` would become -> `0.9.0`
1012
- SEMVER/major
13+
- e.g. `SEMVER/major`: `0.8.11` would become -> `1.0.0`
1114

12-
## Before tagging a release releasing: bump the package version
13-
1. open a PR to bump the package version: e.g. `git checkout -b v0.8.12`
14-
2. bump the package version number that matches the `SEMVER/patch | SEMVER/minor | SEMVER/major`
15-
- e.g. `SEMVER/patch`: `0.8.11` would become -> `0.8.12`
16-
- e.g. `SEMVER/minor`: `0.8.11` would become -> `0.9.00`
17-
- e.g. `SEMVER/major`: `0.8.11` would become -> `1.0.0`
18-
3. run `npm i` <--- this makes sure your bumped package version makes it into the `package-lock.json`
19-
4. run `npm run update:readme` <----- captures the version bump in the readme
20-
5. run `git add .`
21-
6. run `git commit -m "chore: bumps package"`
22-
7. push this to your feature branch.
23-
8. make a PR and merge to `main`
15+
NOTE: if you are unsure quite likely it will be a `SEMVER/patch` for "...when you make backwards compatible bug fixes.". You can learn more about [Semantic Versioning](https://semver.org/).
2416

2517
## Once we merge the PR to `main`:
18+
2619
1. simply go to the `releases` sidebar >
2720
<img width="1332" alt="Screen Shot 2022-01-21 at 12 58 26 PM" src="https://user-images.githubusercontent.com/3622055/150599297-44e00536-9399-4cc0-be5b-d0b09761d651.png">
2821
2. go to the latest draft and click the edit button
2922
<img width="1332" alt="Screen Shot 2022-01-21 at 12 58 31 PM" src="https://user-images.githubusercontent.com/3622055/150599360-cba6d7ec-44eb-49da-977a-a7de5f071795.png">
30-
3. click: publish the release
31-
32-
23+
3. click: publish the release -- this will trigger a github workflow that will:
24+
* get the latest tag version
25+
* update the package.json
26+
* update the readme with the latest version (pulled from the package.json)
27+
* run npm install
28+
* add, commit, and push those changes to `main`
29+
* build the library
30+
* and publish to npm
3331

3432

3533
***

examples/d3/KMeans/KMeans_GaussianClusterDemo/data/gaussian2d_3clusters.csv renamed to examples/d3/DBSCAN/DBSCAN_Cluster/data/gaussian2d_1.55clusters.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x1,x2
1+
x,y
22
-7.849704268160314,-8.674808581953744
33
-8.69664575596503,-7.692212927859845
44
-1.0359915243020554,6.827713353515913

examples/d3/KMeans/KMeans_GaussianClusterDemo/data/gaussian2d_4clusters.csv renamed to examples/d3/DBSCAN/DBSCAN_Cluster/data/gaussian2d_1.56clusters.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x1,x2
1+
x,y
22
-10.718663580210745,9.900472871349784
33
-7.9399489058067685,10.718096194668659
44
-9.199206305612545,6.923022960440686

examples/d3/KMeans/KMeans_GaussianClusterDemo/data/gaussian2d_2clusters.csv renamed to examples/d3/DBSCAN/DBSCAN_Cluster/data/gaussian2d_2clusters.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x1,x2
1+
x,y
22
2.498895550686414,1.1683342316471301
33
5.073222450036444,0.8623713271387572
44
4.672790880324094,2.6418773621498803
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x1,x2
1+
x,y
22
-0.9914878645939103,0.12004373871846165
33
-0.8064234011393798,-0.5891152116668836
44
-0.4265373027932866,-0.6749570357883385
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
x1,x2
1+
x,y
22
2.001164955520126,0.43029947571735944
33
-0.6744557747817002,0.7365153394030783
44
0.13616835175111489,1.0001429333017973
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<html>
2+
<head>
3+
<title>ml5.js DBSCAN example</title>
4+
<script src="https://d3js.org/d3.v4.min.js"></script>
5+
<script src="http://localhost:8080/ml5.js" type="text/javascript"></script>
6+
</head>
7+
<body>
8+
<center>
9+
<h1>DBSCAN Example</h1>
10+
<p style="width: 60%;"> DBSCAN is a <i>density-based clustering non-parametric algorithm</i>: given a set of points in some space, it groups together points that are closely packed together (points with many nearby neighbors),
11+
marking as outliers points that lie alone in low-density regions (whose nearest neighbors are too far away).
12+
DBSCAN is one of the most common clustering algorithms and also most cited in scientific literature.
13+
</p>
14+
<div>
15+
16+
<div id="buttons"></div>
17+
<div id="chart"></div>
18+
</div>
19+
</center>
20+
<script src="sketch.js"></script>
21+
</body>
22+
</html>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
let dbscanModel;
2+
const width = 640;
3+
const height = 480;
4+
const colDict = {
5+
0: "skyblue",
6+
1: "coral",
7+
2: "olive",
8+
3: "tan",
9+
4: "grey",
10+
};
11+
12+
// ----- Initialize the example: ------ //
13+
function init() {
14+
// make all those nice buttons
15+
createButtons();
16+
// start with 3 cluster
17+
make(1.55);
18+
}
19+
init();
20+
21+
// STEP 1:
22+
// create all the buttons
23+
function createButtons() {
24+
addClusterButton(1.55);
25+
addClusterButton(1.56);
26+
addClusterButton(2);
27+
addClusterButton("circle");
28+
addClusterButton("moon");
29+
}
30+
31+
// STEP 2:
32+
// create the model
33+
function make(eps) {
34+
const options = {
35+
eps: eps,
36+
minPts: 3,
37+
};
38+
// if moon or circle data, set the options to 0.1 and 0.16 eps
39+
if (eps === "moon") {
40+
options.eps = 0.1;
41+
} else if (eps === "circle") {
42+
options.eps = 0.16;
43+
}
44+
console.log(eps, options.eps);
45+
46+
// get the path to the data in our data folder dynamically
47+
const dataPath = `data/gaussian2d_${eps}clusters.csv`;
48+
// create a new dbscan clustering each time on make()
49+
dbscanModel = ml5.dbscan(dataPath, options, modelReady);
50+
}
51+
52+
// Step 3:
53+
// when the model is ready, make the chart
54+
function modelReady() {
55+
console.log(dbscanModel.dataset);
56+
makeChart();
57+
}
58+
59+
// Step 4:
60+
// use the fancy d3 to make magic
61+
function makeChart() {
62+
const { dataset } = dbscanModel;
63+
// clear the chart each time
64+
// less efficient, but simple
65+
d3.select("svg").remove();
66+
67+
// reappend the svg to the chart area
68+
const svg = d3
69+
.select("#chart")
70+
.append("svg")
71+
.attr("width", width)
72+
.attr("height", height);
73+
74+
// d[0] is for the x value in the array
75+
const xScale = d3
76+
.scaleLinear()
77+
.domain(d3.extent(dataset, d => d[0]))
78+
.range([10, width - 100]);
79+
80+
// d[1] is for the y value in the array
81+
const yScale = d3
82+
.scaleLinear()
83+
.domain(d3.extent(dataset, d => d[1]))
84+
.range([height - 50, 20]);
85+
86+
svg
87+
.selectAll("circle")
88+
.data(dataset)
89+
.enter()
90+
.append("circle")
91+
.attr("cx", d => xScale(d[0]))
92+
.attr("cy", d => yScale(d[1]))
93+
.attr("r", 6)
94+
.attr("fill", "black");
95+
96+
d3.select("svg")
97+
.selectAll("circle")
98+
.transition()
99+
.attr("fill", (d, i) => colDict[dataset[i].clusterid]);
100+
}
101+
102+
// adds the buttons for the respective cluster data
103+
// we could also use d3.append() and d3.select() here :)
104+
function addClusterButton(eps, minPts = 3) {
105+
const btn = document.createElement("BUTTON");
106+
btn.innerText = `cluster: ${eps} & minPts: ${minPts}`;
107+
108+
btn.addEventListener("click", function(e) {
109+
make(eps);
110+
});
111+
112+
document.querySelector("#buttons").appendChild(btn);
113+
114+
return btn;
115+
}

0 commit comments

Comments
 (0)