id
stringlengths
7
14
test_class
dict
test_case
dict
focal_class
dict
focal_method
dict
repository
dict
128393918_125
{ "fields": [ { "declarator": "epsilon = 0.01", "modifier": "private static", "original_string": "private static double epsilon = 0.01;", "type": "double", "var_name": "epsilon" }, { "declarator": "N = 100000", "modifier": "private static", "original_string"...
{ "body": "@Category(Slow.class)\n @Test\n public void ofDirichletVertexHasCorrectProportions() {\n final DoubleTensor concentration = DoubleTensor.create(1, 2, 3, 4);\n final DirichletVertex dirichletVertex = new DirichletVertex(new ConstantDoubleVertex(concentration));\n final Categorical...
{ "fields": [ { "declarator": "selectableValues", "modifier": "private final", "original_string": "private final Map<CATEGORY, DoubleVertex> selectableValues;", "type": "Map<CATEGORY, DoubleVertex>", "var_name": "selectableValues" } ], "file": "keanu-project/src/main/java/io/...
{ "body": "public static <CATEGORY> CategoricalVertex<CATEGORY> of(\n Map<CATEGORY, Double> selectableValues\n ) {\n return new CategoricalVertex<>(toDoubleVertices(selectableValues));\n }", "class_method_signature": "CategoricalVertex.of(\n Map<CATEGORY, Double> selectableValues\n )",...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_172
{ "fields": [ { "declarator": "VERTEX_INCREMENT = 0.1", "modifier": "private final", "original_string": "private final double VERTEX_INCREMENT = 0.1;", "type": "double", "var_name": "VERTEX_INCREMENT" }, { "declarator": "random", "modifier": "private", "orig...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfVector() {\n DoubleVertex location = ConstantVertex.of(1.);\n DoubleVertex scale = ConstantVertex.of(1.5, 1.5);\n ParetoVertex paretoVertex = new ParetoVertex(new long[]{2}, location, scale);\n LogProbGraph logProbGraph ...
{ "fields": [ { "declarator": "scale", "modifier": "private final", "original_string": "private final DoubleVertex scale;", "type": "DoubleVertex", "var_name": "scale" }, { "declarator": "location", "modifier": "private final", "original_string": "private fi...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex locationPlaceholder = new DoublePlaceholderVertex(location.getShape());\n final DoublePlaceholderVertex scale...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_308
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/algorithms/graphtraversal/TopologicalSortTest.java", "identifier": "TopologicalSortTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void sortsSimpleDiamondGraph() {\n\n DoubleVertex A = new GaussianVertex(5.0, 1.0);\n DoubleVertex B = new GaussianVertex(A, 1.0);\n DoubleVertex C = new GaussianVertex(A, 1.0);\n DoubleVertex D = new GaussianVertex(B, C);\n\n List<? extends Vertex> sort...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/graphtraversal/TopologicalSort.java", "identifier": "TopologicalSort", "interfaces": "", "methods": [ { "class_method_signature": "TopologicalSort.TopologicalSort()", "constructor": true, "full_signature"...
{ "body": "public static List<Vertex> sort(Collection<? extends Vertex> vertices) {\n return vertices\n .stream()\n .sorted(Comparator.comparing(Vertex::getId, Comparator.naturalOrder()))\n .collect(Collectors.toList());\n }", "class_method_signature": "TopologicalSort.sor...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_164
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfNegativeVector() {\n DoubleVertex sigma = ConstantVertex.of(1., 1.);\n HalfGaussianVertex halfGaussianVertex = new HalfGaussianVertex(sigma);\n LogProbGraph logProbGraph = halfGaussianVertex.logProbGraph();\n LogProbGrap...
{ "fields": [ { "declarator": "MU_ZERO = 0.0", "modifier": "private static final", "original_string": "private static final double MU_ZERO = 0.0;", "type": "double", "var_name": "MU_ZERO" }, { "declarator": "LOG_TWO = Math.log(2)", "modifier": "private static fina...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex muPlaceholder = new DoublePlaceholderVertex(getMu().getShape());\n final DoublePlaceholderVertex sigmaPlaceho...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_133
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/vertices/tensor/number/floating/dbl/nonprobabilistic/diff/LogProbGradientCalculatorTest.java", "identifier": "LogProbGradientCalculatorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void doesThrowOnLogProbDiffOnNonProbabilistic() {\n DoubleVertex A = ConstantVertex.of(5.0);\n DoubleVertex B = A.times(4);\n LogProbGradientCalculator calculator = new LogProbGradientCalculator(ImmutableList.of(B), Immutable...
{ "fields": [ { "declarator": "logProbOfVertices", "modifier": "private final", "original_string": "private final Set<Vertex> logProbOfVertices;", "type": "Set<Vertex>", "var_name": "logProbOfVertices" }, { "declarator": "wrtVertices", "modifier": "private final",...
{ "body": "public Map<VertexId, DoubleTensor> getJointLogProbGradientWrtLatents() {\n LogProbGradients totalLogProbGradients = new LogProbGradients();\n\n for (final Vertex<?, ?> ofVertex : logProbOfVertices) {\n LogProbGradients logProbGradientOfVertex = reverseModeLogProbGradientWrtLatents(...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_144
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfScalar() {\n DoubleVertex mu = ConstantVertex.of(0.);\n DoubleVertex sigma = ConstantVertex.of(1.);\n GaussianVertex vertex = new GaussianVertex(mu, sigma);\n LogProbGraph logProbGraph = vertex.logProbGraph();\n\n ...
{ "fields": [ { "declarator": "mu", "modifier": "private final", "original_string": "private final DoubleVertex mu;", "type": "DoubleVertex", "var_name": "mu" }, { "declarator": "sigma", "modifier": "private final", "original_string": "private final DoubleVe...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex muPlaceholder = new DoublePlaceholderVertex(mu.getShape());\n final DoublePlaceholderVertex sigmaPlaceholder ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_328
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void youCanConstructManySequenceItems() throws IOException {\n VertexLabel x1Label = new VertexLabel(\"x1\");\n VertexLabel x2Label = new VertexLabel(\"x2\");\n VertexLabel outputLabel = new VertexLabel(\"OUTPUT\");\n String sequence1Label = \"Sequence_1\";\n ...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/templating/SequenceLoader.java", "identifier": "SequenceLoader", "interfaces": "", "methods": [ { "class_method_signature": "SequenceLoader.loadFromBayesNet(BayesianNetwork network)", "constructor": false, "full_sig...
{ "body": "public static Map<Integer, Sequence> loadMultipleSequencesFromBayesNet(BayesianNetwork network) {\n return loadSequences(network, true);\n }", "class_method_signature": "SequenceLoader.loadMultipleSequencesFromBayesNet(BayesianNetwork network)", "constructor": false, "full_signature": "publ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_282
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" } ], "file": "keanu-project/src/test/java...
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void doesValidateTargetAcceptanceUpper() {\n NUTS.builder().targetAcceptanceProb(1.1);\n }", "class_method_signature": "NUTSTest.doesValidateTargetAcceptanceUpper()", "constructor": false, "full_signature": "@Test(expected = Illeg...
{ "fields": [ { "declarator": "random", "modifier": "@Getter\n private final", "original_string": "@Getter\n private final KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" }, { "declarator": "targetAcceptanceProb", "modifier": "@Getter\n ...
{ "body": "public static NUTSBuilder builder() {\n return new NUTSBuilder();\n }", "class_method_signature": "NUTS.builder()", "constructor": false, "full_signature": "public static NUTSBuilder builder()", "identifier": "builder", "invocations": [], "modifiers": "public static", "parameters": ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_113
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" }, { "declarator": "printSt...
{ "body": "@Test\n public void whenPrintIsCalledAddsPrintVertexAsChild() {\n final UniformVertex A = new UniformVertex(0, 1);\n A.print();\n final Vertex printVertex = Iterables.getOnlyElement(A.getChildren());\n assertThat(printVertex, instanceOf(PrintVertex.class));\n }", "class_...
{ "fields": [ { "declarator": "printStream = System.out", "modifier": "private static", "original_string": "private static PrintStream printStream = System.out;", "type": "PrintStream", "var_name": "printStream" }, { "declarator": "PARENT = \"parent\"", "modifier"...
{ "body": "public static <T> T print(T parentValue, String message, boolean printData) {\n final String dataOutput = printData ? parentValue.toString() + \"\\n\" : \"\";\n printStream.print(message + dataOutput);\n return parentValue;\n }", "class_method_signature": "PrintVertex.print(T pare...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_84
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void doesntCreateTooManyBooleansFromPadding() {\n byte byte1 = (byte) Integer.parseInt(\"10101010\", 2);\n byte byte2 = (byte) Integer.parseInt(\"10000000\", 2);\n byte[] bytes = new byte[]{byte1, byte2};\n\n boolean[] bools = Py4jByteArrayConverter.toBooleanAr...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/util/Py4jByteArrayConverter.java", "identifier": "Py4jByteArrayConverter", "interfaces": "", "methods": [ { "class_method_signature": "Py4jByteArrayConverter.toByteArray(double[] doubleArray)", "constructor": false, ...
{ "body": "public static boolean[] toBooleanArray(byte[] byteArray, int numberOfBooleansInArray) {\n BitSet bits = BitSet.valueOf(byteArray);\n boolean[] bools = new boolean[numberOfBooleansInArray];\n for (int i = bits.nextSetBit(0); i != -1; i = bits.nextSetBit(i + 1)) {\n int positi...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_105
{ "fields": [ { "declarator": "Amu", "modifier": "", "original_string": "DoubleVertex Amu;", "type": "DoubleVertex", "var_name": "Amu" }, { "declarator": "Asigma", "modifier": "", "original_string": "DoubleVertex Asigma;", "type": "DoubleVertex", ...
{ "body": "@Test\n public void doesGetAllDownstreamVerticesOfCollection() {\n TransitiveClosure transitiveClosure = TransitiveClosure.getDownstreamVerticesForCollection(Arrays.asList(A, B, cSigma), true);\n assertThat(transitiveClosure.getAllVertices(), containsInAnyOrder(A, B, aPlusB, cSigma, C));\n...
{ "fields": [ { "declarator": "ADD_ALL = vertex -> true", "modifier": "private static final", "original_string": "private static final Predicate<Vertex> ADD_ALL = vertex -> true;", "type": "Predicate<Vertex>", "var_name": "ADD_ALL" }, { "declarator": "PROBABILISTIC_OR_O...
{ "body": "public static TransitiveClosure getDownstreamVerticesForCollection(List<Vertex> vertices, boolean includeNonProbabilistic) {\n\n Predicate<Vertex> shouldAdd = includeNonProbabilistic ? ADD_ALL : PROBABILISTIC_OR_OBSERVED_ONLY;\n\n Set<Vertex> downstreamVertices = getVertices(\n ver...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_92
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" }, { "declarator": "network...
{ "body": "@Test\n public void testGetAverageVertexDegree() {\n assertThat(network.getAverageVertexDegree(), equalTo((1. + 1. + 2. + 2. + 2.) / 5));\n }", "class_method_signature": "BayesianNetworkTest.testGetAverageVertexDegree()", "constructor": false, "full_signature": "@Test public void testGet...
{ "fields": [ { "declarator": "vertices", "modifier": "private final", "original_string": "private final List<? extends Vertex> vertices;", "type": "List<? extends Vertex>", "var_name": "vertices" }, { "declarator": "vertexLabels", "modifier": "private final", ...
{ "body": "public double getAverageVertexDegree() {\n return getVertices().stream().mapToDouble(Vertex::getDegree).average().getAsDouble();\n }", "class_method_signature": "BayesianNetwork.getAverageVertexDegree()", "constructor": false, "full_signature": "public double getAverageVertexDegree()", "i...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_152
{ "fields": [ { "declarator": "DELTA = 0.001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string": "...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfScalar() {\n DoubleVertex mu = ConstantVertex.of(0.5);\n DoubleVertex beta = ConstantVertex.of(1.);\n LaplaceVertex laplaceVertex = new LaplaceVertex(mu, beta);\n LogProbGraph logProbGraph = laplaceVertex.logProbGraph();...
{ "fields": [ { "declarator": "mu", "modifier": "private final", "original_string": "private final DoubleVertex mu;", "type": "DoubleVertex", "var_name": "mu" }, { "declarator": "beta", "modifier": "private final", "original_string": "private final DoubleVer...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex muPlaceholder = new DoublePlaceholderVertex(mu.getShape());\n final DoublePlaceholderVertex betaPlaceholder =...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_294
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" } ], "file": "keanu-project/src/test/java...
{ "body": "@Category(Slow.class)\n @Test\n public void samplesContinuousTensorPrior() {\n\n long[] shape = new long[]{1, 1};\n DoubleVertex A = new GaussianVertex(shape, 20.0, 1.0);\n DoubleVertex B = new GaussianVertex(shape, 20.0, 1.0);\n\n A.setValue(20.0);\n B.setValue(20....
{ "fields": [ { "declarator": "DEFAULT_VARIABLE_SELECTOR = SINGLE_VARIABLE_SELECTOR", "modifier": "private static final", "original_string": "private static final MHStepVariableSelector DEFAULT_VARIABLE_SELECTOR = SINGLE_VARIABLE_SELECTOR;", "type": "MHStepVariableSelector", "var_nam...
{ "body": "@Override\n public NetworkSamples getPosteriorSamples(ProbabilisticModel model,\n List<? extends Variable> variablesToSampleFrom,\n int sampleCount) {\n return generatePosteriorSamples(model, variablesToSamp...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_129
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/vertices/tensor/number/floating/dbl/nonprobabilistic/diff/LogProbGradientCalculatorTest.java", "identifier": "LogProbGradientCalculatorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canFindGradientOfSingleVariantGaussianWrtSingleVariateLatent() {\n\n GaussianVertex A = new GaussianVertex(0, 1);\n GaussianVertex B = new GaussianVertex(A, 1);\n B.setValue(0.5);\n\n LogProbGradientCalculator calculator = new LogProbGradientCalculator(Imm...
{ "fields": [ { "declarator": "logProbOfVertices", "modifier": "private final", "original_string": "private final Set<Vertex> logProbOfVertices;", "type": "Set<Vertex>", "var_name": "logProbOfVertices" }, { "declarator": "wrtVertices", "modifier": "private final",...
{ "body": "public Map<VertexId, DoubleTensor> getJointLogProbGradientWrtLatents() {\n LogProbGradients totalLogProbGradients = new LogProbGradients();\n\n for (final Vertex<?, ?> ofVertex : logProbOfVertices) {\n LogProbGradients logProbGradientOfVertex = reverseModeLogProbGradientWrtLatents(...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_345
{ "fields": [ { "declarator": "random", "modifier": "private", "original_string": "private KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" } ], "file": "keanu-project/src/test/java/io/improbable/keanu/KeanuRandomTest.java", "identifier": "KeanuRandomTest",...
{ "body": "@Test\n public void canSampleUniformScalar() {\n assertEquals(0, random.nextDouble(new long[0]).getRank());\n assertEquals(1, random.nextDouble(new long[]{1}).getRank());\n assertEquals(2, random.nextDouble(new long[]{1, 1}).getRank());\n assertEquals(2, random.nextDouble(new...
{ "fields": [ { "declarator": "DEFAULT_RANDOM = new AtomicReference<>()", "modifier": "private static final", "original_string": "private static final AtomicReference<KeanuRandom> DEFAULT_RANDOM = new AtomicReference<>();", "type": "AtomicReference<KeanuRandom>", "var_name": "DEFAULT...
{ "body": "public DoubleTensor nextDouble(long[] shape) {\n final int length = getLengthAsInt(shape);\n if (length > 1) {\n return DoubleTensor.create(nextDoubleBuffer(length), shape);\n } else {\n return DoubleTensor.create(nextDouble(), shape);\n }\n }", "class...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_200
{ "fields": [ { "declarator": "random", "modifier": "private", "original_string": "private KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" } ], "file": "keanu-project/src/test/java/io/improbable/keanu/vertices/tensor/number/fixed/intgr/probabilistic/PoissonV...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogProb() {\n DoubleVertex mu = ConstantVertex.of(new double[]{5, 7});\n PoissonVertex poissonVertex = new PoissonVertex(mu);\n LogProbGraph logProbGraph = poissonVertex.logProbGraph();\n LogProbGraphValueFeeder.feedValue(logProbGra...
{ "fields": [ { "declarator": "mu", "modifier": "private final", "original_string": "private final DoubleVertex mu;", "type": "DoubleVertex", "var_name": "mu" }, { "declarator": "MU_NAME = \"mu\"", "modifier": "private static final", "original_string": "priv...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n IntegerPlaceholderVertex valuePlaceholder = new IntegerPlaceholderVertex(this.getShape());\n DoublePlaceholderVertex muPlaceholder = new DoublePlaceholderVertex(mu.getShape());\n\n return LogProbGraph.builder()\n .input(t...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_51
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/generic/GenericTensorTest.java", "identifier": "GenericTensorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canDiagFromVector() {\n GenericTensor<String> expected = GenericTensor.create(new String[]{\"1\", null, null, null, \"5\", null, null, null, \"9\"}).reshape(3, 3);\n GenericTensor<String> actual = GenericTensor.create(\"1\", \"5\", \"9\").diag();\n\n assertEquals...
{ "fields": [ { "declarator": "factory = new GenericBuffer.GenericArrayWrapperFactory()", "modifier": "private static final", "original_string": "private static final GenericBuffer.GenericArrayWrapperFactory factory = new GenericBuffer.GenericArrayWrapperFactory();", "type": "GenericBuffer...
{ "body": "public static <T> GenericTensor<T> create(T... data) {\n return create(data, new long[]{data.length});\n }", "class_method_signature": "GenericTensor.create(T... data)", "constructor": false, "full_signature": "public static GenericTensor<T> create(T... data)", "identifier": "create", "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_191
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfScalar() {\n DoubleVertex alpha = ConstantVertex.of(2.);\n DoubleVertex beta = ConstantVertex.of(1.);\n InverseGammaVertex tensorInverseGammaVertex = new InverseGammaVertex(alpha, beta);\n LogProbGraph logProbGraph = ten...
{ "fields": [ { "declarator": "alpha", "modifier": "private final", "original_string": "private final DoubleVertex alpha;", "type": "DoubleVertex", "var_name": "alpha" }, { "declarator": "beta", "modifier": "private final", "original_string": "private final ...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex alphaPlaceholder = new DoublePlaceholderVertex(alpha.getShape());\n final DoublePlaceholderVertex betaPlaceho...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_312
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/algorithms/graphtraversal/MarkovBlanketTest.java", "identifier": "MarkovBlanketTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void findBlanketFromDoubleDiamondWithDeterministicGraph() {\n\n DoubleVertex A = new GaussianVertex(5.0, 1.0);\n DoubleVertex B = new GaussianVertex(A, 1.0);\n DoubleVertex C = new GaussianVertex(A, 1.0);\n DoubleVertex D = new GaussianVertex(B, C);\n Do...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/graphtraversal/MarkovBlanket.java", "identifier": "MarkovBlanket", "interfaces": "", "methods": [ { "class_method_signature": "MarkovBlanket.MarkovBlanket()", "constructor": true, "full_signature": "priva...
{ "body": "public static Set<Vertex> get(Vertex<?, ?> aVertex) {\n\n LambdaSection parents = LambdaSection.getUpstreamLambdaSection(aVertex, false);\n LambdaSection children = LambdaSection.getDownstreamLambdaSection(aVertex, false);\n Set<Vertex> childrensParents = getUpstreamProbabilisticVertic...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_257
{ "fields": [ { "declarator": "proposal", "modifier": "public", "original_string": "public Proposal proposal;", "type": "Proposal", "var_name": "proposal" }, { "declarator": "currentStateForVertex1 = DoubleTensor.create(4.2, 4.7)", "modifier": "private static fina...
{ "body": "@Test\n public void itThrowsIfYouUseItOnADiscreteVariable() {\n thrown.expect(IllegalStateException.class);\n thrown.expectMessage(\"Gaussian proposal function cannot be used for discrete variable\");\n PoissonVertex poisson = new PoissonVertex(1.);\n proposalDistribution.get...
{ "fields": [ { "declarator": "sigmas", "modifier": "private final", "original_string": "private final Map<? extends Variable, DoubleTensor> sigmas;", "type": "Map<? extends Variable, DoubleTensor>", "var_name": "sigmas" }, { "declarator": "proposalNotifier", "mod...
{ "body": "@Override\n public Proposal getProposal(Set<? extends Variable> variables, KeanuRandom random) {\n Proposal proposal = new Proposal();\n for (Variable variable : variables) {\n if (!(variable.getValue() instanceof DoubleTensor)) {\n throw new IllegalStateException...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_168
{ "fields": [ { "declarator": "N = 100000", "modifier": "private", "original_string": "private int N = 100000;", "type": "int", "var_name": "N" }, { "declarator": "lowerBound = 10.", "modifier": "private", "original_string": "private Double lowerBound = 10.;...
{ "body": "@Test\n public void logProbGraphLowerBoundIsNotNegativeInfinity() {\n DoubleVertex xMin = ConstantVertex.of(lowerBound);\n DoubleVertex xMax = ConstantVertex.of(upperBound);\n UniformVertex uniformVertex = new UniformVertex(xMin, xMax);\n LogProbGraph logProbGraph = uniformVe...
{ "fields": [ { "declarator": "xMin", "modifier": "private final", "original_string": "private final DoubleVertex xMin;", "type": "DoubleVertex", "var_name": "xMin" }, { "declarator": "xMax", "modifier": "private final", "original_string": "private final Dou...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex xMinPlaceholder = new DoublePlaceholderVertex(xMin.getShape());\n final DoublePlaceholderVertex xMaxPlacehold...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_187
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "TEST_VALUES_OF_V = new int[]{\n 1, 2, 3\n }", ...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfScalar() {\n IntegerVertex v = ConstantVertex.of(1);\n StudentTVertex studentT = new StudentTVertex(v);\n LogProbGraph logProbGraph = studentT.logProbGraph();\n\n LogProbGraphValueFeeder.feedValue(logProbGraph, v, v.getV...
{ "fields": [ { "declarator": "v", "modifier": "private final", "original_string": "private final IntegerVertex v;", "type": "IntegerVertex", "var_name": "v" }, { "declarator": "V_NAME = \"v\"", "modifier": "private static final", "original_string": "private...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final IntegerPlaceholderVertex vPlaceholder = new IntegerPlaceholderVertex(v.getShape());\n\n return LogProbGraph.builder()\n .i...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_304
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" }, { "declarator": "samples...
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void doesCatchInvalidDownSampleInterval() {\n samples.downSample(0);\n }", "class_method_signature": "NetworkSamplesTest.doesCatchInvalidDownSampleInterval()", "constructor": false, "full_signature": "@Test(expected = IllegalArgum...
{ "fields": [ { "declarator": "samplesByVariable", "modifier": "private final", "original_string": "private final Map<VariableReference, ? extends List> samplesByVariable;", "type": "Map<VariableReference, ? extends List>", "var_name": "samplesByVariable" }, { "declarat...
{ "body": "public NetworkSamples downSample(final int downSampleInterval) {\n Preconditions.checkArgument(downSampleInterval > 0, \"Down sample interval of %s is invalid. Sample interval must be positive.\", downSampleInterval);\n\n final Map<VariableReference, List<?>> withSamplesDownSampled = samplesB...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_241
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test(expected = IndexOutOfBoundsException.class)\n public void itThrowsIfYouRemoveExistingOuterNamespaceUntilThereIsNone() {\n VertexLabel foo = new VertexLabel(\"namespace\", \"foo\");\n foo = foo.withoutOuterNamespace();\n foo.withoutOuterNamespace();\n }", "class_method_sig...
{ "fields": [ { "declarator": "NAMESPACE_SEPARATOR = '.'", "modifier": "private static final", "original_string": "private static final char NAMESPACE_SEPARATOR = '.';", "type": "char", "var_name": "NAMESPACE_SEPARATOR" }, { "declarator": "namespace", "modifier": ...
{ "body": "public VertexLabel withoutOuterNamespace() {\n List<String> reducedNamespace = namespace.subList(1, namespace.size());\n return new VertexLabel(reducedNamespace, this.name);\n }", "class_method_signature": "VertexLabel.withoutOuterNamespace()", "constructor": false, "full_signature":...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_10
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" }, ...
{ "body": "@Test\n public void youCanGetTheMeanOfX() {\n assertThat(stats.xMean(), equalTo(xStats.getMean()));\n }", "class_method_signature": "BivariateDataStatisticsCalculatorTest.youCanGetTheMeanOfX()", "constructor": false, "full_signature": "@Test public void youCanGetTheMeanOfX()", "identif...
{ "fields": [ { "declarator": "xData", "modifier": "private final", "original_string": "private final DoubleTensor xData;", "type": "DoubleTensor", "var_name": "xData" }, { "declarator": "yData", "modifier": "private final", "original_string": "private final...
{ "body": "public double xMean() {\n return xData.mean().scalar();\n }", "class_method_signature": "BivariateDataStatisticsCalculator.xMean()", "constructor": false, "full_signature": "public double xMean()", "identifier": "xMean", "invocations": [ "scalar", "mean" ], "modifiers": "pub...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_6
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/TensorShapeTest.java", "identifier": "TensorShapeTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canGetShapeIndices() {\n Assert.assertArrayEquals(new long[]{2, 2}, TensorShape.getShapeIndices(new long[]{5, 4}, new long[]{4, 1}, 10));\n Assert.assertArrayEquals(new long[]{4, 3}, TensorShape.getShapeIndices(new long[]{5, 4}, new long[]{4, 1}, 19));\n Assert.a...
{ "fields": [ { "declarator": "shape", "modifier": "private", "original_string": "private long[] shape;", "type": "long[]", "var_name": "shape" } ], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShape.java", "identifier": "TensorShape", "interfaces...
{ "body": "public static long[] getShapeIndices(long[] shape, long[] stride, long flatIndex) {\n Preconditions.checkArgument(flatIndex >= 0, \"Flat index must be >= 0 and less than the length of the shape\");\n long[] shapeIndices = new long[stride.length];\n long remainder = flatIndex;\n ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_353
{ "fields": [ { "declarator": "log = LoggerFactory.getLogger(ChallengerDisasterTest.class)", "modifier": "private static final", "original_string": "private static final Logger log = LoggerFactory.getLogger(ChallengerDisasterTest.class);", "type": "Logger", "var_name": "log" } ...
{ "body": "@Test\n public void testWhenChallengerDisasterIsRunThenBetaIsSmallAndPositive() {\n ChallengerDisaster.ChallengerPosteriors posteriors = ChallengerDisaster.run();\n\n log.info(\"mapAlpha \" + posteriors.mapAlpha);\n log.info(\"mapBeta \" + posteriors.mapBeta);\n\n assertThat(...
{ "fields": [], "file": "keanu-examples/bayesianMethodsForHackers/src/main/java/com/examples/ChallengerDisaster.java", "identifier": "ChallengerDisaster", "interfaces": "", "methods": [ { "class_method_signature": "ChallengerDisaster.run()", "constructor": false, "full_signature": "publi...
{ "body": "public static ChallengerPosteriors run() {\n ChallengerData data = ReadCsv.fromResources(\"challenger_data.csv\")\n .asVectorizedColumnsDefinedBy(ChallengerData.class)\n .load();\n\n // These hyperparameters differ from the alpha used in the example book\n // This...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_47
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/generic/GenericTensorTest.java", "identifier": "GenericTensorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canGetRandomAccessValue() {\n\n GenericTensor<Something> somethingTensor = GenericTensor.create(\n new Something[]{\n Something.A, Something.B, Something.B,\n Something.C, Something.D, Something.B,\n Something.D, Somethin...
{ "fields": [ { "declarator": "factory = new GenericBuffer.GenericArrayWrapperFactory()", "modifier": "private static final", "original_string": "private static final GenericBuffer.GenericArrayWrapperFactory factory = new GenericBuffer.GenericArrayWrapperFactory();", "type": "GenericBuffer...
{ "body": "public static <T> GenericTensor<T> create(T... data) {\n return create(data, new long[]{data.length});\n }", "class_method_signature": "GenericTensor.create(T... data)", "constructor": false, "full_signature": "public static GenericTensor<T> create(T... data)", "identifier": "create", "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_216
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void itThrowsIfTheLogProbStateDoesntSumToN() {\n thrown.expect(IllegalArgumentException.class);\n thrown.expectMessage(\"The sum of x [12] must equal n [10.0]\");\n\n IntegerVertex n = ConstantVertex.of(10);\n DoubleVertex p = ConstantVertex.of(DoubleTensor.cre...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public double logProb(IntegerTensor x) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber();\n }", "class_method_signature": "MultinomialVertex.logProb(IntegerTensor x)", "constructor": false, "full_signature": "@Override...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_147
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void canLogProbWithBatchMu() {\n DoubleTensor mu = DoubleTensor.create(-1, 2, 0.5, 1.5).reshape(2, 2);\n DoubleTensor sigma = DoubleTensor.create(0.5, 1.0);\n GaussianVertex g = new GaussianVertex(mu, sigma);\n DoubleTensor sample = g.sample();\n\n asser...
{ "fields": [ { "declarator": "mu", "modifier": "private final", "original_string": "private final DoubleVertex mu;", "type": "DoubleVertex", "var_name": "mu" }, { "declarator": "sigma", "modifier": "private final", "original_string": "private final DoubleVe...
{ "body": "@Override\n public double logProb(DoubleTensor value) {\n\n DoubleTensor muValues = mu.getValue();\n DoubleTensor sigmaValues = sigma.getValue();\n\n DoubleTensor logPdfs = Gaussian.withParameters(muValues, sigmaValues).logProb(value);\n\n return logPdfs.sumNumber();\n }",...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_281
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" } ], "file": "keanu-project/src/test/java...
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void doesValidateInitialStepSize() {\n NUTS.builder().initialStepSize(-0.1);\n }", "class_method_signature": "NUTSTest.doesValidateInitialStepSize()", "constructor": false, "full_signature": "@Test(expected = IllegalArgumentExcept...
{ "fields": [ { "declarator": "random", "modifier": "@Getter\n private final", "original_string": "@Getter\n private final KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" }, { "declarator": "targetAcceptanceProb", "modifier": "@Getter\n ...
{ "body": "public static NUTSBuilder builder() {\n return new NUTSBuilder();\n }", "class_method_signature": "NUTS.builder()", "constructor": false, "full_signature": "public static NUTSBuilder builder()", "identifier": "builder", "invocations": [], "modifiers": "public static", "parameters": ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_110
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" } ], "file": "keanu-project/src/test/java...
{ "body": "@Test\n public void logProbGraphClampsProbTrueTo0() {\n DoubleVertex probTrue = ConstantVertex.of(-1.);\n BernoulliVertex bernoulliVertex = new BernoulliVertex(probTrue);\n LogProbGraph logProbGraph = bernoulliVertex.logProbGraph();\n LogProbGraphValueFeeder.feedValue(logProb...
{ "fields": [ { "declarator": "probTrue", "modifier": "private final", "original_string": "private final DoubleVertex probTrue;", "type": "DoubleVertex", "var_name": "probTrue" }, { "declarator": "PROBTRUE_NAME = \"probTrue\"", "modifier": "private final static", ...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n BooleanPlaceholderVertex valuePlaceholder = new BooleanPlaceholderVertex(this.getShape());\n DoublePlaceholderVertex probTruePlaceholder = new DoublePlaceholderVertex(probTrue.getShape());\n\n return LogProbGraph.builder()\n ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_87
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" }, { "declarator": "network...
{ "body": "@Test\n public void youCanObserveAProbabilisticVariableAfterCreatingTheNetwork() {\n assertThat(network.getObservedVertices(), is(empty()));\n input1.observe(true);\n assertThat(network.getObservedVertices(), contains(input1));\n input2.observe(true);\n assertThat(netw...
{ "fields": [ { "declarator": "vertices", "modifier": "private final", "original_string": "private final List<? extends Vertex> vertices;", "type": "List<? extends Vertex>", "var_name": "vertices" }, { "declarator": "vertexLabels", "modifier": "private final", ...
{ "body": "public List<Vertex> getObservedVertices() {\n return getObservedVertices(Integer.MAX_VALUE);\n }", "class_method_signature": "BayesianNetwork.getObservedVertices()", "constructor": false, "full_signature": "public List<Vertex> getObservedVertices()", "identifier": "getObservedVertices", ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_68
{ "fields": [ { "declarator": "samples", "modifier": "private", "original_string": "private NetworkSamples samples;", "type": "NetworkSamples", "var_name": "samples" }, { "declarator": "rowTensors = new ArrayList<>()", "modifier": "private", "original_string...
{ "body": "@Test\n public void writeColumnOfTensorsToCsvWithCustomEmptyValue() throws IOException {\n File file = WriteCsv.asColumns(columnTensors).withEmptyValue(\"None\").toFile(File.createTempFile(\"test\", \".csv\"));\n\n CsvReader reader = ReadCsv.fromFile(file).expectHeader(false);\n Lis...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/util/csv/WriteCsv.java", "identifier": "WriteCsv", "interfaces": "", "methods": [ { "class_method_signature": "WriteCsv.asSamples(NetworkSamples samples, List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructo...
{ "body": "public static ColumnWriter asColumns(List<? extends Vertex<? extends Tensor, ?>> vertices) {\n return new ColumnWriter(vertices);\n }", "class_method_signature": "WriteCsv.asColumns(List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructor": false, "full_signature": "public stati...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_239
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void youCanDiminishTheNamespace() {\n String innerNamespace = \"inner\";\n String outerNamespace = \"outer\";\n String name = \"foo\";\n VertexLabel foo = new VertexLabel(outerNamespace, innerNamespace, name);\n VertexLabel newFoo = foo.withoutOuterNames...
{ "fields": [ { "declarator": "NAMESPACE_SEPARATOR = '.'", "modifier": "private static final", "original_string": "private static final char NAMESPACE_SEPARATOR = '.';", "type": "char", "var_name": "NAMESPACE_SEPARATOR" }, { "declarator": "namespace", "modifier": ...
{ "body": "public VertexLabel withoutOuterNamespace() {\n List<String> reducedNamespace = namespace.subList(1, namespace.size());\n return new VertexLabel(reducedNamespace, this.name);\n }", "class_method_signature": "VertexLabel.withoutOuterNamespace()", "constructor": false, "full_signature":...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_106
{ "fields": [ { "declarator": "innerNet", "modifier": "private", "original_string": "private BayesianNetwork innerNet;", "type": "BayesianNetwork", "var_name": "innerNet" }, { "declarator": "trueLocation", "modifier": "private", "original_string": "private U...
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void willRejectProxyWithParent() {\n DoubleProxyVertex proxy = new DoubleProxyVertex(new VertexLabel(\"Input1\"));\n DoubleVertex output = new GaussianVertex(proxy, 1.0);\n output.setLabel(\"Output1\");\n DoubleVertex ...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/network/ModelComposition.java", "identifier": "ModelComposition", "interfaces": "", "methods": [ { "class_method_signature": "ModelComposition.ModelComposition()", "constructor": true, "full_signature": "private Mo...
{ "body": "public static Map<VertexLabel, Vertex> composeModel(BayesianNetwork bayesianNetwork,\n Map<VertexLabel, Vertex> inputVertices,\n List<VertexLabel> desiredOutputs) {\n Map<VertexLabel, Vertex...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_91
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" }, { "declarator": "network...
{ "body": "@Test\n public void testGetNumVertices() {\n assertThat(network.getVertexCount(), equalTo(connectedGraph.size()));\n }", "class_method_signature": "BayesianNetworkTest.testGetNumVertices()", "constructor": false, "full_signature": "@Test public void testGetNumVertices()", "identifier":...
{ "fields": [ { "declarator": "vertices", "modifier": "private final", "original_string": "private final List<? extends Vertex> vertices;", "type": "List<? extends Vertex>", "var_name": "vertices" }, { "declarator": "vertexLabels", "modifier": "private final", ...
{ "body": "public int getVertexCount() {\n return getVertices().size();\n }", "class_method_signature": "BayesianNetwork.getVertexCount()", "constructor": false, "full_signature": "public int getVertexCount()", "identifier": "getVertexCount", "invocations": [ "size", "getVertices" ], "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_151
{ "fields": [ { "declarator": "random", "modifier": "private", "original_string": "private KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" }, { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_st...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfVector() {\n DoubleVertex xMin = ConstantVertex.of(0., 0.);\n DoubleVertex xMax = ConstantVertex.of(20., 20.);\n DoubleVertex c = ConstantVertex.of(10., 10.);\n TriangularVertex triangularVertex = new TriangularVertex(xM...
{ "fields": [ { "declarator": "xMin", "modifier": "private final", "original_string": "private final DoubleVertex xMin;", "type": "DoubleVertex", "var_name": "xMin" }, { "declarator": "xMax", "modifier": "private final", "original_string": "private final Dou...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex xMinPlaceholder = new DoublePlaceholderVertex(xMin.getShape());\n final DoublePlaceholderVertex xMaxPlacehold...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_297
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" } ], "file": "keanu-project/src/test/java...
{ "body": "@Test\n public void samplesFromPriorWithObservedDeterministic() {\n\n BernoulliVertex A = new BernoulliVertex(0.5);\n BernoulliVertex B = new BernoulliVertex(0.5);\n BooleanVertex C = A.or(B);\n C.observe(false);\n\n BayesianNetwork net = new BayesianNetwork(A.getConne...
{ "fields": [ { "declarator": "DEFAULT_VARIABLE_SELECTOR = SINGLE_VARIABLE_SELECTOR", "modifier": "private static final", "original_string": "private static final MHStepVariableSelector DEFAULT_VARIABLE_SELECTOR = SINGLE_VARIABLE_SELECTOR;", "type": "MHStepVariableSelector", "var_nam...
{ "body": "@Override\n public NetworkSamples getPosteriorSamples(ProbabilisticModel model,\n List<? extends Variable> variablesToSampleFrom,\n int sampleCount) {\n return generatePosteriorSamples(model, variablesToSamp...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_29
{ "fields": [ { "declarator": "scalar1 = new long[0]", "modifier": "private", "original_string": "private long[] scalar1 = new long[0];", "type": "long[]", "var_name": "scalar1" }, { "declarator": "scalar2 = new long[0]", "modifier": "private", "original_str...
{ "body": "@Test\n public void checkIsNotBroadcastableWithShapeMismatch() {\n\n long[] a = new long[]{2, 1, 2, 2};\n long[] b = new long[]{4, 3, 2, 2};\n\n assertFalse(TensorShapeValidation.isBroadcastable(a, b));\n }", "class_method_signature": "TensorShapeValidationTest.checkIsNotBroadc...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShapeValidation.java", "identifier": "TensorShapeValidation", "interfaces": "", "methods": [ { "class_method_signature": "TensorShapeValidation.TensorShapeValidation()", "constructor": true, "full_signa...
{ "body": "public static boolean isBroadcastable(long[] left, long[] right) {\n try {\n TensorShape.getBroadcastResultShape(left, right);\n return true;\n } catch (IllegalArgumentException e) {\n return false;\n }\n }", "class_method_signature": "TensorShapeV...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_278
{ "fields": [ { "declarator": "vertex", "modifier": "private", "original_string": "private GaussianVertex vertex;", "type": "GaussianVertex", "var_name": "vertex" }, { "declarator": "gradientCalculator", "modifier": "private", "original_string": "private Kea...
{ "body": "@Test\n public void leapsForwardWithMinimalEnergyLoss() {\n\n LeapfrogState leap = start;\n for (int i = 0; i < 1000; i++) {\n leap = integrator.step(leap, gradientCalculator, 1e-3);\n }\n\n assertEquals(start.getEnergy(), leap.getEnergy(), 1e-6);\n }", "class...
{ "fields": [ { "declarator": "potential", "modifier": "private final", "original_string": "private final Potential potential;", "type": "Potential", "var_name": "potential" } ], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/mcmc/nuts/LeapfrogIntegrator....
{ "body": "public LeapfrogState step(LeapfrogState fromState, final ProbabilisticModelWithGradient logProbGradientCalculator, final double timeStep) {\n\n final double halfTimeStep = timeStep / 2.0;\n\n Map<VariableReference, DoubleTensor> nextMomentum = stepMomentum(halfTimeStep, fromState.getMomentum(...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_52
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/generic/GenericTensorTest.java", "identifier": "GenericTensorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canDiagFromMatrix() {\n GenericTensor<String> actual = GenericTensor.create(new String[]{\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"}).reshape(3, 3).diagPart();\n GenericTensor<String> expected = GenericTensor.create(\"1\", \"5\", \"9\");\n\n as...
{ "fields": [ { "declarator": "factory = new GenericBuffer.GenericArrayWrapperFactory()", "modifier": "private static final", "original_string": "private static final GenericBuffer.GenericArrayWrapperFactory factory = new GenericBuffer.GenericArrayWrapperFactory();", "type": "GenericBuffer...
{ "body": "public static <T> GenericTensor<T> create(T... data) {\n return create(data, new long[]{data.length});\n }", "class_method_signature": "GenericTensor.create(T... data)", "constructor": false, "full_signature": "public static GenericTensor<T> create(T... data)", "identifier": "create", "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_203
{ "fields": [ { "declarator": "N = 100000", "modifier": "private", "original_string": "private int N = 100000;", "type": "int", "var_name": "N" }, { "declarator": "epsilon = 0.05", "modifier": "private", "original_string": "private double epsilon = 0.05;", ...
{ "body": "@Test\n public void logProbUpperBoundIsNegativeInfinity() {\n UniformIntVertex testUniformVertex = new UniformIntVertex(new long[]{1, N}, lowerBound, upperBound);\n assertEquals(testUniformVertex.logProb(IntegerTensor.scalar(upperBound)), Double.NEGATIVE_INFINITY, 1e-6);\n }", "class_...
{ "fields": [ { "declarator": "min", "modifier": "private", "original_string": "private IntegerVertex min;", "type": "IntegerVertex", "var_name": "min" }, { "declarator": "max", "modifier": "private", "original_string": "private IntegerVertex max;", "t...
{ "body": "@Override\n public double logProb(IntegerTensor value) {\n return UniformInt.withParameters(min.getValue(), max.getValue()).logProb(value).sumNumber();\n }", "class_method_signature": "UniformIntVertex.logProb(IntegerTensor value)", "constructor": false, "full_signature": "@Override publ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_346
{ "fields": [ { "declarator": "random", "modifier": "private", "original_string": "private KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" } ], "file": "keanu-project/src/test/java/io/improbable/keanu/KeanuRandomTest.java", "identifier": "KeanuRandomTest",...
{ "body": "@Test\n public void canSampleGammaScalar() {\n assertEquals(0, random.nextGamma(new long[0], DoubleTensor.scalar(2), DoubleTensor.scalar(2)).getRank());\n assertEquals(1, random.nextGamma(new long[]{1}, DoubleTensor.scalar(2), DoubleTensor.scalar(2)).getRank());\n assertEquals(2, ra...
{ "fields": [ { "declarator": "DEFAULT_RANDOM = new AtomicReference<>()", "modifier": "private static final", "original_string": "private static final AtomicReference<KeanuRandom> DEFAULT_RANDOM = new AtomicReference<>();", "type": "AtomicReference<KeanuRandom>", "var_name": "DEFAULT...
{ "body": "public DoubleTensor nextGamma(long[] shape, DoubleTensor theta, DoubleTensor k) {\n return Gamma.withParameters(theta, k).sample(shape, this);\n }", "class_method_signature": "KeanuRandom.nextGamma(long[] shape, DoubleTensor theta, DoubleTensor k)", "constructor": false, "full_signature": "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_192
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfVector() {\n DoubleVertex alpha = ConstantVertex.of(2., 2.);\n DoubleVertex beta = ConstantVertex.of(1., 1.);\n InverseGammaVertex tensorInverseGammaVertex = new InverseGammaVertex(alpha, beta);\n LogProbGraph logProbGra...
{ "fields": [ { "declarator": "alpha", "modifier": "private final", "original_string": "private final DoubleVertex alpha;", "type": "DoubleVertex", "var_name": "alpha" }, { "declarator": "beta", "modifier": "private final", "original_string": "private final ...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex alphaPlaceholder = new DoublePlaceholderVertex(alpha.getShape());\n final DoublePlaceholderVertex betaPlaceho...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_254
{ "fields": [ { "declarator": "deterministicRule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule deterministicRule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "deterministicRule" } ],...
{ "body": "@Test\n public void increasingSequenceReturnsCorrectAutocorr() {\n double[] samples = {1, 2, 3, 4, 5, 6, 7, 8};\n double[] autocorr = Autocorrelation.calculate(samples);\n double[] expected = {1., 0.625, 0.27380952, -0.0297619, -0.26190476,\n -0.39880952, -0.41666667, -0....
{ "fields": [ { "declarator": "ffTransformer = new FastFourierTransformer(DftNormalization.STANDARD)", "modifier": "private static final", "original_string": "private static final FastFourierTransformer ffTransformer = new FastFourierTransformer(DftNormalization.STANDARD);", "type": "FastF...
{ "body": "public static double[] calculate(double[] samples) {\n double[] acovResult = autocovariance(samples);\n double variance = acovResult[0];\n double[] autocorr = Arrays.stream(acovResult).map(x -> x / variance).toArray();\n return autocorr;\n }", "class_method_signature": "Aut...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_311
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/algorithms/graphtraversal/MarkovBlanketTest.java", "identifier": "MarkovBlanketTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void findBlanketFromSimpleGraph() {\n\n DoubleVertex A = new GaussianVertex(5.0, 1.0);\n DoubleVertex B = new GaussianVertex(5.0, 1.0);\n DoubleVertex C = new GaussianVertex(A, B);\n\n Set<Vertex> blanket = MarkovBlanket.get(C);\n\n assertTrue(blanket.si...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/graphtraversal/MarkovBlanket.java", "identifier": "MarkovBlanket", "interfaces": "", "methods": [ { "class_method_signature": "MarkovBlanket.MarkovBlanket()", "constructor": true, "full_signature": "priva...
{ "body": "public static Set<Vertex> get(Vertex<?, ?> aVertex) {\n\n LambdaSection parents = LambdaSection.getUpstreamLambdaSection(aVertex, false);\n LambdaSection children = LambdaSection.getDownstreamLambdaSection(aVertex, false);\n Set<Vertex> childrensParents = getUpstreamProbabilisticVertic...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_184
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfNegativeScalar() {\n\n DoubleVertex scale = ConstantVertex.of(1.);\n HalfCauchyVertex halfCauchyVertex = new HalfCauchyVertex(scale);\n LogProbGraph logProbGraph = halfCauchyVertex.logProbGraph();\n LogProbGraphValueFeed...
{ "fields": [ { "declarator": "LOC_ZERO = 0.0", "modifier": "private static final", "original_string": "private static final double LOC_ZERO = 0.0;", "type": "double", "var_name": "LOC_ZERO" }, { "declarator": "LOG_TWO = Math.log(2)", "modifier": "private static f...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex locationPlaceholder = new DoublePlaceholderVertex(getLocation().getShape());\n final DoublePlaceholderVertex ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_13
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" }, ...
{ "body": "@Test\n public void theMeanSquaredErrorIsZeroWhenTheDataIsPerfectlyCorrelated() {\n BivariateDataStatisticsCalculator perfectStats = new BivariateDataStatisticsCalculator(X_DATA, X_DATA.times(2.).plus(42.));\n assertThat(perfectStats.meanSquaredError(), equalTo(0.));\n }", "class_meth...
{ "fields": [ { "declarator": "xData", "modifier": "private final", "original_string": "private final DoubleTensor xData;", "type": "DoubleTensor", "var_name": "xData" }, { "declarator": "yData", "modifier": "private final", "original_string": "private final...
{ "body": "public double meanSquaredError() {\n DoubleTensor calculatedY = xData.times(estimatedGradient()).plusInPlace(estimatedIntercept());\n DoubleTensor residuals = yData.minus(calculatedY);\n long unbiasedMultiplier = size() - 2;\n return residuals.times(residuals).sumNumber() / unbi...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_242
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void isInNamespaceOfEqualValue() {\n VertexLabel label = new VertexLabel(\"outer\", \"inner\", \"foo\");\n assertTrue(label.isInNamespace(\"outer\", \"inner\"));\n }", "class_method_signature": "VertexLabelTest.isInNamespaceOfEqualValue()", "constructor": false, "fu...
{ "fields": [ { "declarator": "NAMESPACE_SEPARATOR = '.'", "modifier": "private static final", "original_string": "private static final char NAMESPACE_SEPARATOR = '.';", "type": "char", "var_name": "NAMESPACE_SEPARATOR" }, { "declarator": "namespace", "modifier": ...
{ "body": "public boolean isInNamespace(String... namespace) {\n\n if (namespace.length > this.namespace.size()) {\n return false;\n }\n\n for (int i = 0; i < namespace.length; i++) {\n if (!this.namespace.get(i).equals(namespace[i])) {\n return false;\n ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_307
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/algorithms/graphtraversal/TopologicalSortTest.java", "identifier": "TopologicalSortTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void sortsSimpleLinearGraph() {\n\n DoubleVertex A = new GaussianVertex(5.0, 1.0);\n DoubleVertex B = new GaussianVertex(A, 1.0);\n DoubleVertex C = new GaussianVertex(B, 1.0);\n\n List<? extends Vertex> sorted = TopologicalSort.sort(Arrays.asList(C, B, A));\n ...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/graphtraversal/TopologicalSort.java", "identifier": "TopologicalSort", "interfaces": "", "methods": [ { "class_method_signature": "TopologicalSort.TopologicalSort()", "constructor": true, "full_signature"...
{ "body": "public static List<Vertex> sort(Collection<? extends Vertex> vertices) {\n return vertices\n .stream()\n .sorted(Comparator.comparing(Vertex::getId, Comparator.naturalOrder()))\n .collect(Collectors.toList());\n }", "class_method_signature": "TopologicalSort.sor...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_5
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/TensorShapeTest.java", "identifier": "TensorShapeTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void doesThrowOnInvalidPositiveAbsoluteDimensionsFromRelative() {\n TensorShape.getAbsoluteDimensions(3, new int[]{3, 1, 2});\n }", "class_method_signature": "TensorShapeTest.doesThrowOnInvalidPositiveAbsoluteDimensionsFromRelative()"...
{ "fields": [ { "declarator": "shape", "modifier": "private", "original_string": "private long[] shape;", "type": "long[]", "var_name": "shape" } ], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShape.java", "identifier": "TensorShape", "interfaces...
{ "body": "public static int[] getAbsoluteDimensions(int rank, int[] input) {\n int[] output = new int[input.length];\n for (int i = 0; i < output.length; i++) {\n output[i] = getAbsoluteDimension(input[i], rank);\n }\n return output;\n }", "class_method_signature": "Tensor...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_215
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void itThrowsIfTheLogProbShapeDoesntMatchTheNumberOfCategories() {\n thrown.expect(IllegalArgumentException.class);\n thrown.expectMessage(\"x shape must have far right dimension matching number of categories k 4\");\n\n IntegerTensor n = IntegerTensor.create(100);\n ...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public double logProb(IntegerTensor x) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber();\n }", "class_method_signature": "MultinomialVertex.logProb(IntegerTensor x)", "constructor": false, "full_signature": "@Override...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_44
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" } ], "file": "keanu-project/src/t...
{ "body": "@Test\n public void canBroadcastToShape() {\n BooleanTensor a = BooleanTensor.create(\n true, false, true\n ).reshape(3);\n\n BooleanTensor expectedByRow = BooleanTensor.create(\n true, false, true,\n true, false, true,\n true, false, true...
{ "fields": [ { "declarator": "factory = BooleanBuffer.factory", "modifier": "private static final", "original_string": "private static final BooleanBuffer.BooleanArrayWrapperFactory factory = BooleanBuffer.factory;", "type": "BooleanBuffer.BooleanArrayWrapperFactory", "var_name": "f...
{ "body": "@Override\n protected JVMBooleanTensor create(BooleanBuffer.PrimitiveBooleanWrapper buffer, long[] shape, long[] stride) {\n return new JVMBooleanTensor(buffer, shape, stride);\n }", "class_method_signature": "JVMBooleanTensor.create(BooleanBuffer.PrimitiveBooleanWrapper buffer, long[] shape...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_350
{ "fields": [ { "declarator": "numberOfStudents = 100", "modifier": "private final", "original_string": "private final int numberOfStudents = 100;", "type": "int", "var_name": "numberOfStudents" }, { "declarator": "numberOfYesAnswers = 35", "modifier": "private fi...
{ "body": "@Test\n public void doesWorkWithHigherDimensionDescription() {\n double approximateProbabilityOfCheating = CheatingStudents.runWithBernoulli(numberOfStudents, numberOfYesAnswers);\n assertEquals(0.2, approximateProbabilityOfCheating, 0.05);\n }", "class_method_signature": "CheatingStu...
{ "fields": [], "file": "keanu-examples/bayesianMethodsForHackers/src/main/java/com/examples/CheatingStudents.java", "identifier": "CheatingStudents", "interfaces": "", "methods": [ { "class_method_signature": "CheatingStudents.runWithBernoulli(int numberOfStudents, int numberOfYesAnswers)", "...
{ "body": "public static double runWithBernoulli(int numberOfStudents, int numberOfYesAnswers) {\n\n int numberOfSamples = 2000;\n UniformVertex probabilityOfCheating = new UniformVertex(0.0, 1.0);\n BooleanVertex studentCheated = new BernoulliVertex(new long[]{numberOfStudents}, probabilityOfChe...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_327
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void itThrowsWhenManyAreStoredButOneIsRequested() throws IOException {\n expectedException.expect(SequenceConstructionException.class);\n expectedException.expectMessage(\"The provided BayesianNetwork contains more than one Sequence\");\n\n VertexLabel x1Label = new V...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/templating/SequenceLoader.java", "identifier": "SequenceLoader", "interfaces": "", "methods": [ { "class_method_signature": "SequenceLoader.loadFromBayesNet(BayesianNetwork network)", "constructor": false, "full_sig...
{ "body": "public static Sequence loadFromBayesNet(BayesianNetwork network) {\n Collection<Sequence> sequences = loadSequences(network, false).values();\n return sequences.stream().findFirst().get();\n }", "class_method_signature": "SequenceLoader.loadFromBayesNet(BayesianNetwork network)", "cons...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_33
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" } ], "file": "keanu-project/src/t...
{ "body": "@Test\n public void youCanCreateARankOneTensor() {\n BooleanTensor booleanVector = BooleanTensor.create(new boolean[]{true, false, false, true, true}, new long[]{5});\n assertTrue(booleanVector.getValue(3));\n assertEquals(1, booleanVector.getRank());\n }", "class_method_signat...
{ "fields": [ { "declarator": "factory = BooleanBuffer.factory", "modifier": "private static final", "original_string": "private static final BooleanBuffer.BooleanArrayWrapperFactory factory = BooleanBuffer.factory;", "type": "BooleanBuffer.BooleanArrayWrapperFactory", "var_name": "f...
{ "body": "@Override\n protected JVMBooleanTensor create(BooleanBuffer.PrimitiveBooleanWrapper buffer, long[] shape, long[] stride) {\n return new JVMBooleanTensor(buffer, shape, stride);\n }", "class_method_signature": "JVMBooleanTensor.create(BooleanBuffer.PrimitiveBooleanWrapper buffer, long[] shape...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_262
{ "fields": [ { "declarator": "vertex1 = mock(Vertex.class)", "modifier": "private", "original_string": "private Vertex vertex1 = mock(Vertex.class);", "type": "Vertex", "var_name": "vertex1" }, { "declarator": "vertex2 = mock(Vertex.class)", "modifier": "private"...
{ "body": "@Test\n public void youCanTrackTheAcceptanceRateForDifferentSetsOfVertices() {\n Proposal proposal = new Proposal();\n proposal.setProposal(vertex1, 1.);\n notifier.notifyProposalCreated(proposal);\n notifier.notifyProposalRejected();\n assertThat(acceptanceRateTracker...
{ "fields": [ { "declarator": "numApplied = Maps.newHashMap()", "modifier": "private", "original_string": "private Map<VariableReference, Counter> numApplied = Maps.newHashMap();", "type": "Map<VariableReference, Counter>", "var_name": "numApplied" }, { "declarator": "n...
{ "body": "public double getAcceptanceRate(VariableReference variableReference) {\n if (!numApplied.keySet().contains(variableReference)) {\n throw new IllegalStateException(\"No proposals have been registered for \" + variableReference);\n }\n return 1. - (double) numRejected.getOrDef...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_235
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void youCanSetTheNamespace() {\n String namespace = \"namespace\";\n String name = \"foo\";\n VertexLabel foo = new VertexLabel(name);\n VertexLabel newFoo = foo.withExtraNamespace(namespace);\n assertThat(newFoo, equalTo(new VertexLabel(namespace, name)...
{ "fields": [ { "declarator": "NAMESPACE_SEPARATOR = '.'", "modifier": "private static final", "original_string": "private static final char NAMESPACE_SEPARATOR = '.';", "type": "char", "var_name": "NAMESPACE_SEPARATOR" }, { "declarator": "namespace", "modifier": ...
{ "body": "public VertexLabel withExtraNamespace(String topLevelNamespace) {\n List<String> newNamespace = ImmutableList.<String>builder().add(topLevelNamespace).addAll(namespace).build();\n return new VertexLabel(newNamespace, this.name);\n }", "class_method_signature": "VertexLabel.withExtraNames...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_64
{ "fields": [ { "declarator": "csv = \"a,b,c\\nhel,lo,world\"", "modifier": "", "original_string": "String csv = \"a,b,c\\nhel,lo,world\";", "type": "String", "var_name": "csv" } ], "file": "keanu-project/src/test/java/io/improbable/keanu/util/csv/ReadCsvTest.java", "identi...
{ "body": "@Test\n public void canReadFromFile() throws IOException {\n Path temp = Files.createTempFile(\"simple_data\", \".csv\");\n Files.write(temp, csv.getBytes());\n temp.toFile().deleteOnExit();\n\n CsvReader csvReader = ReadCsv.fromFile(temp);\n canRead(csvReader);\n }...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/util/csv/ReadCsv.java", "identifier": "ReadCsv", "interfaces": "", "methods": [ { "class_method_signature": "ReadCsv.ReadCsv()", "constructor": true, "full_signature": "private ReadCsv()", "identifier": "Read...
{ "body": "public static CsvReader fromFile(File file) {\n return fromFile(file.toPath());\n }", "class_method_signature": "ReadCsv.fromFile(File file)", "constructor": false, "full_signature": "public static CsvReader fromFile(File file)", "identifier": "fromFile", "invocations": [ "fromFile"...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_72
{ "fields": [ { "declarator": "samples", "modifier": "private", "original_string": "private NetworkSamples samples;", "type": "NetworkSamples", "var_name": "samples" }, { "declarator": "rowTensors = new ArrayList<>()", "modifier": "private", "original_string...
{ "body": "@Test\n public void writeRowOfTensorsToCsvWithCustomEmptyValue() throws IOException {\n File file = WriteCsv.asRows(rowTensors).withEmptyValue(\"/\").toFile(File.createTempFile(\"test\", \".csv\"));\n\n CsvReader reader = ReadCsv.fromFile(file).expectHeader(false);\n List<List<Strin...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/util/csv/WriteCsv.java", "identifier": "WriteCsv", "interfaces": "", "methods": [ { "class_method_signature": "WriteCsv.asSamples(NetworkSamples samples, List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructo...
{ "body": "public static RowWriter asRows(List<? extends Vertex<? extends Tensor, ?>> vertices) {\n return new RowWriter(vertices);\n }", "class_method_signature": "WriteCsv.asRows(List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructor": false, "full_signature": "public static RowWriter ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_223
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void whenKEqualsTwoItsBinomial() {\n IntegerTensor n = IntegerTensor.scalar(10);\n DoubleTensor p = DoubleTensor.create(0.2, 0.8).reshape(1, 2);\n DiscreteDistribution multinomial = Multinomial.withParameters(n, p);\n DiscreteDistribution binomial = Binomial.wi...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public double logProb(IntegerTensor x) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber();\n }", "class_method_signature": "MultinomialVertex.logProb(IntegerTensor x)", "constructor": false, "full_signature": "@Override...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_331
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void bayesNetConstructionFailsWhenThereAreNoSequenceItems() {\n expectedException.expect(RuntimeException.class);\n expectedException.expectMessage(\"Bayesian Network construction failed because the Sequence contains no SequenceItems\");\n Sequence sequence = new Sequ...
{ "fields": [ { "declarator": "containedItems", "modifier": "private final", "original_string": "private final ArrayList<SequenceItem> containedItems;", "type": "ArrayList<SequenceItem>", "var_name": "containedItems" }, { "declarator": "uniqueIdentifier", "modifie...
{ "body": "public BayesianNetwork toBayesianNetwork() {\n if (containedItems.size() == 0) {\n throw new RuntimeException(\"Bayesian Network construction failed because the Sequence contains no SequenceItems\");\n }\n Optional<Vertex<?, ?>> seedVertex = containedItems\n .get(...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_274
{ "fields": [ { "declarator": "AReference", "modifier": "private", "original_string": "private VariableReference AReference;", "type": "VariableReference", "var_name": "AReference" }, { "declarator": "BReference", "modifier": "private", "original_string": "p...
{ "body": "@Test\n public void canZeros() {\n\n Map<VariableReference, DoubleTensor> result = VariableValues.zeros(left);\n\n DoubleTensor expectedA = DoubleTensor.create(0, 0);\n DoubleTensor expectedB = DoubleTensor.create(0, 0);\n\n assertEquals(expectedA, result.get(AReference));\n ...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/mcmc/nuts/VariableValues.java", "identifier": "VariableValues", "interfaces": "", "methods": [ { "class_method_signature": "VariableValues.VariableValues()", "constructor": true, "full_signature": "privat...
{ "body": "public static Map<VariableReference, DoubleTensor> zeros(Map<VariableReference, DoubleTensor> shapeLike) {\n return withShape(0.0, shapeLike);\n }", "class_method_signature": "VariableValues.zeros(Map<VariableReference, DoubleTensor> shapeLike)", "constructor": false, "full_signature": "pub...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_25
{ "fields": [ { "declarator": "scalar1 = new long[0]", "modifier": "private", "original_string": "private long[] scalar1 = new long[0];", "type": "long[]", "var_name": "scalar1" }, { "declarator": "scalar2 = new long[0]", "modifier": "private", "original_str...
{ "body": "@Test\n public void checkSquareMatrixAcceptsSquareMatrices() {\n TensorShapeValidation.checkShapeIsSquareMatrix(new long[]{3, 3});\n }", "class_method_signature": "TensorShapeValidationTest.checkSquareMatrixAcceptsSquareMatrices()", "constructor": false, "full_signature": "@Test public v...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShapeValidation.java", "identifier": "TensorShapeValidation", "interfaces": "", "methods": [ { "class_method_signature": "TensorShapeValidation.TensorShapeValidation()", "constructor": true, "full_signa...
{ "body": "public static void checkShapeIsSquareMatrix(long[] shape) {\n if (shape.length < 2) {\n throw new IllegalArgumentException(\"Input tensor must be a matrix\");\n }\n\n if (shape[shape.length - 1] != shape[shape.length - 2]) {\n throw new IllegalArgumentException(\"...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_126
{ "fields": [ { "declarator": "epsilon = 0.01", "modifier": "private static", "original_string": "private static double epsilon = 0.01;", "type": "double", "var_name": "epsilon" }, { "declarator": "N = 100000", "modifier": "private static", "original_string"...
{ "body": "@Category(Slow.class)\n @Test\n public void ofDirichletVertexUsesIntegerRangeByDefault() {\n final DoubleTensor concentration = DoubleTensor.create(1, 2, 3, 4, 5);\n final DirichletVertex dirichletVertex = new DirichletVertex(new ConstantDoubleVertex(concentration));\n final Cate...
{ "fields": [ { "declarator": "selectableValues", "modifier": "private final", "original_string": "private final Map<CATEGORY, DoubleVertex> selectableValues;", "type": "Map<CATEGORY, DoubleVertex>", "var_name": "selectableValues" } ], "file": "keanu-project/src/main/java/io/...
{ "body": "public static <CATEGORY> CategoricalVertex<CATEGORY> of(\n Map<CATEGORY, Double> selectableValues\n ) {\n return new CategoricalVertex<>(toDoubleVertices(selectableValues));\n }", "class_method_signature": "CategoricalVertex.of(\n Map<CATEGORY, Double> selectableValues\n )",...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_258
{ "fields": [ { "declarator": "proposal", "modifier": "public", "original_string": "public Proposal proposal;", "type": "Proposal", "var_name": "proposal" }, { "declarator": "currentStateForVertex1 = DoubleTensor.create(4.2, 4.7)", "modifier": "private static fina...
{ "body": "@Test\n public void getProposalThrowsIfProposalIsMissingASigmaForAVariable() {\n CauchyVertex notInProposalDistribution = new CauchyVertex(1., 1.);\n thrown.expect(IllegalStateException.class);\n thrown.expectMessage(\"A sigma was not specified for variable \" + notInProposalDistrib...
{ "fields": [ { "declarator": "sigmas", "modifier": "private final", "original_string": "private final Map<? extends Variable, DoubleTensor> sigmas;", "type": "Map<? extends Variable, DoubleTensor>", "var_name": "sigmas" }, { "declarator": "proposalNotifier", "mod...
{ "body": "@Override\n public Proposal getProposal(Set<? extends Variable> variables, KeanuRandom random) {\n Proposal proposal = new Proposal();\n for (Variable variable : variables) {\n if (!(variable.getValue() instanceof DoubleTensor)) {\n throw new IllegalStateException...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_171
{ "fields": [ { "declarator": "VERTEX_INCREMENT = 0.1", "modifier": "private final", "original_string": "private final double VERTEX_INCREMENT = 0.1;", "type": "double", "var_name": "VERTEX_INCREMENT" }, { "declarator": "random", "modifier": "private", "orig...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfScalar() {\n DoubleVertex location = ConstantVertex.of(1.);\n DoubleVertex scale = ConstantVertex.of(1.5);\n ParetoVertex paretoVertex = new ParetoVertex(location, scale);\n LogProbGraph logProbGraph = paretoVertex.logPr...
{ "fields": [ { "declarator": "scale", "modifier": "private final", "original_string": "private final DoubleVertex scale;", "type": "DoubleVertex", "var_name": "scale" }, { "declarator": "location", "modifier": "private final", "original_string": "private fi...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex locationPlaceholder = new DoublePlaceholderVertex(location.getShape());\n final DoublePlaceholderVertex scale...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_188
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "TEST_VALUES_OF_V = new int[]{\n 1, 2, 3\n }", ...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfVector() {\n IntegerVertex v = ConstantVertex.of(1, 1);\n StudentTVertex studentT = new StudentTVertex(v);\n LogProbGraph logProbGraph = studentT.logProbGraph();\n\n LogProbGraphValueFeeder.feedValue(logProbGraph, v, v.g...
{ "fields": [ { "declarator": "v", "modifier": "private final", "original_string": "private final IntegerVertex v;", "type": "IntegerVertex", "var_name": "v" }, { "declarator": "V_NAME = \"v\"", "modifier": "private static final", "original_string": "private...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final IntegerPlaceholderVertex vPlaceholder = new IntegerPlaceholderVertex(v.getShape());\n\n return LogProbGraph.builder()\n .i...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_167
{ "fields": [ { "declarator": "N = 100000", "modifier": "private", "original_string": "private int N = 100000;", "type": "int", "var_name": "N" }, { "declarator": "lowerBound = 10.", "modifier": "private", "original_string": "private Double lowerBound = 10.;...
{ "body": "@Test\n public void logProbLowerBoundIsNotNegativeInfinity() {\n UniformVertex testUniformVertex = new UniformVertex(new long[]{1, N}, lowerBound, upperBound);\n assertNotEquals(testUniformVertex.logProb(DoubleTensor.scalar(lowerBound)), Double.NEGATIVE_INFINITY, 1e-6);\n }", "class_m...
{ "fields": [ { "declarator": "xMin", "modifier": "private final", "original_string": "private final DoubleVertex xMin;", "type": "DoubleVertex", "var_name": "xMin" }, { "declarator": "xMax", "modifier": "private final", "original_string": "private final Dou...
{ "body": "@Override\n public double logProb(DoubleTensor value) {\n return Uniform.withParameters(xMin.getValue(), xMax.getValue()).logProb(value).sumNumber();\n }", "class_method_signature": "UniformVertex.logProb(DoubleTensor value)", "constructor": false, "full_signature": "@Override public dou...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_48
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/generic/GenericTensorTest.java", "identifier": "GenericTensorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canSetRandomAccessValue() {\n\n GenericTensor<Something> somethingTensor = GenericTensor.create(\n new Something[]{\n Something.A, Something.B, Something.B,\n Something.C, Something.D, Something.B,\n Something.D, Somethin...
{ "fields": [ { "declarator": "factory = new GenericBuffer.GenericArrayWrapperFactory()", "modifier": "private static final", "original_string": "private static final GenericBuffer.GenericArrayWrapperFactory factory = new GenericBuffer.GenericArrayWrapperFactory();", "type": "GenericBuffer...
{ "body": "public static <T> GenericTensor<T> create(T... data) {\n return create(data, new long[]{data.length});\n }", "class_method_signature": "GenericTensor.create(T... data)", "constructor": false, "full_signature": "public static GenericTensor<T> create(T... data)", "identifier": "create", "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_219
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void itThrowsIfTheLogProbStateContainsNumbersGreaterThanN() {\n thrown.expect(IllegalArgumentException.class);\n thrown.expectMessage(\"x must be >= 0 and <= n\");\n\n IntegerTensor n = IntegerTensor.scalar(10);\n DoubleTensor p = DoubleTensor.create(0.2, 0.3, ...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public double logProb(IntegerTensor x) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber();\n }", "class_method_signature": "MultinomialVertex.logProb(IntegerTensor x)", "constructor": false, "full_signature": "@Override...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_130
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/vertices/tensor/number/floating/dbl/nonprobabilistic/diff/LogProbGradientCalculatorTest.java", "identifier": "LogProbGradientCalculatorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canFindGradientOfSingleVariantGaussianWrtMultivariateLatent() {\n\n GaussianVertex A = new GaussianVertex(new long[]{3, 2}, 0, 1);\n GaussianVertex B = new GaussianVertex(A, 1);\n DoubleTensor bValue = DoubleTensor.create(new double[]{0.1, 0.2, 0.3, -0.2, -0.5, 0...
{ "fields": [ { "declarator": "logProbOfVertices", "modifier": "private final", "original_string": "private final Set<Vertex> logProbOfVertices;", "type": "Set<Vertex>", "var_name": "logProbOfVertices" }, { "declarator": "wrtVertices", "modifier": "private final",...
{ "body": "public Map<VertexId, DoubleTensor> getJointLogProbGradientWrtLatents() {\n LogProbGradients totalLogProbGradients = new LogProbGradients();\n\n for (final Vertex<?, ?> ofVertex : logProbOfVertices) {\n LogProbGradients logProbGradientOfVertex = reverseModeLogProbGradientWrtLatents(...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_9
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" }, ...
{ "body": "@Test\n public void youCanGetTheNumberOfSamples() {\n assertThat(stats.size(), equalTo(xStats.getN()));\n }", "class_method_signature": "BivariateDataStatisticsCalculatorTest.youCanGetTheNumberOfSamples()", "constructor": false, "full_signature": "@Test public void youCanGetTheNumberOfSa...
{ "fields": [ { "declarator": "xData", "modifier": "private final", "original_string": "private final DoubleTensor xData;", "type": "DoubleTensor", "var_name": "xData" }, { "declarator": "yData", "modifier": "private final", "original_string": "private final...
{ "body": "public long size() {\n return xData.getLength();\n }", "class_method_signature": "BivariateDataStatisticsCalculator.size()", "constructor": false, "full_signature": "public long size()", "identifier": "size", "invocations": [ "getLength" ], "modifiers": "public", "parameters":...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_131
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/vertices/tensor/number/floating/dbl/nonprobabilistic/diff/LogProbGradientCalculatorTest.java", "identifier": "LogProbGradientCalculatorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canFindGradientOfMultivariantGaussianWrtSingleVariateLatent() {\n\n GaussianVertex A = new GaussianVertex(0, 1);\n GaussianVertex B = new GaussianVertex(new long[]{3, 2}, A, 1);\n DoubleTensor bValue = DoubleTensor.create(new double[]{0.1, 0.2, 0.3, -0.2, -0.5, 0...
{ "fields": [ { "declarator": "logProbOfVertices", "modifier": "private final", "original_string": "private final Set<Vertex> logProbOfVertices;", "type": "Set<Vertex>", "var_name": "logProbOfVertices" }, { "declarator": "wrtVertices", "modifier": "private final",...
{ "body": "public Map<VertexId, DoubleTensor> getJointLogProbGradientWrtLatents() {\n LogProbGradients totalLogProbGradients = new LogProbGradients();\n\n for (final Vertex<?, ?> ofVertex : logProbOfVertices) {\n LogProbGradients logProbGradientOfVertex = reverseModeLogProbGradientWrtLatents(...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_8
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/TensorShapeTest.java", "identifier": "TensorShapeTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void throwsIfFlatIndexUnderflowsShape() {\n long[] shapeIndices = TensorShape.getShapeIndices(new long[]{5, 4}, new long[]{4, 1}, -1);\n }", "class_method_signature": "TensorShapeTest.throwsIfFlatIndexUnderflowsShape()", "constructo...
{ "fields": [ { "declarator": "shape", "modifier": "private", "original_string": "private long[] shape;", "type": "long[]", "var_name": "shape" } ], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShape.java", "identifier": "TensorShape", "interfaces...
{ "body": "public static long[] getShapeIndices(long[] shape, long[] stride, long flatIndex) {\n Preconditions.checkArgument(flatIndex >= 0, \"Flat index must be >= 0 and less than the length of the shape\");\n long[] shapeIndices = new long[stride.length];\n long remainder = flatIndex;\n ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_49
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/generic/GenericTensorTest.java", "identifier": "GenericTensorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canPermute() {\n GenericTensor<Something> somethingTensor = GenericTensor.create(\n Something.A, Something.B, Something.B,\n Something.C, Something.D, Something.B,\n Something.D, Something.A, Something.C\n ).reshape(3, 3);\n\n Gen...
{ "fields": [ { "declarator": "factory = new GenericBuffer.GenericArrayWrapperFactory()", "modifier": "private static final", "original_string": "private static final GenericBuffer.GenericArrayWrapperFactory factory = new GenericBuffer.GenericArrayWrapperFactory();", "type": "GenericBuffer...
{ "body": "public static <T> GenericTensor<T> create(T... data) {\n return create(data, new long[]{data.length});\n }", "class_method_signature": "GenericTensor.create(T... data)", "constructor": false, "full_signature": "public static GenericTensor<T> create(T... data)", "identifier": "create", "...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_218
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void itThrowsIfTheLogProbStateContainsNegativeNumbers() {\n thrown.expect(IllegalArgumentException.class);\n thrown.expectMessage(\"x must be >= 0 and <= n\");\n\n IntegerTensor n = IntegerTensor.scalar(10);\n DoubleTensor p = DoubleTensor.create(0.2, 0.8);\n ...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public double logProb(IntegerTensor x) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber();\n }", "class_method_signature": "MultinomialVertex.logProb(IntegerTensor x)", "constructor": false, "full_signature": "@Override...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_189
{ "fields": [ { "declarator": "random", "modifier": "private", "original_string": "private KeanuRandom random;", "type": "KeanuRandom", "var_name": "random" }, { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private ...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfScalar() {\n DoubleVertex theta = ConstantVertex.of(1.5);\n DoubleVertex k = ConstantVertex.of(1.);\n GammaVertex tensorGamma = new GammaVertex(theta, k);\n LogProbGraph logProbGraph = tensorGamma.logProbGraph();\n\n ...
{ "fields": [ { "declarator": "theta", "modifier": "private final", "original_string": "private final DoubleVertex theta;", "type": "DoubleVertex", "var_name": "theta" }, { "declarator": "k", "modifier": "private final", "original_string": "private final Dou...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex thetaPlaceholder = new DoublePlaceholderVertex(theta.getShape());\n final DoublePlaceholderVertex kPlaceholde...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_166
{ "fields": [ { "declarator": "N = 100000", "modifier": "private", "original_string": "private int N = 100000;", "type": "int", "var_name": "N" }, { "declarator": "lowerBound = 10.", "modifier": "private", "original_string": "private Double lowerBound = 10.;...
{ "body": "@Test\n public void logProbGraphUpperBoundIsNegativeInfinity() {\n DoubleVertex xMin = ConstantVertex.of(lowerBound);\n DoubleVertex xMax = ConstantVertex.of(upperBound);\n UniformVertex uniformVertex = new UniformVertex(xMin, xMax);\n LogProbGraph logProbGraph = uniformVerte...
{ "fields": [ { "declarator": "xMin", "modifier": "private final", "original_string": "private final DoubleVertex xMin;", "type": "DoubleVertex", "var_name": "xMin" }, { "declarator": "xMax", "modifier": "private final", "original_string": "private final Dou...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex xMinPlaceholder = new DoublePlaceholderVertex(xMin.getShape());\n final DoublePlaceholderVertex xMaxPlacehold...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_170
{ "fields": [ { "declarator": "DELTA = 0.0001", "modifier": "private static final", "original_string": "private static final double DELTA = 0.0001;", "type": "double", "var_name": "DELTA" }, { "declarator": "random", "modifier": "private", "original_string":...
{ "body": "@Test\n public void logProbGraphMatchesKnownLogDensityOfVector() {\n DoubleVertex mu = ConstantVertex.of(0., 0.);\n DoubleVertex s = ConstantVertex.of(1., 1.);\n LogisticVertex logisticVertex = new LogisticVertex(mu, s);\n LogProbGraph logProbGraph = logisticVertex.logProbGra...
{ "fields": [ { "declarator": "mu", "modifier": "private final", "original_string": "private final DoubleVertex mu;", "type": "DoubleVertex", "var_name": "mu" }, { "declarator": "s", "modifier": "private final", "original_string": "private final DoubleVertex...
{ "body": "@Override\n public LogProbGraph logProbGraph() {\n final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape());\n final DoublePlaceholderVertex muPlaceholder = new DoublePlaceholderVertex(mu.getShape());\n final DoublePlaceholderVertex sPlaceholder = ne...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_259
{ "fields": [ { "declarator": "proposal", "modifier": "public", "original_string": "public Proposal proposal;", "type": "Proposal", "var_name": "proposal" }, { "declarator": "currentStateForVertex1 = DoubleTensor.create(4.2, 4.7)", "modifier": "private static fina...
{ "body": "@Test\n public void logProbThrowsIfProposalIsMissingASigmaForAVariable() {\n CauchyVertex notInProposalDistribution = new CauchyVertex(1., 1.);\n thrown.expect(IllegalStateException.class);\n thrown.expectMessage(\"A sigma was not specified for variable \" + notInProposalDistributio...
{ "fields": [ { "declarator": "sigmas", "modifier": "private final", "original_string": "private final Map<? extends Variable, DoubleTensor> sigmas;", "type": "Map<? extends Variable, DoubleTensor>", "var_name": "sigmas" }, { "declarator": "proposalNotifier", "mod...
{ "body": "@Override\n public <T> double logProb(Probabilistic<T> variable, T ofValue, T givenValue) {\n if (!(ofValue instanceof DoubleTensor)) {\n throw new ClassCastException(\"Only DoubleTensor values are supported - not \" + ofValue.getClass().getSimpleName());\n }\n if (!sigma...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_127
{ "fields": [ { "declarator": "epsilon = 0.01", "modifier": "private static", "original_string": "private static double epsilon = 0.01;", "type": "double", "var_name": "epsilon" }, { "declarator": "N = 100000", "modifier": "private static", "original_string"...
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void ofDirichletWrongAmountOfCategoriesFails() {\n final DirichletVertex dirichletVertex = new DirichletVertex(1, 2, 3, 4, 5);\n CategoricalVertex.of(dirichletVertex, Arrays.asList(TestEnum.A, TestEnum.B, TestEnum.C, TestEnum.D));\n...
{ "fields": [ { "declarator": "selectableValues", "modifier": "private final", "original_string": "private final Map<CATEGORY, DoubleVertex> selectableValues;", "type": "Map<CATEGORY, DoubleVertex>", "var_name": "selectableValues" } ], "file": "keanu-project/src/main/java/io/...
{ "body": "public static <CATEGORY> CategoricalVertex<CATEGORY> of(\n Map<CATEGORY, Double> selectableValues\n ) {\n return new CategoricalVertex<>(toDoubleVertices(selectableValues));\n }", "class_method_signature": "CategoricalVertex.of(\n Map<CATEGORY, Double> selectableValues\n )",...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_330
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test(expected = SequenceConstructionException.class)\n public void itThrowsIfYouAskForTheLastItemButThereIsNone() {\n new Sequence(10, this.hashCode(), null).getLastItem();\n }", "class_method_signature": "SequenceTest.itThrowsIfYouAskForTheLastItemButThereIsNone()", "constructor": false,...
{ "fields": [ { "declarator": "containedItems", "modifier": "private final", "original_string": "private final ArrayList<SequenceItem> containedItems;", "type": "ArrayList<SequenceItem>", "var_name": "containedItems" }, { "declarator": "uniqueIdentifier", "modifie...
{ "body": "public SequenceItem getLastItem() {\n if (containedItems.isEmpty()) {\n throw new SequenceConstructionException(\"Sequence is empty!\");\n }\n return this.asList().get(this.size() - 1);\n }", "class_method_signature": "Sequence.getLastItem()", "constructor": false, ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_275
{ "fields": [ { "declarator": "AReference", "modifier": "private", "original_string": "private VariableReference AReference;", "type": "VariableReference", "var_name": "AReference" }, { "declarator": "BReference", "modifier": "private", "original_string": "p...
{ "body": "@Test\n public void canOnes() {\n\n Map<VariableReference, DoubleTensor> result = VariableValues.ones(left);\n\n DoubleTensor expectedA = DoubleTensor.create(1, 1);\n DoubleTensor expectedB = DoubleTensor.create(1, 1);\n\n assertEquals(expectedA, result.get(AReference));\n ...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/algorithms/mcmc/nuts/VariableValues.java", "identifier": "VariableValues", "interfaces": "", "methods": [ { "class_method_signature": "VariableValues.VariableValues()", "constructor": true, "full_signature": "privat...
{ "body": "public static Map<VariableReference, DoubleTensor> ones(Map<VariableReference, DoubleTensor> shapeLike) {\n return withShape(1.0, shapeLike);\n }", "class_method_signature": "VariableValues.ones(Map<VariableReference, DoubleTensor> shapeLike)", "constructor": false, "full_signature": "publi...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_24
{ "fields": [ { "declarator": "scalar1 = new long[0]", "modifier": "private", "original_string": "private long[] scalar1 = new long[0];", "type": "long[]", "var_name": "scalar1" }, { "declarator": "scalar2 = new long[0]", "modifier": "private", "original_str...
{ "body": "@Test\n public void acceptsNonScalarToScalarParentShape() {\n TensorShapeValidation.checkTensorsMatchNonLengthOneShapeOrAreLengthOne(new long[]{2, 4}, scalar2, scalar1);\n }", "class_method_signature": "TensorShapeValidationTest.acceptsNonScalarToScalarParentShape()", "constructor": false,...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShapeValidation.java", "identifier": "TensorShapeValidation", "interfaces": "", "methods": [ { "class_method_signature": "TensorShapeValidation.TensorShapeValidation()", "constructor": true, "full_signa...
{ "body": "public static void checkTensorsMatchNonLengthOneShapeOrAreLengthOne(long[] proposalShape, long[]... shapes) {\n\n Set<TensorShape> nonLengthOneShapes = getNonLengthOneShapes(shapes);\n\n if (!nonLengthOneShapes.isEmpty()) {\n\n boolean moreThanOneNonLengthOneShape = nonLengthOneSha...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_73
{ "fields": [ { "declarator": "samples", "modifier": "private", "original_string": "private NetworkSamples samples;", "type": "NetworkSamples", "var_name": "samples" }, { "declarator": "rowTensors = new ArrayList<>()", "modifier": "private", "original_string...
{ "body": "@Test\n public void writeRowOfTensorsToCsvWithHeader() throws IOException {\n File file = WriteCsv.asRows(rowTensors).withDefaultHeader().toFile(File.createTempFile(\"test\", \".csv\"));\n\n CsvReader reader = ReadCsv.fromFile(file).expectHeader(true);\n List<List<String>> lines = r...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/util/csv/WriteCsv.java", "identifier": "WriteCsv", "interfaces": "", "methods": [ { "class_method_signature": "WriteCsv.asSamples(NetworkSamples samples, List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructo...
{ "body": "public static RowWriter asRows(List<? extends Vertex<? extends Tensor, ?>> vertices) {\n return new RowWriter(vertices);\n }", "class_method_signature": "WriteCsv.asRows(List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructor": false, "full_signature": "public static RowWriter ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_222
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void itWorksWithMatrixOfNAndMatrixOfProbabilities() {\n\n int n1 = 1;\n int n2 = 10;\n int n3 = 100;\n int n4 = 1000;\n\n IntegerTensor n = IntegerTensor.create(new int[]{\n n1, n2,\n n3, n4\n }, 2, 2);\n\n double[] p1...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public double logProb(IntegerTensor x) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).logProb(x).sumNumber();\n }", "class_method_signature": "MultinomialVertex.logProb(IntegerTensor x)", "constructor": false, "full_signature": "@Override...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_234
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void itReturnsEmptyIfYouAskForTheOuterNamespaceButThereIsntOne() {\n VertexLabel labelWithoutNamespace = new VertexLabel(\"foo\");\n assertThat(labelWithoutNamespace.getOuterNamespace().isPresent(), is(false));\n }", "class_method_signature": "VertexLabelTest.itReturnsE...
{ "fields": [ { "declarator": "NAMESPACE_SEPARATOR = '.'", "modifier": "private static final", "original_string": "private static final char NAMESPACE_SEPARATOR = '.';", "type": "char", "var_name": "NAMESPACE_SEPARATOR" }, { "declarator": "namespace", "modifier": ...
{ "body": "public Optional<String> getOuterNamespace() {\n return namespace.stream().findFirst();\n }", "class_method_signature": "VertexLabel.getOuterNamespace()", "constructor": false, "full_signature": "public Optional<String> getOuterNamespace()", "identifier": "getOuterNamespace", "invocation...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_65
{ "fields": [ { "declarator": "samples", "modifier": "private", "original_string": "private NetworkSamples samples;", "type": "NetworkSamples", "var_name": "samples" }, { "declarator": "rowTensors = new ArrayList<>()", "modifier": "private", "original_string...
{ "body": "@Test\n public void writeSamplesToCsv() throws IOException {\n File file = WriteCsv.asSamples(samples, rowTensors).toFile(File.createTempFile(\"test\", \".csv\"));\n\n CsvReader reader = ReadCsv.fromFile(file).expectHeader(false);\n List<List<String>> lines = reader.readLines();\n\n...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/util/csv/WriteCsv.java", "identifier": "WriteCsv", "interfaces": "", "methods": [ { "class_method_signature": "WriteCsv.asSamples(NetworkSamples samples, List<? extends Vertex<? extends Tensor, ?>> vertices)", "constructo...
{ "body": "public static SampleWriter asSamples(NetworkSamples samples, List<? extends Vertex<? extends Tensor, ?>> vertices) {\n return new SampleWriter(samples, vertices);\n }", "class_method_signature": "WriteCsv.asSamples(NetworkSamples samples, List<? extends Vertex<? extends Tensor, ?>> vertices)", ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_326
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void youCanConstructASequenceItem() throws IOException {\n VertexLabel xLabel = new VertexLabel(\"x\");\n Sequence sequence = constructSimpleSequence(null, xLabel);\n BayesianNetwork network = sequence.toBayesianNetwork();\n\n ByteArrayOutputStream writer = new...
{ "fields": [], "file": "keanu-project/src/main/java/io/improbable/keanu/templating/SequenceLoader.java", "identifier": "SequenceLoader", "interfaces": "", "methods": [ { "class_method_signature": "SequenceLoader.loadFromBayesNet(BayesianNetwork network)", "constructor": false, "full_sig...
{ "body": "public static Sequence loadFromBayesNet(BayesianNetwork network) {\n Collection<Sequence> sequences = loadSequences(network, false).values();\n return sequences.stream().findFirst().get();\n }", "class_method_signature": "SequenceLoader.loadFromBayesNet(BayesianNetwork network)", "cons...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_32
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/jvm/JVMTensorTest.java", "identifier": "JVMTensorTest", "interfaces": "", "superclass": "" }
{ "body": "@Test\n public void canToStringScalar() {\n DoubleTensor scalar = JVMDoubleTensorFactory.INSTANCE.scalar(9);\n String actual = scalar.toString();\n\n assertThat(actual, equalTo(\n \"{\\n\" +\n \"shape = []\\n\" +\n \"data = \\n9.0\\n}\"));\n ...
{ "fields": [ { "declarator": "buffer", "modifier": "protected", "original_string": "protected B buffer;", "type": "B", "var_name": "buffer" }, { "declarator": "shape", "modifier": "protected", "original_string": "protected long[] shape;", "type": "lon...
{ "body": "@Override\n public String toString() {\n\n return \"{\\n\" +\n \"shape = \" + Arrays.toString(shape) +\n \"\\ndata = \\n\" + arrayToString(buffer.asArray(), shape, stride) +\n \"\\n}\";\n }", "class_method_signature": "JVMTensor.toString()", "constructor": ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_263
{ "fields": [ { "declarator": "vertex1 = mock(Vertex.class)", "modifier": "private", "original_string": "private Vertex vertex1 = mock(Vertex.class);", "type": "Vertex", "var_name": "vertex1" }, { "declarator": "vertex2 = mock(Vertex.class)", "modifier": "private"...
{ "body": "@Test\n public void youCanTrackTheAcceptanceRateOfASetOfMultipleVertices() {\n Proposal proposal = new Proposal();\n proposal.setProposal(vertex1, 1.);\n proposal.setProposal(vertex2, 2.);\n notifier.notifyProposalCreated(proposal);\n notifier.notifyProposalRejected();...
{ "fields": [ { "declarator": "numApplied = Maps.newHashMap()", "modifier": "private", "original_string": "private Map<VariableReference, Counter> numApplied = Maps.newHashMap();", "type": "Map<VariableReference, Counter>", "var_name": "numApplied" }, { "declarator": "n...
{ "body": "public double getAcceptanceRate(VariableReference variableReference) {\n if (!numApplied.keySet().contains(variableReference)) {\n throw new IllegalStateException(\"No proposals have been registered for \" + variableReference);\n }\n return 1. - (double) numRejected.getOrDef...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_214
{ "fields": [ { "declarator": "rule = new DeterministicRule()", "modifier": "@Rule\n public", "original_string": "@Rule\n public DeterministicRule rule = new DeterministicRule();", "type": "DeterministicRule", "var_name": "rule" }, { "declarator": "thrown = Expect...
{ "body": "@Test\n public void doesAllowSampleWithShapeThatIsBroadcastableWithVertexShape() {\n IntegerTensor n = IntegerTensor.create(100, 200, 300, 400);\n DoubleTensor p = DoubleTensor.create(new double[]{\n 0.1, 0.9,\n 0.2, 0.8,\n 0.3, 0.7,\n 0.4, 0.6\n...
{ "fields": [ { "declarator": "p", "modifier": "private final", "original_string": "private final DoubleVertex p;", "type": "DoubleVertex", "var_name": "p" }, { "declarator": "n", "modifier": "private final", "original_string": "private final IntegerVertex n...
{ "body": "@Override\n public IntegerTensor sampleWithShape(long[] shape, KeanuRandom random) {\n return Multinomial.withParameters(n.getValue(), p.getValue(), validationEnabled).sample(shape, random);\n }", "class_method_signature": "MultinomialVertex.sampleWithShape(long[] shape, KeanuRandom random)"...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_45
{ "fields": [ { "declarator": "thrown = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException thrown = ExpectedException.none();", "type": "ExpectedException", "var_name": "thrown" } ], "file": "keanu-project/src/t...
{ "body": "@Test\n public void canDiagFromVector() {\n BooleanTensor expected = BooleanTensor.create(new boolean[]{true, false, false, false, true, false, false, false, false}, 3, 3);\n BooleanTensor actual = BooleanTensor.create(true, true, false).diag();\n\n Assert.assertEquals(expected, act...
{ "fields": [ { "declarator": "factory = BooleanBuffer.factory", "modifier": "private static final", "original_string": "private static final BooleanBuffer.BooleanArrayWrapperFactory factory = BooleanBuffer.factory;", "type": "BooleanBuffer.BooleanArrayWrapperFactory", "var_name": "f...
{ "body": "@Override\n protected JVMBooleanTensor create(BooleanBuffer.PrimitiveBooleanWrapper buffer, long[] shape, long[] stride) {\n return new JVMBooleanTensor(buffer, shape, stride);\n }", "class_method_signature": "JVMBooleanTensor.create(BooleanBuffer.PrimitiveBooleanWrapper buffer, long[] shape...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_351
{ "fields": [ { "declarator": "numberOfStudents = 100", "modifier": "private final", "original_string": "private final int numberOfStudents = 100;", "type": "int", "var_name": "numberOfStudents" }, { "declarator": "numberOfYesAnswers = 35", "modifier": "private fi...
{ "body": "@Test\n public void doesWorkWithBinomial() {\n double approximateProbabilityOfCheating = CheatingStudents.runUsingBinomial(numberOfStudents, numberOfYesAnswers);\n assertEquals(0.2, approximateProbabilityOfCheating, 0.05);\n }", "class_method_signature": "CheatingStudentsTest.doesWork...
{ "fields": [], "file": "keanu-examples/bayesianMethodsForHackers/src/main/java/com/examples/CheatingStudents.java", "identifier": "CheatingStudents", "interfaces": "", "methods": [ { "class_method_signature": "CheatingStudents.runWithBernoulli(int numberOfStudents, int numberOfYesAnswers)", "...
{ "body": "public static double runUsingBinomial(int numberOfStudents, int numberOfYesAnswers) {\n int numberOfSamples = 100;\n\n UniformVertex probabilityOfCheating = new UniformVertex(0.0, 1.0);\n DoubleVertex pYesAnswer = probabilityOfCheating.times(0.5).plus(0.25);\n BinomialVertex ans...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_4
{ "fields": [], "file": "keanu-project/src/test/java/io/improbable/keanu/tensor/TensorShapeTest.java", "identifier": "TensorShapeTest", "interfaces": "", "superclass": "" }
{ "body": "@Test(expected = IllegalArgumentException.class)\n public void doesThrowOnInvalidNegativeAbsoluteDimensionsFromRelative() {\n TensorShape.getAbsoluteDimensions(3, new int[]{-4, 1, 2});\n }", "class_method_signature": "TensorShapeTest.doesThrowOnInvalidNegativeAbsoluteDimensionsFromRelative()...
{ "fields": [ { "declarator": "shape", "modifier": "private", "original_string": "private long[] shape;", "type": "long[]", "var_name": "shape" } ], "file": "keanu-project/src/main/java/io/improbable/keanu/tensor/TensorShape.java", "identifier": "TensorShape", "interfaces...
{ "body": "public static int[] getAbsoluteDimensions(int rank, int[] input) {\n int[] output = new int[input.length];\n for (int i = 0; i < output.length; i++) {\n output[i] = getAbsoluteDimension(input[i], rank);\n }\n return output;\n }", "class_method_signature": "Tensor...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_12
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" }, ...
{ "body": "@Test\n public void youCanCalculateTheMeanSquaredError() {\n assertThat(stats.meanSquaredError(), greaterThan(0.));\n }", "class_method_signature": "BivariateDataStatisticsCalculatorTest.youCanCalculateTheMeanSquaredError()", "constructor": false, "full_signature": "@Test public void you...
{ "fields": [ { "declarator": "xData", "modifier": "private final", "original_string": "private final DoubleTensor xData;", "type": "DoubleTensor", "var_name": "xData" }, { "declarator": "yData", "modifier": "private final", "original_string": "private final...
{ "body": "public double meanSquaredError() {\n DoubleTensor calculatedY = xData.times(estimatedGradient()).plusInPlace(estimatedIntercept());\n DoubleTensor residuals = yData.minus(calculatedY);\n long unbiasedMultiplier = size() - 2;\n return residuals.times(residuals).sumNumber() / unbi...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }
128393918_243
{ "fields": [ { "declarator": "expectedException = ExpectedException.none()", "modifier": "@Rule\n public", "original_string": "@Rule\n public ExpectedException expectedException = ExpectedException.none();", "type": "ExpectedException", "var_name": "expectedException" } ...
{ "body": "@Test\n public void isInSuperNamespace() {\n VertexLabel label = new VertexLabel(\"outer\", \"inner\", \"foo\");\n assertTrue(label.isInNamespace(\"outer\"));\n }", "class_method_signature": "VertexLabelTest.isInSuperNamespace()", "constructor": false, "full_signature": "@Test pub...
{ "fields": [ { "declarator": "NAMESPACE_SEPARATOR = '.'", "modifier": "private static final", "original_string": "private static final char NAMESPACE_SEPARATOR = '.';", "type": "char", "var_name": "NAMESPACE_SEPARATOR" }, { "declarator": "namespace", "modifier": ...
{ "body": "public boolean isInNamespace(String... namespace) {\n\n if (namespace.length > this.namespace.size()) {\n return false;\n }\n\n for (int i = 0; i < namespace.length; i++) {\n if (!this.namespace.get(i).equals(namespace[i])) {\n return false;\n ...
{ "created": null, "fork": null, "fork_count": 33, "is_fork": false, "language": "Java", "license": "licensed", "repo_id": 128393918, "size": 15461, "stargazer_count": 146, "stars": null, "updates": null, "url": "https://github.com/improbable-research/keanu" }