Skip to content

Instantly share code, notes, and snippets.

@MNoichl
Last active January 2, 2018 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MNoichl/1178dd29c8fd77252532e1a719e86890 to your computer and use it in GitHub Desktop.
Save MNoichl/1178dd29c8fd77252532e1a719e86890 to your computer and use it in GitHub Desktop.
DB-Indexes for selected paper-clusters
license: mit

Method

The 500 most cited or all accessible papers from the following journals where downloaded, and there citation records accessed:

analytical journals:

  • Mind
  • Analysis
  • Philosophical Quarterly
  • Ethics

continental journals:

  • Continental Philosophy Review
  • Journal of Speculative Philosophy
  • Constellations
  • Journal of the British Society for Phenomenology

The citation data was stripped to the cited authors. The resulting documents where tokenized - divided into single words. Then it was determined for every paper if it contained any of the found names.

Paper Nr. Heidegger Ryle ...
1 1 0 ...
2 1 0 ...
3 0 1 ...

These resulting examples where clustered with a K-means-Algorithm. The Davies-Bouldin-Indexes for this Clustering are shown above. A low index indicates good clustering, which means that the clusters have high internal consistency and are very different to each other So we can say that the hypothesis of two clusters (eg. analytic and continental philosophy) seems not particulary merited (DB = 8.6), expecially when compared to 7 clusters, which yields a DB of 6.92.

forked from MNoichl's block: DB-Indexes for selected paper-clusters

k DB W
2.0 8.615821506268905 9.689455603922553
3.0 8.372683745091003 9.613802707240781
4.0 8.060323505815674 9.560900214038929
5.0 7.554504049059224 9.493703031235166
6.0 7.2756812254733925 9.447811112043595
7.0 6.923465652878521 9.405677164477725
8.0 7.334561607266986 9.373500004392408
9.0 6.940523517981654 9.351522900176995
10.0 7.010046258819619 9.290545797722556
<html>
<head>
<meta charset="utf-8">
<title>Visualization</title>
<link rel="stylesheet" href="scatter.css" charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Alegreya|Alegreya+SC|Alegreya+Sans|Alegreya+Sans+SC|Cormorant+Garamond|Cormorant+SC:300,400,500,600,700|EB+Garamond|Fanwood+Text:400,400i|Goudy+Bookletter+1911|IM+Fell+Double+Pica+SC|IM+Fell+French+Canon+SC|IM+Fell+French+Canon:400,400i|IM+Fell+Great+Primer+SC|IM+Fell+Great+Primer:400,400i|Spectral+SC:200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i|Vollkorn+SC:400,600,700,900&amp;subset=latin-ext" rel="stylesheet">
</head>
<body>
<div id="scatter"></div>
<input type="button" name="xAxis" value="xAxis">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
<script src="scatter.js" charset="utf-8"></script>
</body>
</html>
rect {
fill: transparent;
shape-rendering: crispEdges;
}
.axis path,
.axis line {
fill: none;
stroke: rgba(0, 0, 0, 0.1);
shape-rendering: crispEdges;
}
h1 {
font-family: Alegreya SC, serif;
}
text {
margin-top: 40pt;
margin-bottom:5pt;
text-align: left;
font-family: 'Alegreya SC', serif;
font-size: 12pt;
font-weight: 300;
}
.axisLine {
fill: none;
shape-rendering: crispEdges;
stroke: rgba(0, 0, 0, 0.5);
stroke-width: 2px;
}
.dot {
fill-opacity: .8;
}
.d3-tip {
/* width: 100px;*/
background-color: #ffffff;
padding: 3px 12px;
font-family: serif;
border: 1px solid #bbbbbb;
box-shadow: 1px 1px 4px #bbbbbb;
font-family: EB Garamond, serif;
text-transform: capitalize;
background: rgba(255,255,255, 0.6);
}
/*
.d3-tip {
line-height: 1;
font-weight: bold;
padding: 12px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 2px;
}
var margin = { top: 50, right: 300, bottom: 50, left: 50 },
outerWidth = 1050,
outerHeight = 500,
width = outerWidth - margin.left - margin.right,
height = outerHeight - margin.top - margin.bottom;
var x = d3.scale.linear()
.range([0, width]).nice();
var y = d3.scale.linear()
.range([height, 0]).nice();
var xCat = "k",
yCat = "DB",
rCat = "c1",
colorCat = "cluster";
d3.csv("cereal.csv", function(data) {
data.forEach(function(d) {
d.DB = +d.DB;
d.k = +d.k;
d["Protein (g)"] = +d["Protein (g)"];
d["Serving Size Weight"] = +d["Serving Size Weight"];
d.Sodium = +d.Sodium;
d.Sugars = +d.Sugars;
d["Vitamins and Minerals"] = +d["Vitamins and Minerals"];
});
var xMax = d3.max(data, function(d) { return d[xCat]; }) * 1.05,
xMin = d3.min(data, function(d) { return d[xCat]; }),
xMin = xMin > 0 ? 0 : xMin,
yMax = d3.max(data, function(d) { return d[yCat]; }) * 1.05,
yMin = d3.min(data, function(d) { return d[yCat]; }) / 1.05;
x.domain([xMin, xMax]);
y.domain([yMin, yMax]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.tickSize(-height);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.tickSize(-width);
var color = d3.scale.category20();
var tip = d3.tip()
.attr("class", "d3-tip")
.offset([-10, 0])
.html(function(d) {
return xCat + ": " + d[xCat] + "<br>" + yCat + ": " + d[yCat];
});
var zoomBeh = d3.behavior.zoom()
.x(x)
.y(y)
.scaleExtent([0, 500])
.on("zoom", zoom);
var svg = d3.select("#scatter")
.append("svg")
.attr("width", outerWidth)
.attr("height", outerHeight)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")")
.call(zoomBeh);
svg.call(tip);
svg.append("rect")
.attr("width", width)
.attr("height", height);
svg.append("g")
.classed("x axis", true)
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.append("text")
.classed("label", true)
.attr("x", width)
.attr("y", margin.bottom - 10)
.style("text-anchor", "end")
.text(xCat);
svg.append("g")
.classed("y axis", true)
.call(yAxis)
.append("text")
.classed("label", true)
.attr("transform", "rotate(-90)")
.attr("y", -margin.left)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text(yCat);
var objects = svg.append("svg")
.classed("objects", true)
.attr("width", width)
.attr("height", height);
objects.append("svg:line")
.classed("axisLine hAxisLine", true)
.attr("x1", 0)
.attr("y1", 0)
.attr("x2", width)
.attr("y2", 0)
.attr("transform", "translate(0," + height + ")");
objects.append("svg:line")
.classed("axisLine vAxisLine", true)
.attr("x1", 0)
.attr("y1", 0)
.attr("x2", 0)
.attr("y2", height);
objects.selectAll(".dot")
.data(data)
.enter().append("circle")
.classed("dot", true)
.attr("r", 3)//function (d) { return 6 * Math.sqrt(d[rCat] / Math.PI); }
.attr("transform", transform)
.style("fill", function(d) { return color(d[colorCat]); })
.on("mouseover", tip.show)
.on("mouseout", tip.hide);
var legend = svg.selectAll(".legend")
.data(color.domain())
.enter().append("g")
.classed("legend", true)
.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; });
/*
legend.append("circle")
.attr("r", 3.5)
.attr("cx", width + 20)
.attr("fill", color);
legend.append("text")
.attr("x", width + 26)
.attr("dy", ".35em")
.text(function(d) { return d; });
*/
d3.select("input").on("click", change);
function change() {
xCat = "Carbs";
xMax = d3.max(data, function(d) { return d[xCat]; });
xMin = d3.min(data, function(d) { return d[xCat]; });
zoomBeh.x(x.domain([xMin, xMax])).y(y.domain([yMin, yMax]));
var svg = d3.select("#scatter").transition();
svg.select(".x.axis").duration(750).call(xAxis).select(".label").text(xCat);
objects.selectAll(".dot").transition().duration(1000).attr("transform", transform);
}
function zoom() {
svg.select(".x.axis").call(xAxis);
svg.select(".y.axis").call(yAxis);
svg.selectAll(".dot")
.attr("transform", transform);
}
function transform(d) {
return "translate(" + x(d[xCat]) + "," + y(d[yCat]) + ")";
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment