id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
17,100
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.exampleMapForProperties
private static Map<String, Object> exampleMapForProperties(Map<String, Property> properties, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { Map<String, Object> exampleMap = new LinkedHashMap<>(); if (proper...
java
private static Map<String, Object> exampleMapForProperties(Map<String, Property> properties, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { Map<String, Object> exampleMap = new LinkedHashMap<>(); if (proper...
[ "private", "static", "Map", "<", "String", ",", "Object", ">", "exampleMapForProperties", "(", "Map", "<", "String", ",", "Property", ">", "properties", ",", "Map", "<", "String", ",", "Model", ">", "definitions", ",", "DocumentResolver", "definitionDocumentReso...
Generates a map of examples from a map of properties. If defined examples are found, those are used. Otherwise, examples are generated from the type. @param properties the map of properties @param definitions the map of definitions @param markupDocBuilder the markup builder @param refStack map to de...
[ "Generates", "a", "map", "of", "examples", "from", "a", "map", "of", "properties", ".", "If", "defined", "examples", "are", "found", "those", "are", "used", ".", "Otherwise", "examples", "are", "generated", "from", "the", "type", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L278-L300
17,101
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.generateExampleForArrayProperty
private static Object[] generateExampleForArrayProperty(ArrayProperty value, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { Property property = value.getItems(); return getExample(property, definitions, def...
java
private static Object[] generateExampleForArrayProperty(ArrayProperty value, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { Property property = value.getItems(); return getExample(property, definitions, def...
[ "private", "static", "Object", "[", "]", "generateExampleForArrayProperty", "(", "ArrayProperty", "value", ",", "Map", "<", "String", ",", "Model", ">", "definitions", ",", "DocumentResolver", "definitionDocumentResolver", ",", "MarkupDocBuilder", "markupDocBuilder", ",...
Generates examples from an ArrayProperty @param value ArrayProperty @param definitions map of definitions @param markupDocBuilder the markup builder @return array of Object
[ "Generates", "examples", "from", "an", "ArrayProperty" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L334-L337
17,102
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.getExample
private static Object[] getExample( Property property, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { if (property.getExample() != null) { ret...
java
private static Object[] getExample( Property property, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) { if (property.getExample() != null) { ret...
[ "private", "static", "Object", "[", "]", "getExample", "(", "Property", "property", ",", "Map", "<", "String", ",", "Model", ">", "definitions", ",", "DocumentResolver", "definitionDocumentResolver", ",", "MarkupDocBuilder", "markupDocBuilder", ",", "Map", "<", "S...
Get example from a property @param property Property @param definitions map of definitions @param definitionDocumentResolver DocumentResolver @param markupDocBuilder the markup builder @param refStack reference stack @return array of Object
[ "Get", "example", "from", "a", "property" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L349-L364
17,103
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.generateStringExample
public static String generateStringExample(String format, List<String> enumValues) { if (enumValues == null || enumValues.isEmpty()) { if (format == null) { return "string"; } else { switch (format) { case "byte": ...
java
public static String generateStringExample(String format, List<String> enumValues) { if (enumValues == null || enumValues.isEmpty()) { if (format == null) { return "string"; } else { switch (format) { case "byte": ...
[ "public", "static", "String", "generateStringExample", "(", "String", "format", ",", "List", "<", "String", ">", "enumValues", ")", "{", "if", "(", "enumValues", "==", "null", "||", "enumValues", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "format", "...
Generates examples for string properties or parameters with given format @param format the format of the string property @param enumValues the enum values @return example
[ "Generates", "examples", "for", "string", "properties", "or", "parameters", "with", "given", "format" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L373-L398
17,104
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java
ExamplesUtil.generateIntegerExample
public static Integer generateIntegerExample(List<Integer> enumValues) { if (enumValues == null || enumValues.isEmpty()) { return 0; } else { return enumValues.get(0); } }
java
public static Integer generateIntegerExample(List<Integer> enumValues) { if (enumValues == null || enumValues.isEmpty()) { return 0; } else { return enumValues.get(0); } }
[ "public", "static", "Integer", "generateIntegerExample", "(", "List", "<", "Integer", ">", "enumValues", ")", "{", "if", "(", "enumValues", "==", "null", "||", "enumValues", ".", "isEmpty", "(", ")", ")", "{", "return", "0", ";", "}", "else", "{", "retur...
Generates examples for integer properties - if there are enums, it uses first enum value, returns 0 otherwise. @param enumValues the enum values @return example
[ "Generates", "examples", "for", "integer", "properties", "-", "if", "there", "are", "enums", "it", "uses", "first", "enum", "value", "returns", "0", "otherwise", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/ExamplesUtil.java#L406-L412
17,105
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/PathUtils.java
PathUtils.getOperationMap
private static Map<HttpMethod, Operation> getOperationMap(Path path) { Map<HttpMethod, Operation> result = new LinkedHashMap<>(); if (path.getGet() != null) { result.put(HttpMethod.GET, path.getGet()); } if (path.getPut() != null) { result.put(HttpMethod.PUT, pat...
java
private static Map<HttpMethod, Operation> getOperationMap(Path path) { Map<HttpMethod, Operation> result = new LinkedHashMap<>(); if (path.getGet() != null) { result.put(HttpMethod.GET, path.getGet()); } if (path.getPut() != null) { result.put(HttpMethod.PUT, pat...
[ "private", "static", "Map", "<", "HttpMethod", ",", "Operation", ">", "getOperationMap", "(", "Path", "path", ")", "{", "Map", "<", "HttpMethod", ",", "Operation", ">", "result", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "if", "(", "path", ".", ...
Returns the operations of a path as a map which preserves the insertion order. @param path the path @return the operations of a path as a map
[ "Returns", "the", "operations", "of", "a", "path", "as", "a", "map", "which", "preserves", "the", "insertion", "order", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/PathUtils.java#L33-L59
17,106
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/PathUtils.java
PathUtils.toPathOperationsList
public static List<PathOperation> toPathOperationsList(Map<String, Path> paths, String host, String basePath, Comparator<PathOperation> compara...
java
public static List<PathOperation> toPathOperationsList(Map<String, Path> paths, String host, String basePath, Comparator<PathOperation> compara...
[ "public", "static", "List", "<", "PathOperation", ">", "toPathOperationsList", "(", "Map", "<", "String", ",", "Path", ">", "paths", ",", "String", "host", ",", "String", "basePath", ",", "Comparator", "<", "PathOperation", ">", "comparator", ")", "{", "List...
Converts the Swagger paths into a list of PathOperations. @param paths the Swagger paths @param host the host of all paths @param basePath the basePath of all paths @param comparator the comparator to use. @return the path operations
[ "Converts", "the", "Swagger", "paths", "into", "a", "list", "of", "PathOperations", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/PathUtils.java#L70-L82
17,107
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/utils/PathUtils.java
PathUtils.toPathOperationsList
public static List<PathOperation> toPathOperationsList(String path, Path pathModel) { List<PathOperation> pathOperations = new ArrayList<>(); getOperationMap(pathModel).forEach((httpMethod, operation) -> pathOperations.add(new PathOperation(httpMethod, path, operation))); return ...
java
public static List<PathOperation> toPathOperationsList(String path, Path pathModel) { List<PathOperation> pathOperations = new ArrayList<>(); getOperationMap(pathModel).forEach((httpMethod, operation) -> pathOperations.add(new PathOperation(httpMethod, path, operation))); return ...
[ "public", "static", "List", "<", "PathOperation", ">", "toPathOperationsList", "(", "String", "path", ",", "Path", "pathModel", ")", "{", "List", "<", "PathOperation", ">", "pathOperations", "=", "new", "ArrayList", "<>", "(", ")", ";", "getOperationMap", "(",...
Converts a Swagger path into a PathOperation. @param path the path @param pathModel the Swagger Path model @return the path operations
[ "Converts", "a", "Swagger", "path", "into", "a", "PathOperation", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/utils/PathUtils.java#L91-L96
17,108
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/model/PathOperation.java
PathOperation.getTitle
public String getTitle() { String operationName = operation.getSummary(); if (isBlank(operationName)) { operationName = getMethod().toString() + " " + getPath(); } return operationName; }
java
public String getTitle() { String operationName = operation.getSummary(); if (isBlank(operationName)) { operationName = getMethod().toString() + " " + getPath(); } return operationName; }
[ "public", "String", "getTitle", "(", ")", "{", "String", "operationName", "=", "operation", ".", "getSummary", "(", ")", ";", "if", "(", "isBlank", "(", "operationName", ")", ")", "{", "operationName", "=", "getMethod", "(", ")", ".", "toString", "(", ")...
Returns the display title for an operation @return the operation title
[ "Returns", "the", "display", "title", "for", "an", "operation" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/model/PathOperation.java#L49-L55
17,109
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/OverviewDocument.java
OverviewDocument.apply
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, OverviewDocument.Parameters params) { Swagger swagger = params.swagger; Info info = swagger.getInfo(); buildDocumentTitle(markupDocBuilder, info.getTitle()); applyOverviewDocumentExtension(new Context(Position...
java
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, OverviewDocument.Parameters params) { Swagger swagger = params.swagger; Info info = swagger.getInfo(); buildDocumentTitle(markupDocBuilder, info.getTitle()); applyOverviewDocumentExtension(new Context(Position...
[ "@", "Override", "public", "MarkupDocBuilder", "apply", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "OverviewDocument", ".", "Parameters", "params", ")", "{", "Swagger", "swagger", "=", "params", ".", "swagger", ";", "Info", "info", "=", "swagger", ".", "g...
Builds the overview MarkupDocument. @return the overview MarkupDocument
[ "Builds", "the", "overview", "MarkupDocument", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/OverviewDocument.java#L68-L88
17,110
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/OverviewDocument.java
OverviewDocument.applyOverviewDocumentExtension
private void applyOverviewDocumentExtension(Context context) { extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.apply(context)); }
java
private void applyOverviewDocumentExtension(Context context) { extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.apply(context)); }
[ "private", "void", "applyOverviewDocumentExtension", "(", "Context", "context", ")", "{", "extensionRegistry", ".", "getOverviewDocumentExtensions", "(", ")", ".", "forEach", "(", "extension", "->", "extension", ".", "apply", "(", "context", ")", ")", ";", "}" ]
Apply extension context to all OverviewContentExtension @param context context
[ "Apply", "extension", "context", "to", "all", "OverviewContentExtension" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/OverviewDocument.java#L155-L157
17,111
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java
DefinitionsDocument.apply
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, DefinitionsDocument.Parameters params) { Map<String, Model> definitions = params.definitions; if (MapUtils.isNotEmpty(definitions)) { applyDefinitionsDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupD...
java
@Override public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, DefinitionsDocument.Parameters params) { Map<String, Model> definitions = params.definitions; if (MapUtils.isNotEmpty(definitions)) { applyDefinitionsDocumentExtension(new Context(Position.DOCUMENT_BEFORE, markupD...
[ "@", "Override", "public", "MarkupDocBuilder", "apply", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "DefinitionsDocument", ".", "Parameters", "params", ")", "{", "Map", "<", "String", ",", "Model", ">", "definitions", "=", "params", ".", "definitions", ";", ...
Builds the definitions MarkupDocument. @return the definitions MarkupDocument
[ "Builds", "the", "definitions", "MarkupDocument", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java#L79-L91
17,112
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java
DefinitionsDocument.applyDefinitionsDocumentExtension
private void applyDefinitionsDocumentExtension(Context context) { extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.apply(context)); }
java
private void applyDefinitionsDocumentExtension(Context context) { extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.apply(context)); }
[ "private", "void", "applyDefinitionsDocumentExtension", "(", "Context", "context", ")", "{", "extensionRegistry", ".", "getDefinitionsDocumentExtensions", "(", ")", ".", "forEach", "(", "extension", "->", "extension", ".", "apply", "(", "context", ")", ")", ";", "...
Apply extension context to all DefinitionsContentExtension @param context context
[ "Apply", "extension", "context", "to", "all", "DefinitionsContentExtension" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java#L112-L114
17,113
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java
DefinitionsDocument.buildDefinition
private void buildDefinition(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) { if (logger.isDebugEnabled()) { logger.debug("Definition processed : '{}'", definitionName); } if (config.isSeparatedDefinitionsEnabled()) { MarkupDocBuilder defDocBuilder...
java
private void buildDefinition(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) { if (logger.isDebugEnabled()) { logger.debug("Definition processed : '{}'", definitionName); } if (config.isSeparatedDefinitionsEnabled()) { MarkupDocBuilder defDocBuilder...
[ "private", "void", "buildDefinition", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "String", "definitionName", ",", "Model", "model", ")", "{", "if", "(", "logger", ".", "isDebugEnabled", "(", ")", ")", "{", "logger", ".", "debug", "(", "\"Definition proces...
Generate definition files depending on the generation mode @param definitionName definition name to process @param model definition model to process
[ "Generate", "definition", "files", "depending", "on", "the", "generation", "mode" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java#L122-L140
17,114
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java
DefinitionsDocument.applyDefinitionComponent
private void applyDefinitionComponent(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) { definitionComponent.apply(markupDocBuilder, DefinitionComponent.parameters( definitionName, model, 2)); }
java
private void applyDefinitionComponent(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) { definitionComponent.apply(markupDocBuilder, DefinitionComponent.parameters( definitionName, model, 2)); }
[ "private", "void", "applyDefinitionComponent", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "String", "definitionName", ",", "Model", "model", ")", "{", "definitionComponent", ".", "apply", "(", "markupDocBuilder", ",", "DefinitionComponent", ".", "parameters", "("...
Builds a concrete definition @param markupDocBuilder the markupDocBuilder do use for output @param definitionName the name of the definition @param model the Swagger Model of the definition
[ "Builds", "a", "concrete", "definition" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java#L159-L164
17,115
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java
DefinitionsDocument.definitionRef
private void definitionRef(MarkupDocBuilder markupDocBuilder, String definitionName) { buildDefinitionTitle(markupDocBuilder, crossReference(markupDocBuilder, definitionDocumentResolverDefault.apply(definitionName), definitionName, definitionName), "ref-" + definitionName); }
java
private void definitionRef(MarkupDocBuilder markupDocBuilder, String definitionName) { buildDefinitionTitle(markupDocBuilder, crossReference(markupDocBuilder, definitionDocumentResolverDefault.apply(definitionName), definitionName, definitionName), "ref-" + definitionName); }
[ "private", "void", "definitionRef", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "String", "definitionName", ")", "{", "buildDefinitionTitle", "(", "markupDocBuilder", ",", "crossReference", "(", "markupDocBuilder", ",", "definitionDocumentResolverDefault", ".", "apply...
Builds a cross-reference to a separated definition file. @param definitionName definition name to target
[ "Builds", "a", "cross", "-", "reference", "to", "a", "separated", "definition", "file", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java#L171-L173
17,116
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java
DefinitionsDocument.buildDefinitionTitle
private void buildDefinitionTitle(MarkupDocBuilder markupDocBuilder, String title, String anchor) { markupDocBuilder.sectionTitleWithAnchorLevel2(title, anchor); }
java
private void buildDefinitionTitle(MarkupDocBuilder markupDocBuilder, String title, String anchor) { markupDocBuilder.sectionTitleWithAnchorLevel2(title, anchor); }
[ "private", "void", "buildDefinitionTitle", "(", "MarkupDocBuilder", "markupDocBuilder", ",", "String", "title", ",", "String", "anchor", ")", "{", "markupDocBuilder", ".", "sectionTitleWithAnchorLevel2", "(", "title", ",", "anchor", ")", ";", "}" ]
Builds definition title @param markupDocBuilder the markupDocBuilder do use for output @param title definition title @param anchor optional anchor (null => auto-generate from title)
[ "Builds", "definition", "title" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/document/DefinitionsDocument.java#L182-L184
17,117
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/ParameterAdapter.java
ParameterAdapter.generateExample
public static Object generateExample(AbstractSerializableParameter<?> parameter) { switch (parameter.getType()) { case "integer": return 0; case "number": return 0.0; case "boolean": return true; case "string": ...
java
public static Object generateExample(AbstractSerializableParameter<?> parameter) { switch (parameter.getType()) { case "integer": return 0; case "number": return 0.0; case "boolean": return true; case "string": ...
[ "public", "static", "Object", "generateExample", "(", "AbstractSerializableParameter", "<", "?", ">", "parameter", ")", "{", "switch", "(", "parameter", ".", "getType", "(", ")", ")", "{", "case", "\"integer\"", ":", "return", "0", ";", "case", "\"number\"", ...
Generate a default example value for parameter. @param parameter parameter @return a generated example for the parameter
[ "Generate", "a", "default", "example", "value", "for", "parameter", "." ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/ParameterAdapter.java#L85-L98
17,118
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/ParameterAdapter.java
ParameterAdapter.getType
private Type getType(Map<String, Model> definitions, DocumentResolver definitionDocumentResolver) { Validate.notNull(parameter, "parameter must not be null!"); Type type = null; if (parameter instanceof BodyParameter) { BodyParameter bodyParameter = (BodyParameter) parameter; ...
java
private Type getType(Map<String, Model> definitions, DocumentResolver definitionDocumentResolver) { Validate.notNull(parameter, "parameter must not be null!"); Type type = null; if (parameter instanceof BodyParameter) { BodyParameter bodyParameter = (BodyParameter) parameter; ...
[ "private", "Type", "getType", "(", "Map", "<", "String", ",", "Model", ">", "definitions", ",", "DocumentResolver", "definitionDocumentResolver", ")", "{", "Validate", ".", "notNull", "(", "parameter", ",", "\"parameter must not be null!\"", ")", ";", "Type", "typ...
Retrieves the type of a parameter, or otherwise null @param definitionDocumentResolver the definition document resolver @return the type of the parameter, or otherwise null
[ "Retrieves", "the", "type", "of", "a", "parameter", "or", "otherwise", "null" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/ParameterAdapter.java#L163-L198
17,119
Swagger2Markup/swagger2markup
src/main/java/io/github/swagger2markup/internal/adapter/ParameterAdapter.java
ParameterAdapter.getDefaultValue
public Optional<Object> getDefaultValue() { Validate.notNull(parameter, "parameter must not be null!"); if (parameter instanceof AbstractSerializableParameter) { AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter; return Optional.ofNul...
java
public Optional<Object> getDefaultValue() { Validate.notNull(parameter, "parameter must not be null!"); if (parameter instanceof AbstractSerializableParameter) { AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter; return Optional.ofNul...
[ "public", "Optional", "<", "Object", ">", "getDefaultValue", "(", ")", "{", "Validate", ".", "notNull", "(", "parameter", ",", "\"parameter must not be null!\"", ")", ";", "if", "(", "parameter", "instanceof", "AbstractSerializableParameter", ")", "{", "AbstractSeri...
Retrieves the default value of a parameter @return the default value of the parameter
[ "Retrieves", "the", "default", "value", "of", "a", "parameter" ]
da83465f19a2f8a0f1fba873b5762bca8587896b
https://github.com/Swagger2Markup/swagger2markup/blob/da83465f19a2f8a0f1fba873b5762bca8587896b/src/main/java/io/github/swagger2markup/internal/adapter/ParameterAdapter.java#L205-L212
17,120
haifengl/smile
plot/src/main/java/smile/plot/SparseMatrixPlot.java
SparseMatrixPlot.plot
public static PlotCanvas plot(SparseMatrix sparse) { double[] lowerBound = {0, 0}; double[] upperBound = {sparse.ncols(), sparse.nrows()}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new SparseMatrixPlot(sparse)); canvas.getAxis(0).setLabelVisib...
java
public static PlotCanvas plot(SparseMatrix sparse) { double[] lowerBound = {0, 0}; double[] upperBound = {sparse.ncols(), sparse.nrows()}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new SparseMatrixPlot(sparse)); canvas.getAxis(0).setLabelVisib...
[ "public", "static", "PlotCanvas", "plot", "(", "SparseMatrix", "sparse", ")", "{", "double", "[", "]", "lowerBound", "=", "{", "0", ",", "0", "}", ";", "double", "[", "]", "upperBound", "=", "{", "sparse", ".", "ncols", "(", ")", ",", "sparse", ".", ...
Create a sparse matrix plot canvas. @param sparse a sparse matrix.
[ "Create", "a", "sparse", "matrix", "plot", "canvas", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/SparseMatrixPlot.java#L286-L298
17,121
haifengl/smile
plot/src/main/java/smile/plot/BaseGrid.java
BaseGrid.setFrameVisible
public BaseGrid setFrameVisible(boolean v) { for (int i = 0; i < axis.length; i++) { axis[i].setGridVisible(v); } return this; }
java
public BaseGrid setFrameVisible(boolean v) { for (int i = 0; i < axis.length; i++) { axis[i].setGridVisible(v); } return this; }
[ "public", "BaseGrid", "setFrameVisible", "(", "boolean", "v", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "axis", ".", "length", ";", "i", "++", ")", "{", "axis", "[", "i", "]", ".", "setGridVisible", "(", "v", ")", ";", "}", "re...
Set if the frame visible.
[ "Set", "if", "the", "frame", "visible", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/BaseGrid.java#L93-L98
17,122
haifengl/smile
plot/src/main/java/smile/plot/BaseGrid.java
BaseGrid.setAxisLabel
public BaseGrid setAxisLabel(String... axisLabels) { if (axisLabels.length != base.getDimension()) { throw new IllegalArgumentException("Axis label size don't match base dimension."); } for (int i = 0; i < axisLabels.length; i++) { axis[i].setAxisLabel(axisLabels[i]); ...
java
public BaseGrid setAxisLabel(String... axisLabels) { if (axisLabels.length != base.getDimension()) { throw new IllegalArgumentException("Axis label size don't match base dimension."); } for (int i = 0; i < axisLabels.length; i++) { axis[i].setAxisLabel(axisLabels[i]); ...
[ "public", "BaseGrid", "setAxisLabel", "(", "String", "...", "axisLabels", ")", "{", "if", "(", "axisLabels", ".", "length", "!=", "base", ".", "getDimension", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Axis label size don't match base ...
Set axis labels.
[ "Set", "axis", "labels", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/BaseGrid.java#L117-L127
17,123
haifengl/smile
plot/src/main/java/smile/plot/BaseGrid.java
BaseGrid.getAxisLabel
public String[] getAxisLabel() { String[] array = new String[axis.length]; for (int i = 0; i < array.length; i++) { array[i] = axis[i].getAxisLabel(); } return array; }
java
public String[] getAxisLabel() { String[] array = new String[axis.length]; for (int i = 0; i < array.length; i++) { array[i] = axis[i].getAxisLabel(); } return array; }
[ "public", "String", "[", "]", "getAxisLabel", "(", ")", "{", "String", "[", "]", "array", "=", "new", "String", "[", "axis", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "i", "++", ")", ...
Get axis label.
[ "Get", "axis", "label", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/BaseGrid.java#L132-L138
17,124
haifengl/smile
plot/src/main/java/smile/plot/BaseGrid.java
BaseGrid.paint
public void paint(Graphics g) { for (int i = 0; i < axis.length; i++) { axis[i].paint(g); } }
java
public void paint(Graphics g) { for (int i = 0; i < axis.length; i++) { axis[i].paint(g); } }
[ "public", "void", "paint", "(", "Graphics", "g", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "axis", ".", "length", ";", "i", "++", ")", "{", "axis", "[", "i", "]", ".", "paint", "(", "g", ")", ";", "}", "}" ]
Draw the grid.
[ "Draw", "the", "grid", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/BaseGrid.java#L169-L173
17,125
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.learn
public long learn(double confidence, PrintStream out) { long n = 0; ttree = fim.buildTotalSupportTree(); for (int i = 0; i < ttree.root.children.length; i++) { if (ttree.root.children[i] != null) { int[] itemset = {ttree.root.children[i].id}; n += lear...
java
public long learn(double confidence, PrintStream out) { long n = 0; ttree = fim.buildTotalSupportTree(); for (int i = 0; i < ttree.root.children.length; i++) { if (ttree.root.children[i] != null) { int[] itemset = {ttree.root.children[i].id}; n += lear...
[ "public", "long", "learn", "(", "double", "confidence", ",", "PrintStream", "out", ")", "{", "long", "n", "=", "0", ";", "ttree", "=", "fim", ".", "buildTotalSupportTree", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ttree", "."...
Mines the association rules. The discovered rules will be printed out to the provided stream. @param confidence the confidence threshold for association rules. @return the number of discovered association rules.
[ "Mines", "the", "association", "rules", ".", "The", "discovered", "rules", "will", "be", "printed", "out", "to", "the", "provided", "stream", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L111-L121
17,126
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.learn
public List<AssociationRule> learn(double confidence) { List<AssociationRule> list = new ArrayList<>(); ttree = fim.buildTotalSupportTree(); for (int i = 0; i < ttree.root.children.length; i++) { if (ttree.root.children[i] != null) { int[] itemset = {ttree.root.childr...
java
public List<AssociationRule> learn(double confidence) { List<AssociationRule> list = new ArrayList<>(); ttree = fim.buildTotalSupportTree(); for (int i = 0; i < ttree.root.children.length; i++) { if (ttree.root.children[i] != null) { int[] itemset = {ttree.root.childr...
[ "public", "List", "<", "AssociationRule", ">", "learn", "(", "double", "confidence", ")", "{", "List", "<", "AssociationRule", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "ttree", "=", "fim", ".", "buildTotalSupportTree", "(", ")", ";", "f...
Mines the association rules. The discovered frequent rules will be returned in a list. @param confidence the confidence threshold for association rules.
[ "Mines", "the", "association", "rules", ".", "The", "discovered", "frequent", "rules", "will", "be", "returned", "in", "a", "list", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L127-L137
17,127
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.learn
private long learn(PrintStream out, List<AssociationRule> list, int[] itemset, int size, Node node, double confidence) { long n = 0; if (node.children == null) { return n; } for (int i = 0; i < size; i++) { if (node.children[i] != null) { int[] ne...
java
private long learn(PrintStream out, List<AssociationRule> list, int[] itemset, int size, Node node, double confidence) { long n = 0; if (node.children == null) { return n; } for (int i = 0; i < size; i++) { if (node.children[i] != null) { int[] ne...
[ "private", "long", "learn", "(", "PrintStream", "out", ",", "List", "<", "AssociationRule", ">", "list", ",", "int", "[", "]", "itemset", ",", "int", "size", ",", "Node", "node", ",", "double", "confidence", ")", "{", "long", "n", "=", "0", ";", "if"...
Generates association rules from a T-tree. @param itemset the label for a T-tree node as generated sofar. @param size the size of the current array level in the T-tree. @param node the current node in the T-tree. @param confidence the confidence threshold for association rules.
[ "Generates", "association", "rules", "from", "a", "T", "-", "tree", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L146-L163
17,128
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.learn
private long learn(PrintStream out, List<AssociationRule> list, int[] itemset, int support, double confidence) { long n = 0; // Determine combinations int[][] combinations = getPowerSet(itemset); // Loop through combinations for (int i = 0; i < combinations.length; i++) { ...
java
private long learn(PrintStream out, List<AssociationRule> list, int[] itemset, int support, double confidence) { long n = 0; // Determine combinations int[][] combinations = getPowerSet(itemset); // Loop through combinations for (int i = 0; i < combinations.length; i++) { ...
[ "private", "long", "learn", "(", "PrintStream", "out", ",", "List", "<", "AssociationRule", ">", "list", ",", "int", "[", "]", "itemset", ",", "int", "support", ",", "double", "confidence", ")", "{", "long", "n", "=", "0", ";", "// Determine combinations",...
Generates all association rules for a given item set. @param itemset the given frequent item set. @param support the associated support value for the item set. @param confidence the confidence threshold for association rules.
[ "Generates", "all", "association", "rules", "for", "a", "given", "item", "set", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L171-L200
17,129
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.getComplement
private static int[] getComplement(int[] subset, int[] fullset) { int size = fullset.length - subset.length; // Returns null if no complement if (size < 1) { return null; } // Otherwsise define combination array and determine complement int[] complement = ne...
java
private static int[] getComplement(int[] subset, int[] fullset) { int size = fullset.length - subset.length; // Returns null if no complement if (size < 1) { return null; } // Otherwsise define combination array and determine complement int[] complement = ne...
[ "private", "static", "int", "[", "]", "getComplement", "(", "int", "[", "]", "subset", ",", "int", "[", "]", "fullset", ")", "{", "int", "size", "=", "fullset", ".", "length", "-", "subset", ".", "length", ";", "// Returns null if no complement", "if", "...
Returns the complement of subset.
[ "Returns", "the", "complement", "of", "subset", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L215-L243
17,130
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.getPowerSet
private static int[][] getPowerSet(int[] set) { int[][] sets = new int[getPowerSetSize(set.length)][]; getPowerSet(set, 0, null, sets, 0); return sets; }
java
private static int[][] getPowerSet(int[] set) { int[][] sets = new int[getPowerSetSize(set.length)][]; getPowerSet(set, 0, null, sets, 0); return sets; }
[ "private", "static", "int", "[", "]", "[", "]", "getPowerSet", "(", "int", "[", "]", "set", ")", "{", "int", "[", "]", "[", "]", "sets", "=", "new", "int", "[", "getPowerSetSize", "(", "set", ".", "length", ")", "]", "[", "", "]", ";", "getPowe...
Returns all possible subsets except null and full set.
[ "Returns", "all", "possible", "subsets", "except", "null", "and", "full", "set", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L248-L252
17,131
haifengl/smile
core/src/main/java/smile/association/ARM.java
ARM.getPowerSet
private static int getPowerSet(int[] set, int inputIndex, int[] sofar, int[][] sets, int outputIndex) { for (int i = inputIndex; i < set.length; i++) { int n = sofar == null ? 0 : sofar.length; if (n < set.length-1) { int[] subset = new int[n + 1]; subset[...
java
private static int getPowerSet(int[] set, int inputIndex, int[] sofar, int[][] sets, int outputIndex) { for (int i = inputIndex; i < set.length; i++) { int n = sofar == null ? 0 : sofar.length; if (n < set.length-1) { int[] subset = new int[n + 1]; subset[...
[ "private", "static", "int", "getPowerSet", "(", "int", "[", "]", "set", ",", "int", "inputIndex", ",", "int", "[", "]", "sofar", ",", "int", "[", "]", "[", "]", "sets", ",", "int", "outputIndex", ")", "{", "for", "(", "int", "i", "=", "inputIndex",...
Recursively calculates all possible subsets. @param set the input item set. @param inputIndex the index within the input set marking current element under consideration (0 at start). @param sofar the current combination determined sofar during the recursion (null at start). @param sets the power set to store all combin...
[ "Recursively", "calculates", "all", "possible", "subsets", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/association/ARM.java#L265-L281
17,132
haifengl/smile
math/src/main/java/smile/math/special/Beta.java
Beta.incompleteFractionSummation
private static double incompleteFractionSummation(double alpha, double beta, double x) { final int MAXITER = 500; final double EPS = 3.0E-7; double aplusb = alpha + beta; double aplus1 = alpha + 1.0; double aminus1 = alpha - 1.0; double c = 1.0; double d = 1.0 - ...
java
private static double incompleteFractionSummation(double alpha, double beta, double x) { final int MAXITER = 500; final double EPS = 3.0E-7; double aplusb = alpha + beta; double aplus1 = alpha + 1.0; double aminus1 = alpha - 1.0; double c = 1.0; double d = 1.0 - ...
[ "private", "static", "double", "incompleteFractionSummation", "(", "double", "alpha", ",", "double", "beta", ",", "double", "x", ")", "{", "final", "int", "MAXITER", "=", "500", ";", "final", "double", "EPS", "=", "3.0E-7", ";", "double", "aplusb", "=", "a...
Incomplete fraction summation used in the method regularizedIncompleteBeta using a modified Lentz's method.
[ "Incomplete", "fraction", "summation", "used", "in", "the", "method", "regularizedIncompleteBeta", "using", "a", "modified", "Lentz", "s", "method", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/special/Beta.java#L86-L139
17,133
haifengl/smile
core/src/main/java/smile/manifold/TSNE.java
TSNE.expd
private double[][] expd(double[][] D, double perplexity, double tol) { int n = D.length; double[][] P = new double[n][n]; double[] DiSum = Math.rowSums(D); int nprocs = MulticoreExecutor.getThreadPoolSize(); int chunk = n / nprocs; List<PerplexityTask> tasks =...
java
private double[][] expd(double[][] D, double perplexity, double tol) { int n = D.length; double[][] P = new double[n][n]; double[] DiSum = Math.rowSums(D); int nprocs = MulticoreExecutor.getThreadPoolSize(); int chunk = n / nprocs; List<PerplexityTask> tasks =...
[ "private", "double", "[", "]", "[", "]", "expd", "(", "double", "[", "]", "[", "]", "D", ",", "double", "perplexity", ",", "double", "tol", ")", "{", "int", "n", "=", "D", ".", "length", ";", "double", "[", "]", "[", "]", "P", "=", "new", "do...
Compute the Gaussian kernel (search the width for given perplexity.
[ "Compute", "the", "Gaussian", "kernel", "(", "search", "the", "width", "for", "given", "perplexity", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/manifold/TSNE.java#L278-L300
17,134
haifengl/smile
core/src/main/java/smile/neighbor/KDTree.java
KDTree.buildNode
private Node buildNode(int begin, int end) { int d = keys[0].length; // Allocate the node Node node = new Node(); // Fill in basic info node.count = end - begin; node.index = begin; // Calculate the bounding box double[] lowerBound = new double[d]; ...
java
private Node buildNode(int begin, int end) { int d = keys[0].length; // Allocate the node Node node = new Node(); // Fill in basic info node.count = end - begin; node.index = begin; // Calculate the bounding box double[] lowerBound = new double[d]; ...
[ "private", "Node", "buildNode", "(", "int", "begin", ",", "int", "end", ")", "{", "int", "d", "=", "keys", "[", "0", "]", ".", "length", ";", "// Allocate the node", "Node", "node", "=", "new", "Node", "(", ")", ";", "// Fill in basic info", "node", "....
Build a k-d tree from the given set of dataset.
[ "Build", "a", "k", "-", "d", "tree", "from", "the", "given", "set", "of", "dataset", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/KDTree.java#L157-L235
17,135
haifengl/smile
core/src/main/java/smile/neighbor/KDTree.java
KDTree.search
private void search(double[] q, Node node, Neighbor<double[], E> neighbor) { if (node.isLeaf()) { // look at all the instances in this leaf for (int idx = node.index; idx < node.index + node.count; idx++) { if (q == keys[index[idx]] && identicalExcluded) { ...
java
private void search(double[] q, Node node, Neighbor<double[], E> neighbor) { if (node.isLeaf()) { // look at all the instances in this leaf for (int idx = node.index; idx < node.index + node.count; idx++) { if (q == keys[index[idx]] && identicalExcluded) { ...
[ "private", "void", "search", "(", "double", "[", "]", "q", ",", "Node", "node", ",", "Neighbor", "<", "double", "[", "]", ",", "E", ">", "neighbor", ")", "{", "if", "(", "node", ".", "isLeaf", "(", ")", ")", "{", "// look at all the instances in this l...
Returns the nearest neighbors of the given target starting from the give tree node. @param q the query key. @param node the root of subtree. @param neighbor the current nearest neighbor.
[ "Returns", "the", "nearest", "neighbors", "of", "the", "given", "target", "starting", "from", "the", "give", "tree", "node", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/KDTree.java#L260-L294
17,136
haifengl/smile
core/src/main/java/smile/neighbor/KDTree.java
KDTree.search
private void search(double[] q, Node node, double radius, List<Neighbor<double[], E>> neighbors) { if (node.isLeaf()) { // look at all the instances in this leaf for (int idx = node.index; idx < node.index + node.count; idx++) { if (q == keys[index[idx]] && identicalExclu...
java
private void search(double[] q, Node node, double radius, List<Neighbor<double[], E>> neighbors) { if (node.isLeaf()) { // look at all the instances in this leaf for (int idx = node.index; idx < node.index + node.count; idx++) { if (q == keys[index[idx]] && identicalExclu...
[ "private", "void", "search", "(", "double", "[", "]", "q", ",", "Node", "node", ",", "double", "radius", ",", "List", "<", "Neighbor", "<", "double", "[", "]", ",", "E", ">", ">", "neighbors", ")", "{", "if", "(", "node", ".", "isLeaf", "(", ")",...
Returns the neighbors in the given range of search target from the give tree node. @param q the query key. @param node the root of subtree. @param radius the radius of search range from target. @param neighbors the list of found neighbors in the range.
[ "Returns", "the", "neighbors", "in", "the", "given", "range", "of", "search", "target", "from", "the", "give", "tree", "node", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/KDTree.java#L352-L383
17,137
haifengl/smile
math/src/main/java/smile/math/matrix/Cholesky.java
Cholesky.inverse
public DenseMatrix inverse() { int n = L.nrows(); DenseMatrix inv = Matrix.eye(n); solve(inv); return inv; }
java
public DenseMatrix inverse() { int n = L.nrows(); DenseMatrix inv = Matrix.eye(n); solve(inv); return inv; }
[ "public", "DenseMatrix", "inverse", "(", ")", "{", "int", "n", "=", "L", ".", "nrows", "(", ")", ";", "DenseMatrix", "inv", "=", "Matrix", ".", "eye", "(", "n", ")", ";", "solve", "(", "inv", ")", ";", "return", "inv", ";", "}" ]
Returns the matrix inverse.
[ "Returns", "the", "matrix", "inverse", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/matrix/Cholesky.java#L88-L93
17,138
haifengl/smile
plot/src/main/java/smile/swing/table/TableCopyPasteAdapter.java
TableCopyPasteAdapter.actionPerformed
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().compareTo("Copy") == 0) { StringBuilder sbf = new StringBuilder(); // Check to ensure we have selected only a contiguous block of // cells int numcols = table.getSelectedColumnCoun...
java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().compareTo("Copy") == 0) { StringBuilder sbf = new StringBuilder(); // Check to ensure we have selected only a contiguous block of // cells int numcols = table.getSelectedColumnCoun...
[ "@", "Override", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "if", "(", "e", ".", "getActionCommand", "(", ")", ".", "compareTo", "(", "\"Copy\"", ")", "==", "0", ")", "{", "StringBuilder", "sbf", "=", "new", "StringBuilder", ...
This method is activated on the Keystrokes we are listening to in this implementation. Here it listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in invalid selection and then copy action cannot be performed. Paste is done by aligning the upper left corner of the selection with t...
[ "This", "method", "is", "activated", "on", "the", "Keystrokes", "we", "are", "listening", "to", "in", "this", "implementation", ".", "Here", "it", "listens", "for", "Copy", "and", "Paste", "ActionCommands", ".", "Selections", "comprising", "non", "-", "adjacen...
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/swing/table/TableCopyPasteAdapter.java#L79-L133
17,139
haifengl/smile
nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java
BigramCollocationFinder.find
public BigramCollocation[] find(Corpus corpus, int k) { BigramCollocation[] bigrams = new BigramCollocation[k]; HeapSelect<BigramCollocation> heap = new HeapSelect<>(bigrams); Iterator<Bigram> iterator = corpus.getBigrams(); while (iterator.hasNext()) { Bigram bigram...
java
public BigramCollocation[] find(Corpus corpus, int k) { BigramCollocation[] bigrams = new BigramCollocation[k]; HeapSelect<BigramCollocation> heap = new HeapSelect<>(bigrams); Iterator<Bigram> iterator = corpus.getBigrams(); while (iterator.hasNext()) { Bigram bigram...
[ "public", "BigramCollocation", "[", "]", "find", "(", "Corpus", "corpus", ",", "int", "k", ")", "{", "BigramCollocation", "[", "]", "bigrams", "=", "new", "BigramCollocation", "[", "k", "]", ";", "HeapSelect", "<", "BigramCollocation", ">", "heap", "=", "n...
Finds top k bigram collocations in the given corpus. @return the array of significant bigram collocations in descending order of likelihood ratio.
[ "Finds", "top", "k", "bigram", "collocations", "in", "the", "given", "corpus", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java#L66-L93
17,140
haifengl/smile
nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java
BigramCollocationFinder.find
public BigramCollocation[] find(Corpus corpus, double p) { if (p <= 0.0 || p >= 1.0) { throw new IllegalArgumentException("Invalid p = " + p); } double cutoff = chisq.quantile(p); ArrayList<BigramCollocation> bigrams = new ArrayList<>(); Iterator<Bigram> it...
java
public BigramCollocation[] find(Corpus corpus, double p) { if (p <= 0.0 || p >= 1.0) { throw new IllegalArgumentException("Invalid p = " + p); } double cutoff = chisq.quantile(p); ArrayList<BigramCollocation> bigrams = new ArrayList<>(); Iterator<Bigram> it...
[ "public", "BigramCollocation", "[", "]", "find", "(", "Corpus", "corpus", ",", "double", "p", ")", "{", "if", "(", "p", "<=", "0.0", "||", "p", ">=", "1.0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid p = \"", "+", "p", ")", "...
Finds bigram collocations in the given corpus whose p-value is less than the given threshold. @param p the p-value threshold @return the array of significant bigram collocations in descending order of likelihood ratio.
[ "Finds", "bigram", "collocations", "in", "the", "given", "corpus", "whose", "p", "-", "value", "is", "less", "than", "the", "given", "threshold", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java#L102-L142
17,141
haifengl/smile
nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java
BigramCollocationFinder.likelihoodRatio
private double likelihoodRatio(int c1, int c2, int c12, long N) { double p = (double) c2 / N; double p1 = (double) c12 / c1; double p2 = (double) (c2 - c12) / (N - c1); double logLambda = logL(c12, c1, p) + logL(c2-c12, N-c1, p) - logL(c12, c1, p1) - logL(c2-c12, N-c1, p2); retu...
java
private double likelihoodRatio(int c1, int c2, int c12, long N) { double p = (double) c2 / N; double p1 = (double) c12 / c1; double p2 = (double) (c2 - c12) / (N - c1); double logLambda = logL(c12, c1, p) + logL(c2-c12, N-c1, p) - logL(c12, c1, p1) - logL(c2-c12, N-c1, p2); retu...
[ "private", "double", "likelihoodRatio", "(", "int", "c1", ",", "int", "c2", ",", "int", "c12", ",", "long", "N", ")", "{", "double", "p", "=", "(", "double", ")", "c2", "/", "N", ";", "double", "p1", "=", "(", "double", ")", "c12", "/", "c1", "...
Returns the likelihood ratio test statistic -2 log &lambda; @param c1 the number of occurrences of w1. @param c2 the number of occurrences of w2. @param c12 the number of occurrences of w1 w2. @param N the number of tokens in the corpus.
[ "Returns", "the", "likelihood", "ratio", "test", "statistic", "-", "2", "log", "&lambda", ";" ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java#L151-L158
17,142
haifengl/smile
nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java
BigramCollocationFinder.logL
private double logL(int k, long n, double x) { if (x == 0.0) x = 0.01; if (x == 1.0) x = 0.99; return k * Math.log(x) + (n-k) * Math.log(1-x); }
java
private double logL(int k, long n, double x) { if (x == 0.0) x = 0.01; if (x == 1.0) x = 0.99; return k * Math.log(x) + (n-k) * Math.log(1-x); }
[ "private", "double", "logL", "(", "int", "k", ",", "long", "n", ",", "double", "x", ")", "{", "if", "(", "x", "==", "0.0", ")", "x", "=", "0.01", ";", "if", "(", "x", "==", "1.0", ")", "x", "=", "0.99", ";", "return", "k", "*", "Math", ".",...
Help function for calculating likelihood ratio statistic.
[ "Help", "function", "for", "calculating", "likelihood", "ratio", "statistic", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/nlp/src/main/java/smile/nlp/collocation/BigramCollocationFinder.java#L163-L167
17,143
haifengl/smile
core/src/main/java/smile/wavelet/WaveletShrinkage.java
WaveletShrinkage.denoise
public static void denoise(double[] t, Wavelet wavelet, boolean soft) { wavelet.transform(t); int n = t.length; int nh = t.length >> 1; double[] wc = new double[nh]; System.arraycopy(t, nh, wc, 0, nh); double error = Math.mad(wc) / 0.6745; double lambda = error...
java
public static void denoise(double[] t, Wavelet wavelet, boolean soft) { wavelet.transform(t); int n = t.length; int nh = t.length >> 1; double[] wc = new double[nh]; System.arraycopy(t, nh, wc, 0, nh); double error = Math.mad(wc) / 0.6745; double lambda = error...
[ "public", "static", "void", "denoise", "(", "double", "[", "]", "t", ",", "Wavelet", "wavelet", ",", "boolean", "soft", ")", "{", "wavelet", ".", "transform", "(", "t", ")", ";", "int", "n", "=", "t", ".", "length", ";", "int", "nh", "=", "t", "....
Adaptive denoising a time series with given wavelet. @param t the time series array. The size should be a power of 2. For time series of size no power of 2, 0 padding can be applied. @param wavelet the wavelet to transform the time series. @param soft true if apply soft thresholding.
[ "Adaptive", "denoising", "a", "time", "series", "with", "given", "wavelet", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/wavelet/WaveletShrinkage.java#L68-L93
17,144
haifengl/smile
interpolation/src/main/java/smile/interpolation/CubicSplineInterpolation1D.java
CubicSplineInterpolation1D.sety2
private void sety2(double[] x, double[] y) { double p, qn, sig, un; double[] u = new double[n - 1]; y2[0] = u[0] = 0.0; for (int i = 1; i < n - 1; i++) { sig = (x[i] - x[i - 1]) / (x[i + 1] - x[i - 1]); p = sig * y2[i - 1] + 2.0; y2[i] = (sig - 1.0) ...
java
private void sety2(double[] x, double[] y) { double p, qn, sig, un; double[] u = new double[n - 1]; y2[0] = u[0] = 0.0; for (int i = 1; i < n - 1; i++) { sig = (x[i] - x[i - 1]) / (x[i + 1] - x[i - 1]); p = sig * y2[i - 1] + 2.0; y2[i] = (sig - 1.0) ...
[ "private", "void", "sety2", "(", "double", "[", "]", "x", ",", "double", "[", "]", "y", ")", "{", "double", "p", ",", "qn", ",", "sig", ",", "un", ";", "double", "[", "]", "u", "=", "new", "double", "[", "n", "-", "1", "]", ";", "y2", "[", ...
Calculate the second derivatives of the interpolating function at the tabulated points. At the endpoints, we use a natural spline with zero second derivative on that boundary.
[ "Calculate", "the", "second", "derivatives", "of", "the", "interpolating", "function", "at", "the", "tabulated", "points", ".", "At", "the", "endpoints", "we", "use", "a", "natural", "spline", "with", "zero", "second", "derivative", "on", "that", "boundary", "...
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/interpolation/src/main/java/smile/interpolation/CubicSplineInterpolation1D.java#L73-L92
17,145
haifengl/smile
math/src/main/java/smile/stat/distribution/DiscreteMixture.java
DiscreteMixture.bic
public double bic(double[] data) { if (components.isEmpty()) { throw new IllegalStateException("Mixture is empty!"); } int n = data.length; double logLikelihood = 0.0; for (double x : data) { double p = p(x); if (p > 0) { logL...
java
public double bic(double[] data) { if (components.isEmpty()) { throw new IllegalStateException("Mixture is empty!"); } int n = data.length; double logLikelihood = 0.0; for (double x : data) { double p = p(x); if (p > 0) { logL...
[ "public", "double", "bic", "(", "double", "[", "]", "data", ")", "{", "if", "(", "components", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Mixture is empty!\"", ")", ";", "}", "int", "n", "=", "data", ".", "leng...
BIC score of the mixture for given data.
[ "BIC", "score", "of", "the", "mixture", "for", "given", "data", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/stat/distribution/DiscreteMixture.java#L227-L243
17,146
haifengl/smile
core/src/main/java/smile/clustering/SIB.java
SIB.seed
private static int[] seed(SparseDataset data, int k) { int n = data.size(); int[] y = new int[n]; SparseArray centroid = data.get(Math.randomInt(n)).x; double[] D = new double[n]; for (int i = 0; i < n; i++) { D[i] = Double.MAX_VALUE; } // pick the ...
java
private static int[] seed(SparseDataset data, int k) { int n = data.size(); int[] y = new int[n]; SparseArray centroid = data.get(Math.randomInt(n)).x; double[] D = new double[n]; for (int i = 0; i < n; i++) { D[i] = Double.MAX_VALUE; } // pick the ...
[ "private", "static", "int", "[", "]", "seed", "(", "SparseDataset", "data", ",", "int", "k", ")", "{", "int", "n", "=", "data", ".", "size", "(", ")", ";", "int", "[", "]", "y", "=", "new", "int", "[", "n", "]", ";", "SparseArray", "centroid", ...
Initialize clusters with KMeans++ algorithm.
[ "Initialize", "clusters", "with", "KMeans", "++", "algorithm", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/clustering/SIB.java#L228-L272
17,147
haifengl/smile
math/src/main/java/smile/stat/distribution/TDistribution.java
TDistribution.cdf2tiled
public double cdf2tiled(double x) { if (x < 0) { throw new IllegalArgumentException("Invalid x: " + x); } return 1.0 - Beta.regularizedIncompleteBetaFunction(0.5 * nu, 0.5, nu / (nu + x * x)); }
java
public double cdf2tiled(double x) { if (x < 0) { throw new IllegalArgumentException("Invalid x: " + x); } return 1.0 - Beta.regularizedIncompleteBetaFunction(0.5 * nu, 0.5, nu / (nu + x * x)); }
[ "public", "double", "cdf2tiled", "(", "double", "x", ")", "{", "if", "(", "x", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid x: \"", "+", "x", ")", ";", "}", "return", "1.0", "-", "Beta", ".", "regularizedIncompleteBetaFun...
Two-tailed cdf.
[ "Two", "-", "tailed", "cdf", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/stat/distribution/TDistribution.java#L134-L140
17,148
haifengl/smile
math/src/main/java/smile/stat/distribution/TDistribution.java
TDistribution.quantile2tiled
public double quantile2tiled(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 1.0 - p); return Math.sqrt(nu * (1.0 - x) / x); }
java
public double quantile2tiled(double p) { if (p < 0.0 || p > 1.0) { throw new IllegalArgumentException("Invalid p: " + p); } double x = Beta.inverseRegularizedIncompleteBetaFunction(0.5 * nu, 0.5, 1.0 - p); return Math.sqrt(nu * (1.0 - x) / x); }
[ "public", "double", "quantile2tiled", "(", "double", "p", ")", "{", "if", "(", "p", "<", "0.0", "||", "p", ">", "1.0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid p: \"", "+", "p", ")", ";", "}", "double", "x", "=", "Beta", ...
Two-tailed quantile.
[ "Two", "-", "tailed", "quantile", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/stat/distribution/TDistribution.java#L145-L152
17,149
haifengl/smile
data/src/main/java/smile/data/parser/DelimitedTextParser.java
DelimitedTextParser.parse
public AttributeDataset parse(String name, InputStream stream) throws IOException, ParseException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { return parse(name, null, reader); } }
java
public AttributeDataset parse(String name, InputStream stream) throws IOException, ParseException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { return parse(name, null, reader); } }
[ "public", "AttributeDataset", "parse", "(", "String", "name", ",", "InputStream", "stream", ")", "throws", "IOException", ",", "ParseException", "{", "try", "(", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "strea...
Parse a dataset from an input stream. @param name the name of dataset. @param stream the input stream of data. @throws java.io.FileNotFoundException
[ "Parse", "a", "dataset", "from", "an", "input", "stream", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/DelimitedTextParser.java#L297-L301
17,150
haifengl/smile
plot/src/main/java/smile/plot/Label.java
Label.coordToString
public static String coordToString(double... c) { StringBuilder builder = new StringBuilder("("); for (int i = 0; i < c.length; i++) { builder.append(Math.round(c[i], 2)).append(","); } if (c.length > 0) { builder.setCharAt(builder.length(), ')'); } else ...
java
public static String coordToString(double... c) { StringBuilder builder = new StringBuilder("("); for (int i = 0; i < c.length; i++) { builder.append(Math.round(c[i], 2)).append(","); } if (c.length > 0) { builder.setCharAt(builder.length(), ')'); } else ...
[ "public", "static", "String", "coordToString", "(", "double", "...", "c", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "\"(\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "c", ".", "length", ";", "i", "++", ...
Convert coordinate to a string.
[ "Convert", "coordinate", "to", "a", "string", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Label.java#L179-L192
17,151
haifengl/smile
math/src/main/java/smile/sort/QuickSelect.java
QuickSelect.median
public static <T extends Comparable<? super T>> T median(T[] a) { int k = a.length / 2; return select(a, k); }
java
public static <T extends Comparable<? super T>> T median(T[] a) { int k = a.length / 2; return select(a, k); }
[ "public", "static", "<", "T", "extends", "Comparable", "<", "?", "super", "T", ">", ">", "T", "median", "(", "T", "[", "]", "a", ")", "{", "int", "k", "=", "a", ".", "length", "/", "2", ";", "return", "select", "(", "a", ",", "k", ")", ";", ...
Find the median of an array of type double.
[ "Find", "the", "median", "of", "an", "array", "of", "type", "double", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/sort/QuickSelect.java#L299-L302
17,152
haifengl/smile
core/src/main/java/smile/validation/AUC.java
AUC.measure
public static double measure(int[] truth, double[] probability) { if (truth.length != probability.length) { throw new IllegalArgumentException(String.format("The vector sizes don't match: %d != %d.", truth.length, probability.length)); } // for large sample size, overflow may happen...
java
public static double measure(int[] truth, double[] probability) { if (truth.length != probability.length) { throw new IllegalArgumentException(String.format("The vector sizes don't match: %d != %d.", truth.length, probability.length)); } // for large sample size, overflow may happen...
[ "public", "static", "double", "measure", "(", "int", "[", "]", "truth", ",", "double", "[", "]", "probability", ")", "{", "if", "(", "truth", ".", "length", "!=", "probability", ".", "length", ")", "{", "throw", "new", "IllegalArgumentException", "(", "S...
Caulculate AUC for binary classifier. @param truth The sample labels @param probability The posterior probability of positive class. @return AUC
[ "Caulculate", "AUC", "for", "binary", "classifier", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/validation/AUC.java#L52-L98
17,153
haifengl/smile
core/src/main/java/smile/vq/GrowingNeuralGas.java
GrowingNeuralGas.neurons
public Neuron[] neurons() { HashMap<Integer, Neuron> hash = new HashMap<>(); Neuron[] neurons = new Neuron[nodes.size()]; int i = 0; for (Node node : nodes) { Neuron[] neighbors = new Neuron[node.edges.size()]; neurons[i] = new Neuron(node.w, neighbors); ...
java
public Neuron[] neurons() { HashMap<Integer, Neuron> hash = new HashMap<>(); Neuron[] neurons = new Neuron[nodes.size()]; int i = 0; for (Node node : nodes) { Neuron[] neighbors = new Neuron[node.edges.size()]; neurons[i] = new Neuron(node.w, neighbors); ...
[ "public", "Neuron", "[", "]", "neurons", "(", ")", "{", "HashMap", "<", "Integer", ",", "Neuron", ">", "hash", "=", "new", "HashMap", "<>", "(", ")", ";", "Neuron", "[", "]", "neurons", "=", "new", "Neuron", "[", "nodes", ".", "size", "(", ")", "...
Returns the neurons in the network. @return the neurons in the network.
[ "Returns", "the", "neurons", "in", "the", "network", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/vq/GrowingNeuralGas.java#L225-L250
17,154
haifengl/smile
core/src/main/java/smile/vq/GrowingNeuralGas.java
GrowingNeuralGas.predict
@Override public int predict(double[] x) { double minDist = Double.MAX_VALUE; int bestCluster = 0; int i = 0; for (Node neuron : nodes) { double dist = Math.squaredDistance(x, neuron.w); if (dist < minDist) { minDist = dist; be...
java
@Override public int predict(double[] x) { double minDist = Double.MAX_VALUE; int bestCluster = 0; int i = 0; for (Node neuron : nodes) { double dist = Math.squaredDistance(x, neuron.w); if (dist < minDist) { minDist = dist; be...
[ "@", "Override", "public", "int", "predict", "(", "double", "[", "]", "x", ")", "{", "double", "minDist", "=", "Double", ".", "MAX_VALUE", ";", "int", "bestCluster", "=", "0", ";", "int", "i", "=", "0", ";", "for", "(", "Node", "neuron", ":", "node...
Cluster a new instance to the nearest neuron. @param x a new instance. @return the cluster label. If the method partition() was called, this is the cluster id of nearest neuron. Otherwise, it is just the index of neuron.
[ "Cluster", "a", "new", "instance", "to", "the", "nearest", "neuron", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/vq/GrowingNeuralGas.java#L404-L425
17,155
haifengl/smile
plot/src/main/java/smile/plot/Projection2D.java
Projection2D.inverseProjection
public double[] inverseProjection(int x, int y) { double[] sc = new double[2]; double ratio = (canvas.base.upperBound[0] - canvas.base.lowerBound[0]) / (canvas.getWidth() * (1 - 2 * canvas.margin)); sc[0] = canvas.base.lowerBound[0] + ratio * (x - canvas.getWidth() * canvas.margin); ra...
java
public double[] inverseProjection(int x, int y) { double[] sc = new double[2]; double ratio = (canvas.base.upperBound[0] - canvas.base.lowerBound[0]) / (canvas.getWidth() * (1 - 2 * canvas.margin)); sc[0] = canvas.base.lowerBound[0] + ratio * (x - canvas.getWidth() * canvas.margin); ra...
[ "public", "double", "[", "]", "inverseProjection", "(", "int", "x", ",", "int", "y", ")", "{", "double", "[", "]", "sc", "=", "new", "double", "[", "2", "]", ";", "double", "ratio", "=", "(", "canvas", ".", "base", ".", "upperBound", "[", "0", "]...
Project the screen coordinate back to the logical coordinates. @param x the x of Java2D coordinate in the canvas. @param y the y of Java2D coordinate in the canvas
[ "Project", "the", "screen", "coordinate", "back", "to", "the", "logical", "coordinates", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Projection2D.java#L45-L55
17,156
haifengl/smile
core/src/main/java/smile/vq/SOM.java
SOM.getClusterLabel
public int[][] getClusterLabel() { if (y == null) { throw new IllegalStateException("Neuron cluster labels are not available. Call partition() first."); } int[][] clusterLabels = new int[height][width]; for (int i = 0, l = 0; i < height; i++) { for (int j = 0; j <...
java
public int[][] getClusterLabel() { if (y == null) { throw new IllegalStateException("Neuron cluster labels are not available. Call partition() first."); } int[][] clusterLabels = new int[height][width]; for (int i = 0, l = 0; i < height; i++) { for (int j = 0; j <...
[ "public", "int", "[", "]", "[", "]", "getClusterLabel", "(", ")", "{", "if", "(", "y", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Neuron cluster labels are not available. Call partition() first.\"", ")", ";", "}", "int", "[", "]", ...
Returns the cluster labels for each neuron. If the neurons have not been clustered, throws an Illegal State Exception.
[ "Returns", "the", "cluster", "labels", "for", "each", "neuron", ".", "If", "the", "neurons", "have", "not", "been", "clustered", "throws", "an", "Illegal", "State", "Exception", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/vq/SOM.java#L401-L413
17,157
haifengl/smile
core/src/main/java/smile/vq/SOM.java
SOM.partition
public int[] partition(int k) { int n = width * height; double[][] units = new double[n][d]; for (int i = 0, l = 0; i < height; i++) { for (int j = 0; j < width; j++, l++) { units[l] = neurons[i][j]; } } double[][] proximity = new double[n...
java
public int[] partition(int k) { int n = width * height; double[][] units = new double[n][d]; for (int i = 0, l = 0; i < height; i++) { for (int j = 0; j < width; j++, l++) { units[l] = neurons[i][j]; } } double[][] proximity = new double[n...
[ "public", "int", "[", "]", "partition", "(", "int", "k", ")", "{", "int", "n", "=", "width", "*", "height", ";", "double", "[", "]", "[", "]", "units", "=", "new", "double", "[", "n", "]", "[", "d", "]", ";", "for", "(", "int", "i", "=", "0...
Clustering the neurons into k groups. And then assigns the samples in each neuron to the corresponding cluster. @param k the number of clusters. @return the cluster label of samples.
[ "Clustering", "the", "neurons", "into", "k", "groups", ".", "And", "then", "assigns", "the", "samples", "in", "each", "neuron", "to", "the", "corresponding", "cluster", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/vq/SOM.java#L421-L448
17,158
haifengl/smile
core/src/main/java/smile/vq/SOM.java
SOM.predict
@Override public int predict(double[] x) { double best = Double.MAX_VALUE; int ii = -1, jj = -1; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { double dist = Math.squaredDistance(neurons[i][j], x); if (dist < best) { ...
java
@Override public int predict(double[] x) { double best = Double.MAX_VALUE; int ii = -1, jj = -1; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { double dist = Math.squaredDistance(neurons[i][j], x); if (dist < best) { ...
[ "@", "Override", "public", "int", "predict", "(", "double", "[", "]", "x", ")", "{", "double", "best", "=", "Double", ".", "MAX_VALUE", ";", "int", "ii", "=", "-", "1", ",", "jj", "=", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i"...
Cluster a new instance to the nearest neuron. For clustering purpose, one should build a sufficient large map to capture the structure of data space. Then the neurons of map can be clustered into a small number of clusters. Finally the sample should be assign to the cluster of its nearest neurons. @param x a new insta...
[ "Cluster", "a", "new", "instance", "to", "the", "nearest", "neuron", ".", "For", "clustering", "purpose", "one", "should", "build", "a", "sufficient", "large", "map", "to", "capture", "the", "structure", "of", "data", "space", ".", "Then", "the", "neurons", ...
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/vq/SOM.java#L462-L482
17,159
haifengl/smile
data/src/main/java/smile/data/parser/LibsvmParser.java
LibsvmParser.parse
public SparseDataset parse(String name, String path) throws IOException, ParseException { return parse(name, new File(path)); }
java
public SparseDataset parse(String name, String path) throws IOException, ParseException { return parse(name, new File(path)); }
[ "public", "SparseDataset", "parse", "(", "String", "name", ",", "String", "path", ")", "throws", "IOException", ",", "ParseException", "{", "return", "parse", "(", "name", ",", "new", "File", "(", "path", ")", ")", ";", "}" ]
Parse a libsvm sparse dataset from given file. @param path the file path of data source. @throws java.io.IOException
[ "Parse", "a", "libsvm", "sparse", "dataset", "from", "given", "file", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/LibsvmParser.java#L92-L94
17,160
haifengl/smile
data/src/main/java/smile/data/parser/LibsvmParser.java
LibsvmParser.parse
public SparseDataset parse(String name, InputStream stream) throws IOException, ParseException { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); try { String line = reader.readLine(); if (line == null) { throw new IOException("Empty dat...
java
public SparseDataset parse(String name, InputStream stream) throws IOException, ParseException { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); try { String line = reader.readLine(); if (line == null) { throw new IOException("Empty dat...
[ "public", "SparseDataset", "parse", "(", "String", "name", ",", "InputStream", "stream", ")", "throws", "IOException", ",", "ParseException", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "stream", ")", ")", ...
Parse a libsvm sparse dataset from an input stream. @param name the name of dataset. @param stream the input stream of data. @throws java.io.IOException
[ "Parse", "a", "libsvm", "sparse", "dataset", "from", "an", "input", "stream", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/LibsvmParser.java#L120-L190
17,161
haifengl/smile
data/src/main/java/smile/data/parser/microarray/TXTParser.java
TXTParser.parse
public AttributeDataset parse(String name, String path) throws IOException, ParseException { return parse(name, new File(path)); }
java
public AttributeDataset parse(String name, String path) throws IOException, ParseException { return parse(name, new File(path)); }
[ "public", "AttributeDataset", "parse", "(", "String", "name", ",", "String", "path", ")", "throws", "IOException", ",", "ParseException", "{", "return", "parse", "(", "name", ",", "new", "File", "(", "path", ")", ")", ";", "}" ]
Parse a TXT dataset from given file. @param path the file path of data source. @throws java.io.IOException
[ "Parse", "a", "TXT", "dataset", "from", "given", "file", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/microarray/TXTParser.java#L96-L98
17,162
haifengl/smile
data/src/main/java/smile/data/parser/microarray/TXTParser.java
TXTParser.parse
public AttributeDataset parse(String name, InputStream stream) throws IOException, ParseException { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line = reader.readLine(); if (line == null) { throw new IOException("Empty data source."); } ...
java
public AttributeDataset parse(String name, InputStream stream) throws IOException, ParseException { BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line = reader.readLine(); if (line == null) { throw new IOException("Empty data source."); } ...
[ "public", "AttributeDataset", "parse", "(", "String", "name", ",", "InputStream", "stream", ")", "throws", "IOException", ",", "ParseException", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "stream", ")", ")"...
Parse a TXT dataset from an input stream. @param name the name of dataset. @param stream the input stream of data. @throws java.io.IOException
[ "Parse", "a", "TXT", "dataset", "from", "an", "input", "stream", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/microarray/TXTParser.java#L123-L170
17,163
haifengl/smile
math/src/main/java/smile/math/matrix/Factory.java
Factory.matrix
public static DenseMatrix matrix(double[][] A) { if (nlmatrixZeros != null) { try { return (DenseMatrix) nlmatrixArray2D.newInstance((Object) A); } catch (Exception e) { logger.error("Failed to call NLMatrix(double[][]): {}", e); } } ...
java
public static DenseMatrix matrix(double[][] A) { if (nlmatrixZeros != null) { try { return (DenseMatrix) nlmatrixArray2D.newInstance((Object) A); } catch (Exception e) { logger.error("Failed to call NLMatrix(double[][]): {}", e); } } ...
[ "public", "static", "DenseMatrix", "matrix", "(", "double", "[", "]", "[", "]", "A", ")", "{", "if", "(", "nlmatrixZeros", "!=", "null", ")", "{", "try", "{", "return", "(", "DenseMatrix", ")", "nlmatrixArray2D", ".", "newInstance", "(", "(", "Object", ...
Creates a matrix initialized by A.
[ "Creates", "a", "matrix", "initialized", "by", "A", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/matrix/Factory.java#L70-L80
17,164
haifengl/smile
math/src/main/java/smile/math/matrix/Factory.java
Factory.matrix
public static DenseMatrix matrix(int nrows, int ncols) { if (nlmatrixZeros != null) { try { return (DenseMatrix) nlmatrixZeros.newInstance(nrows, ncols); } catch (Exception e) { logger.error("Failed to call NLMatrix(int, int): {}", e); } ...
java
public static DenseMatrix matrix(int nrows, int ncols) { if (nlmatrixZeros != null) { try { return (DenseMatrix) nlmatrixZeros.newInstance(nrows, ncols); } catch (Exception e) { logger.error("Failed to call NLMatrix(int, int): {}", e); } ...
[ "public", "static", "DenseMatrix", "matrix", "(", "int", "nrows", ",", "int", "ncols", ")", "{", "if", "(", "nlmatrixZeros", "!=", "null", ")", "{", "try", "{", "return", "(", "DenseMatrix", ")", "nlmatrixZeros", ".", "newInstance", "(", "nrows", ",", "n...
Creates a matrix of all zeros.
[ "Creates", "a", "matrix", "of", "all", "zeros", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/matrix/Factory.java#L96-L106
17,165
haifengl/smile
math/src/main/java/smile/math/matrix/Factory.java
Factory.matrix
public static DenseMatrix matrix(int nrows, int ncols, double value) { if (nlmatrixOnes != null) { try { return (DenseMatrix) nlmatrixOnes.newInstance(nrows, ncols, value); } catch (Exception e) { logger.error("Failed to call NLMatrix(int, int, double): {}...
java
public static DenseMatrix matrix(int nrows, int ncols, double value) { if (nlmatrixOnes != null) { try { return (DenseMatrix) nlmatrixOnes.newInstance(nrows, ncols, value); } catch (Exception e) { logger.error("Failed to call NLMatrix(int, int, double): {}...
[ "public", "static", "DenseMatrix", "matrix", "(", "int", "nrows", ",", "int", "ncols", ",", "double", "value", ")", "{", "if", "(", "nlmatrixOnes", "!=", "null", ")", "{", "try", "{", "return", "(", "DenseMatrix", ")", "nlmatrixOnes", ".", "newInstance", ...
Creates a matrix filled with given value.
[ "Creates", "a", "matrix", "filled", "with", "given", "value", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/matrix/Factory.java#L109-L119
17,166
haifengl/smile
plot/src/main/java/smile/plot/QQPlot.java
QQPlot.plot
public static PlotCanvas plot(double[] x) { double[] lowerBound = {Math.min(x), GaussianDistribution.getInstance().quantile(1 / (x.length + 1.0))}; double[] upperBound = {Math.max(x), GaussianDistribution.getInstance().quantile(x.length / (x.length + 1.0))}; PlotCanvas canvas = new PlotCanvas(lo...
java
public static PlotCanvas plot(double[] x) { double[] lowerBound = {Math.min(x), GaussianDistribution.getInstance().quantile(1 / (x.length + 1.0))}; double[] upperBound = {Math.max(x), GaussianDistribution.getInstance().quantile(x.length / (x.length + 1.0))}; PlotCanvas canvas = new PlotCanvas(lo...
[ "public", "static", "PlotCanvas", "plot", "(", "double", "[", "]", "x", ")", "{", "double", "[", "]", "lowerBound", "=", "{", "Math", ".", "min", "(", "x", ")", ",", "GaussianDistribution", ".", "getInstance", "(", ")", ".", "quantile", "(", "1", "/"...
Create a plot canvas with the one sample Q-Q plot to standard normal distribution. The x-axis is the quantiles of x and the y-axis is the quantiles of normal distribution. @param x a sample set.
[ "Create", "a", "plot", "canvas", "with", "the", "one", "sample", "Q", "-", "Q", "plot", "to", "standard", "normal", "distribution", ".", "The", "x", "-", "axis", "is", "the", "quantiles", "of", "x", "and", "the", "y", "-", "axis", "is", "the", "quant...
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/QQPlot.java#L175-L181
17,167
haifengl/smile
plot/src/main/java/smile/plot/QQPlot.java
QQPlot.plot
public static PlotCanvas plot(double[] x, double[] y) { double[] lowerBound = {Math.min(x), Math.min(y)}; double[] upperBound = {Math.max(x), Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new QQPlot(x, y)); return canvas; }
java
public static PlotCanvas plot(double[] x, double[] y) { double[] lowerBound = {Math.min(x), Math.min(y)}; double[] upperBound = {Math.max(x), Math.max(y)}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new QQPlot(x, y)); return canvas; }
[ "public", "static", "PlotCanvas", "plot", "(", "double", "[", "]", "x", ",", "double", "[", "]", "y", ")", "{", "double", "[", "]", "lowerBound", "=", "{", "Math", ".", "min", "(", "x", ")", ",", "Math", ".", "min", "(", "y", ")", "}", ";", "...
Create a plot canvas with the two sample Q-Q plot. The x-axis is the quantiles of x and the y-axis is the quantiles of y. @param x a sample set. @param y a sample set.
[ "Create", "a", "plot", "canvas", "with", "the", "two", "sample", "Q", "-", "Q", "plot", ".", "The", "x", "-", "axis", "is", "the", "quantiles", "of", "x", "and", "the", "y", "-", "axis", "is", "the", "quantiles", "of", "y", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/QQPlot.java#L204-L210
17,168
haifengl/smile
plot/src/main/java/smile/plot/QQPlot.java
QQPlot.plot
public static PlotCanvas plot(int[] x, DiscreteDistribution d) { double[] lowerBound = {Math.min(x), d.quantile(1 / (x.length + 1.0))}; double[] upperBound = {Math.max(x), d.quantile(x.length / (x.length + 1.0))}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new...
java
public static PlotCanvas plot(int[] x, DiscreteDistribution d) { double[] lowerBound = {Math.min(x), d.quantile(1 / (x.length + 1.0))}; double[] upperBound = {Math.max(x), d.quantile(x.length / (x.length + 1.0))}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound); canvas.add(new...
[ "public", "static", "PlotCanvas", "plot", "(", "int", "[", "]", "x", ",", "DiscreteDistribution", "d", ")", "{", "double", "[", "]", "lowerBound", "=", "{", "Math", ".", "min", "(", "x", ")", ",", "d", ".", "quantile", "(", "1", "/", "(", "x", "....
Create a plot canvas with the one sample Q-Q plot to given distribution. The x-axis is the quantiles of x and the y-axis is the quantiles of given distribution. @param x a sample set. @param d a distribution.
[ "Create", "a", "plot", "canvas", "with", "the", "one", "sample", "Q", "-", "Q", "plot", "to", "given", "distribution", ".", "The", "x", "-", "axis", "is", "the", "quantiles", "of", "x", "and", "the", "y", "-", "axis", "is", "the", "quantiles", "of", ...
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/QQPlot.java#L219-L225
17,169
haifengl/smile
plot/src/main/java/smile/plot/Projection3D.java
Projection3D.precompute
private void precompute() { sinTheta = Math.sin(theta); cosTheta = Math.cos(theta); sinPhi = Math.sin(phi); cosPhi = Math.cos(phi); }
java
private void precompute() { sinTheta = Math.sin(theta); cosTheta = Math.cos(theta); sinPhi = Math.sin(phi); cosPhi = Math.cos(phi); }
[ "private", "void", "precompute", "(", ")", "{", "sinTheta", "=", "Math", ".", "sin", "(", "theta", ")", ";", "cosTheta", "=", "Math", ".", "cos", "(", "theta", ")", ";", "sinPhi", "=", "Math", ".", "sin", "(", "phi", ")", ";", "cosPhi", "=", "Mat...
Pre-computes sin and cos of rotation angles.
[ "Pre", "-", "computes", "sin", "and", "cos", "of", "rotation", "angles", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Projection3D.java#L65-L70
17,170
haifengl/smile
plot/src/main/java/smile/plot/Projection3D.java
Projection3D.project
public double[] project(double[] xyz) { double[] coord = new double[3]; coord[0] = cosTheta * xyz[1] - sinTheta * xyz[0]; coord[1] = cosPhi * xyz[2] - sinPhi * cosTheta * xyz[0] - sinPhi * sinTheta * xyz[1]; coord[2] = cosPhi * sinTheta * xyz[1] + sinPhi * xyz[2] + cosPhi * cosTheta * x...
java
public double[] project(double[] xyz) { double[] coord = new double[3]; coord[0] = cosTheta * xyz[1] - sinTheta * xyz[0]; coord[1] = cosPhi * xyz[2] - sinPhi * cosTheta * xyz[0] - sinPhi * sinTheta * xyz[1]; coord[2] = cosPhi * sinTheta * xyz[1] + sinPhi * xyz[2] + cosPhi * cosTheta * x...
[ "public", "double", "[", "]", "project", "(", "double", "[", "]", "xyz", ")", "{", "double", "[", "]", "coord", "=", "new", "double", "[", "3", "]", ";", "coord", "[", "0", "]", "=", "cosTheta", "*", "xyz", "[", "1", "]", "-", "sinTheta", "*", ...
Returns the camera coordinates. @param xyz the world coordinates. @return the camera coordinates.
[ "Returns", "the", "camera", "coordinates", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Projection3D.java#L77-L85
17,171
haifengl/smile
plot/src/main/java/smile/plot/Projection3D.java
Projection3D.z
public double z(double[] xyz) { return cosPhi * sinTheta * xyz[1] + sinPhi * xyz[2] + cosPhi * cosTheta * xyz[0]; }
java
public double z(double[] xyz) { return cosPhi * sinTheta * xyz[1] + sinPhi * xyz[2] + cosPhi * cosTheta * xyz[0]; }
[ "public", "double", "z", "(", "double", "[", "]", "xyz", ")", "{", "return", "cosPhi", "*", "sinTheta", "*", "xyz", "[", "1", "]", "+", "sinPhi", "*", "xyz", "[", "2", "]", "+", "cosPhi", "*", "cosTheta", "*", "xyz", "[", "0", "]", ";", "}" ]
Returns z-axis value in the camera coordinates. @param xyz the world coordinates. @return z-axis value in the camera coordinates.
[ "Returns", "z", "-", "axis", "value", "in", "the", "camera", "coordinates", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Projection3D.java#L92-L94
17,172
haifengl/smile
plot/src/main/java/smile/plot/Projection3D.java
Projection3D.rotate
public void rotate(double t, double p) { theta = theta - t / 100; phi = phi + p / 100; precompute(); reset(); }
java
public void rotate(double t, double p) { theta = theta - t / 100; phi = phi + p / 100; precompute(); reset(); }
[ "public", "void", "rotate", "(", "double", "t", ",", "double", "p", ")", "{", "theta", "=", "theta", "-", "t", "/", "100", ";", "phi", "=", "phi", "+", "p", "/", "100", ";", "precompute", "(", ")", ";", "reset", "(", ")", ";", "}" ]
Rotates the plot, i.e. change the view angle. @param t the change add to &theta; @param p the change add to &phi;
[ "Rotates", "the", "plot", "i", ".", "e", ".", "change", "the", "view", "angle", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Projection3D.java#L133-L138
17,173
haifengl/smile
netlib/src/main/java/smile/netlib/LU.java
LU.pivsign
private static int pivsign(int[] piv, int n) { int pivsign = 1; for (int i = 0; i < n; i++) { if (piv[i] != (i+1)) pivsign = -pivsign; } return pivsign; }
java
private static int pivsign(int[] piv, int n) { int pivsign = 1; for (int i = 0; i < n; i++) { if (piv[i] != (i+1)) pivsign = -pivsign; } return pivsign; }
[ "private", "static", "int", "pivsign", "(", "int", "[", "]", "piv", ",", "int", "n", ")", "{", "int", "pivsign", "=", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "if", "(", "piv", "[", "i", "]...
Returns the pivot sign.
[ "Returns", "the", "pivot", "sign", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/netlib/src/main/java/smile/netlib/LU.java#L55-L63
17,174
haifengl/smile
netlib/src/main/java/smile/netlib/LU.java
LU.inverse
@Override public DenseMatrix inverse() { int m = lu.nrows(); int n = lu.ncols(); if (m != n) { throw new IllegalArgumentException(String.format("Matrix is not square: %d x %d", m, n)); } int nb = LAPACK.getInstance().ilaenv(1, "DGETRI", "", n, -1, -1, -1); ...
java
@Override public DenseMatrix inverse() { int m = lu.nrows(); int n = lu.ncols(); if (m != n) { throw new IllegalArgumentException(String.format("Matrix is not square: %d x %d", m, n)); } int nb = LAPACK.getInstance().ilaenv(1, "DGETRI", "", n, -1, -1, -1); ...
[ "@", "Override", "public", "DenseMatrix", "inverse", "(", ")", "{", "int", "m", "=", "lu", ".", "nrows", "(", ")", ";", "int", "n", "=", "lu", ".", "ncols", "(", ")", ";", "if", "(", "m", "!=", "n", ")", "{", "throw", "new", "IllegalArgumentExcep...
Returns the matrix inverse. The LU matrix will overwritten with the inverse of the original matrix.
[ "Returns", "the", "matrix", "inverse", ".", "The", "LU", "matrix", "will", "overwritten", "with", "the", "inverse", "of", "the", "original", "matrix", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/netlib/src/main/java/smile/netlib/LU.java#L69-L96
17,175
haifengl/smile
core/src/main/java/smile/neighbor/CoverTree.java
CoverTree.buildCoverTree
private void buildCoverTree() { ArrayList<DistanceSet> pointSet = new ArrayList<>(); ArrayList<DistanceSet> consumedSet = new ArrayList<>(); E point = data[0]; int idx = 0; double maxDist = -1; for (int i = 1; i < data.length; i++) { DistanceSet set = new Di...
java
private void buildCoverTree() { ArrayList<DistanceSet> pointSet = new ArrayList<>(); ArrayList<DistanceSet> consumedSet = new ArrayList<>(); E point = data[0]; int idx = 0; double maxDist = -1; for (int i = 1; i < data.length; i++) { DistanceSet set = new Di...
[ "private", "void", "buildCoverTree", "(", ")", "{", "ArrayList", "<", "DistanceSet", ">", "pointSet", "=", "new", "ArrayList", "<>", "(", ")", ";", "ArrayList", "<", "DistanceSet", ">", "consumedSet", "=", "new", "ArrayList", "<>", "(", ")", ";", "E", "p...
Builds the cover tree.
[ "Builds", "the", "cover", "tree", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/CoverTree.java#L265-L284
17,176
haifengl/smile
core/src/main/java/smile/neighbor/CoverTree.java
CoverTree.max
private double max(ArrayList<DistanceSet> v) { double max = 0.0; for (DistanceSet n : v) { if (max < n.dist.get(n.dist.size() - 1)) { max = n.dist.get(n.dist.size() - 1); } } return max; }
java
private double max(ArrayList<DistanceSet> v) { double max = 0.0; for (DistanceSet n : v) { if (max < n.dist.get(n.dist.size() - 1)) { max = n.dist.get(n.dist.size() - 1); } } return max; }
[ "private", "double", "max", "(", "ArrayList", "<", "DistanceSet", ">", "v", ")", "{", "double", "max", "=", "0.0", ";", "for", "(", "DistanceSet", "n", ":", "v", ")", "{", "if", "(", "max", "<", "n", ".", "dist", ".", "get", "(", "n", ".", "dis...
Returns the max distance of the reference point p in current node to it's children nodes. @param v the stack of DistanceNode objects. @return the distance of the furthest child.
[ "Returns", "the", "max", "distance", "of", "the", "reference", "point", "p", "in", "current", "node", "to", "it", "s", "children", "nodes", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/neighbor/CoverTree.java#L430-L438
17,177
haifengl/smile
symbolic/src/main/java/smile/symbolic/Calculus.java
Calculus.diff
public static String diff(String expression) throws InvalidExpressionException { ExpressionTree expTree = parseToTree(expression); expTree.derive(); expTree.reduce(); return expTree.toString(); }
java
public static String diff(String expression) throws InvalidExpressionException { ExpressionTree expTree = parseToTree(expression); expTree.derive(); expTree.reduce(); return expTree.toString(); }
[ "public", "static", "String", "diff", "(", "String", "expression", ")", "throws", "InvalidExpressionException", "{", "ExpressionTree", "expTree", "=", "parseToTree", "(", "expression", ")", ";", "expTree", ".", "derive", "(", ")", ";", "expTree", ".", "reduce", ...
Compute the symbolic derivative. @param expression the mathematical expression
[ "Compute", "the", "symbolic", "derivative", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/symbolic/src/main/java/smile/symbolic/Calculus.java#L30-L37
17,178
haifengl/smile
symbolic/src/main/java/smile/symbolic/Calculus.java
Calculus.diff
public static final double diff(String expression, double val) throws InvalidExpressionException { ExpressionTree expTree = parseToTree(expression); expTree.derive(); expTree.reduce(); return expTree.getVal(); }
java
public static final double diff(String expression, double val) throws InvalidExpressionException { ExpressionTree expTree = parseToTree(expression); expTree.derive(); expTree.reduce(); return expTree.getVal(); }
[ "public", "static", "final", "double", "diff", "(", "String", "expression", ",", "double", "val", ")", "throws", "InvalidExpressionException", "{", "ExpressionTree", "expTree", "=", "parseToTree", "(", "expression", ")", ";", "expTree", ".", "derive", "(", ")", ...
Compute numeric derivative @param expression the mathematical expression @param val the value for which to evaluate the expression at @return numeric derivative
[ "Compute", "numeric", "derivative" ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/symbolic/src/main/java/smile/symbolic/Calculus.java#L45-L53
17,179
haifengl/smile
symbolic/src/main/java/smile/symbolic/Calculus.java
Calculus.diffReadable
public static String diffReadable(String expression) throws InvalidExpressionException { ExpressionParser p = new ExpressionParser(); return p.format(diff(expression)); }
java
public static String diffReadable(String expression) throws InvalidExpressionException { ExpressionParser p = new ExpressionParser(); return p.format(diff(expression)); }
[ "public", "static", "String", "diffReadable", "(", "String", "expression", ")", "throws", "InvalidExpressionException", "{", "ExpressionParser", "p", "=", "new", "ExpressionParser", "(", ")", ";", "return", "p", ".", "format", "(", "diff", "(", "expression", ")"...
Compute the reformatted symbolic derivative. @param expression the mathematical expressino @return "readable" form of the derived expression. Unnecessary * are deleted and unary minus is changed from $ to -.
[ "Compute", "the", "reformatted", "symbolic", "derivative", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/symbolic/src/main/java/smile/symbolic/Calculus.java#L61-L66
17,180
haifengl/smile
symbolic/src/main/java/smile/symbolic/Calculus.java
Calculus.rewrite
public static String rewrite(String expression) throws InvalidExpressionException { ExpressionTree expTree = parseToTree(expression); expTree.reduce(); return expTree.toString(); }
java
public static String rewrite(String expression) throws InvalidExpressionException { ExpressionTree expTree = parseToTree(expression); expTree.reduce(); return expTree.toString(); }
[ "public", "static", "String", "rewrite", "(", "String", "expression", ")", "throws", "InvalidExpressionException", "{", "ExpressionTree", "expTree", "=", "parseToTree", "(", "expression", ")", ";", "expTree", ".", "reduce", "(", ")", ";", "return", "expTree", "....
Rewrite the expression to eliminate redundant terms and simplify the expression. @param expression @return @throws InvalidExpressionException
[ "Rewrite", "the", "expression", "to", "eliminate", "redundant", "terms", "and", "simplify", "the", "expression", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/symbolic/src/main/java/smile/symbolic/Calculus.java#L74-L81
17,181
haifengl/smile
symbolic/src/main/java/smile/symbolic/Calculus.java
Calculus.parseToTree
private static final ExpressionTree parseToTree(String expression) throws InvalidExpressionException { ExpressionParser parser = new ExpressionParser(); parser.parse(expression); return new ExpressionTree(parser.getVar(), parser.getTokens()); }
java
private static final ExpressionTree parseToTree(String expression) throws InvalidExpressionException { ExpressionParser parser = new ExpressionParser(); parser.parse(expression); return new ExpressionTree(parser.getVar(), parser.getTokens()); }
[ "private", "static", "final", "ExpressionTree", "parseToTree", "(", "String", "expression", ")", "throws", "InvalidExpressionException", "{", "ExpressionParser", "parser", "=", "new", "ExpressionParser", "(", ")", ";", "parser", ".", "parse", "(", "expression", ")",...
Parse a mathematical expression and form a binary expression tree. @param expression @return @throws InvalidExpressionException
[ "Parse", "a", "mathematical", "expression", "and", "form", "a", "binary", "expression", "tree", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/symbolic/src/main/java/smile/symbolic/Calculus.java#L100-L106
17,182
haifengl/smile
math/src/main/java/smile/stat/distribution/BinomialDistribution.java
BinomialDistribution.rand
@Override public double rand() { double np = n * p; // Poisson approximation for extremely low np if (np < 1.E-6) { return PoissonDistribution.tinyLambdaRand(np); } boolean inv = false; // invert if (p > 0.5) { // fast...
java
@Override public double rand() { double np = n * p; // Poisson approximation for extremely low np if (np < 1.E-6) { return PoissonDistribution.tinyLambdaRand(np); } boolean inv = false; // invert if (p > 0.5) { // fast...
[ "@", "Override", "public", "double", "rand", "(", ")", "{", "double", "np", "=", "n", "*", "p", ";", "// Poisson approximation for extremely low np", "if", "(", "np", "<", "1.E-6", ")", "{", "return", "PoissonDistribution", ".", "tinyLambdaRand", "(", "np", ...
This function generates a random variate with the binomial distribution. Uses down/up search from the mode by chop-down technique for n*p &lt; 55, and patchwork rejection method for n*p &ge; 55. For n*p &lt; 1.E-6 numerical inaccuracy is avoided by poisson approximation.
[ "This", "function", "generates", "a", "random", "variate", "with", "the", "binomial", "distribution", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/stat/distribution/BinomialDistribution.java#L200-L237
17,183
haifengl/smile
math/src/main/java/smile/math/distance/EditDistance.java
EditDistance.weightedEdit
private double weightedEdit(char[] x, char[] y) { // switch parameters to use the shorter one as y to save space. if (x.length < y.length) { char[] swap = x; x = y; y = swap; } int radius = (int) Math.round(r * Math.max(x.length, y.length)); ...
java
private double weightedEdit(char[] x, char[] y) { // switch parameters to use the shorter one as y to save space. if (x.length < y.length) { char[] swap = x; x = y; y = swap; } int radius = (int) Math.round(r * Math.max(x.length, y.length)); ...
[ "private", "double", "weightedEdit", "(", "char", "[", "]", "x", ",", "char", "[", "]", "y", ")", "{", "// switch parameters to use the shorter one as y to save space.", "if", "(", "x", ".", "length", "<", "y", ".", "length", ")", "{", "char", "[", "]", "s...
Weighted edit distance.
[ "Weighted", "edit", "distance", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/distance/EditDistance.java#L166-L217
17,184
haifengl/smile
math/src/main/java/smile/math/distance/EditDistance.java
EditDistance.br
private int br(char[] x, char[] y) { if (x.length > y.length) { char[] swap = x; x = y; y = swap; } final int m = x.length; final int n = y.length; int ZERO_K = n; if (n+2 > FKP[0].length) FKP = new int[2*n+1][n+2]; ...
java
private int br(char[] x, char[] y) { if (x.length > y.length) { char[] swap = x; x = y; y = swap; } final int m = x.length; final int n = y.length; int ZERO_K = n; if (n+2 > FKP[0].length) FKP = new int[2*n+1][n+2]; ...
[ "private", "int", "br", "(", "char", "[", "]", "x", ",", "char", "[", "]", "y", ")", "{", "if", "(", "x", ".", "length", ">", "y", ".", "length", ")", "{", "char", "[", "]", "swap", "=", "x", ";", "x", "=", "y", ";", "y", "=", "swap", "...
Berghel & Roach's extended Ukkonen's algorithm.
[ "Berghel", "&", "Roach", "s", "extended", "Ukkonen", "s", "algorithm", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/distance/EditDistance.java#L278-L324
17,185
haifengl/smile
plot/src/main/java/smile/plot/Heatmap.java
Heatmap.init
private void init() { if (x == null) { x = new double[z[0].length]; for (int i = 0; i < x.length; i++) { x[i] = i + 0.5; } } if (y == null) { y = new double[z.length]; for (int i = 0; i < y.length; i++) { ...
java
private void init() { if (x == null) { x = new double[z[0].length]; for (int i = 0; i < x.length; i++) { x[i] = i + 0.5; } } if (y == null) { y = new double[z.length]; for (int i = 0; i < y.length; i++) { ...
[ "private", "void", "init", "(", ")", "{", "if", "(", "x", "==", "null", ")", "{", "x", "=", "new", "double", "[", "z", "[", "0", "]", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "x", ".", "length", ";", "i", ...
Initialize the internal variables.
[ "Initialize", "the", "internal", "variables", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Heatmap.java#L163-L197
17,186
haifengl/smile
math/src/main/java/smile/math/Complex.java
Complex.minus
public Complex minus(Complex b) { Complex a = this; double real = a.re - b.re; double imag = a.im - b.im; return new Complex(real, imag); }
java
public Complex minus(Complex b) { Complex a = this; double real = a.re - b.re; double imag = a.im - b.im; return new Complex(real, imag); }
[ "public", "Complex", "minus", "(", "Complex", "b", ")", "{", "Complex", "a", "=", "this", ";", "double", "real", "=", "a", ".", "re", "-", "b", ".", "re", ";", "double", "imag", "=", "a", ".", "im", "-", "b", ".", "im", ";", "return", "new", ...
Returns this - b.
[ "Returns", "this", "-", "b", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/Complex.java#L112-L117
17,187
haifengl/smile
math/src/main/java/smile/math/Complex.java
Complex.reciprocal
public Complex reciprocal() { double scale = re * re + im * im; return new Complex(re / scale, -im / scale); }
java
public Complex reciprocal() { double scale = re * re + im * im; return new Complex(re / scale, -im / scale); }
[ "public", "Complex", "reciprocal", "(", ")", "{", "double", "scale", "=", "re", "*", "re", "+", "im", "*", "im", ";", "return", "new", "Complex", "(", "re", "/", "scale", ",", "-", "im", "/", "scale", ")", ";", "}" ]
Returns the reciprocal.
[ "Returns", "the", "reciprocal", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/Complex.java#L167-L170
17,188
haifengl/smile
math/src/main/java/smile/math/Complex.java
Complex.exp
public Complex exp() { return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im)); }
java
public Complex exp() { return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im)); }
[ "public", "Complex", "exp", "(", ")", "{", "return", "new", "Complex", "(", "Math", ".", "exp", "(", "re", ")", "*", "Math", ".", "cos", "(", "im", ")", ",", "Math", ".", "exp", "(", "re", ")", "*", "Math", ".", "sin", "(", "im", ")", ")", ...
Returns the complex exponential.
[ "Returns", "the", "complex", "exponential", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/Complex.java#L189-L191
17,189
haifengl/smile
math/src/main/java/smile/math/Complex.java
Complex.sin
public Complex sin() { return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im)); }
java
public Complex sin() { return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im)); }
[ "public", "Complex", "sin", "(", ")", "{", "return", "new", "Complex", "(", "Math", ".", "sin", "(", "re", ")", "*", "Math", ".", "cosh", "(", "im", ")", ",", "Math", ".", "cos", "(", "re", ")", "*", "Math", ".", "sinh", "(", "im", ")", ")", ...
Returns the complex sine.
[ "Returns", "the", "complex", "sine", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/Complex.java#L196-L198
17,190
haifengl/smile
core/src/main/java/smile/regression/ElasticNet.java
ElasticNet.getAugmentedResponse
private double[] getAugmentedResponse(double[] y) { double[] ret = new double[y.length + p]; System.arraycopy(y, 0, ret, 0, y.length); return ret; }
java
private double[] getAugmentedResponse(double[] y) { double[] ret = new double[y.length + p]; System.arraycopy(y, 0, ret, 0, y.length); return ret; }
[ "private", "double", "[", "]", "getAugmentedResponse", "(", "double", "[", "]", "y", ")", "{", "double", "[", "]", "ret", "=", "new", "double", "[", "y", ".", "length", "+", "p", "]", ";", "System", ".", "arraycopy", "(", "y", ",", "0", ",", "ret...
transform the original response array by padding 0 at the tail @param y original response array @return response array with padding 0 at tail
[ "transform", "the", "original", "response", "array", "by", "padding", "0", "at", "the", "tail" ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/regression/ElasticNet.java#L163-L167
17,191
haifengl/smile
core/src/main/java/smile/regression/ElasticNet.java
ElasticNet.getAugmentedData
private double[][] getAugmentedData(double[][] x) { double[][] ret = new double[x.length + p][p]; double padding = c * Math.sqrt(lambda2); for (int i = 0; i < x.length; i++) { for (int j = 0; j < p; j++) { ret[i][j] = c * x[i][j]; } } for (...
java
private double[][] getAugmentedData(double[][] x) { double[][] ret = new double[x.length + p][p]; double padding = c * Math.sqrt(lambda2); for (int i = 0; i < x.length; i++) { for (int j = 0; j < p; j++) { ret[i][j] = c * x[i][j]; } } for (...
[ "private", "double", "[", "]", "[", "]", "getAugmentedData", "(", "double", "[", "]", "[", "]", "x", ")", "{", "double", "[", "]", "[", "]", "ret", "=", "new", "double", "[", "x", ".", "length", "+", "p", "]", "[", "p", "]", ";", "double", "p...
transform the original data array by padding a weighted identity matrix and multiply a scaling @param x the original data array @return data with padding
[ "transform", "the", "original", "data", "array", "by", "padding", "a", "weighted", "identity", "matrix", "and", "multiply", "a", "scaling" ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/regression/ElasticNet.java#L177-L189
17,192
haifengl/smile
data/src/main/java/smile/data/parser/BinarySparseDatasetParser.java
BinarySparseDatasetParser.parse
public BinarySparseDataset parse(String name, URI uri) throws IOException, ParseException { return parse(name, new File(uri)); }
java
public BinarySparseDataset parse(String name, URI uri) throws IOException, ParseException { return parse(name, new File(uri)); }
[ "public", "BinarySparseDataset", "parse", "(", "String", "name", ",", "URI", "uri", ")", "throws", "IOException", ",", "ParseException", "{", "return", "parse", "(", "name", ",", "new", "File", "(", "uri", ")", ")", ";", "}" ]
Parse a binary sparse dataset from given URI. @param uri the URI of data source. @throws java.io.IOException
[ "Parse", "a", "binary", "sparse", "dataset", "from", "given", "URI", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/BinarySparseDatasetParser.java#L61-L63
17,193
haifengl/smile
data/src/main/java/smile/data/parser/BinarySparseDatasetParser.java
BinarySparseDatasetParser.parse
public BinarySparseDataset parse(String name, InputStream stream) throws IOException, ParseException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { BinarySparseDataset sparse = new BinarySparseDataset(name); String line = reader.readLine(); ...
java
public BinarySparseDataset parse(String name, InputStream stream) throws IOException, ParseException { try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { BinarySparseDataset sparse = new BinarySparseDataset(name); String line = reader.readLine(); ...
[ "public", "BinarySparseDataset", "parse", "(", "String", "name", ",", "InputStream", "stream", ")", "throws", "IOException", ",", "ParseException", "{", "try", "(", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "new", "InputStreamReader", "(", "st...
Parse a binary sparse dataset from an input stream. @param name the name of dataset. @param stream the input stream of data. @throws java.io.IOException
[ "Parse", "a", "binary", "sparse", "dataset", "from", "an", "input", "stream", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/data/src/main/java/smile/data/parser/BinarySparseDatasetParser.java#L115-L152
17,194
haifengl/smile
plot/src/main/java/smile/plot/Hexmap.java
Hexmap.plot
public static PlotCanvas plot(double[][] data) { double[] lowerBound = {-0.5, 0.36}; double[] upperBound = {data[0].length, data.length * 0.87 + 0.5}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Hexmap(data)); canvas.getAxis(0).setFrameVisib...
java
public static PlotCanvas plot(double[][] data) { double[] lowerBound = {-0.5, 0.36}; double[] upperBound = {data[0].length, data.length * 0.87 + 0.5}; PlotCanvas canvas = new PlotCanvas(lowerBound, upperBound, false); canvas.add(new Hexmap(data)); canvas.getAxis(0).setFrameVisib...
[ "public", "static", "PlotCanvas", "plot", "(", "double", "[", "]", "[", "]", "data", ")", "{", "double", "[", "]", "lowerBound", "=", "{", "-", "0.5", ",", "0.36", "}", ";", "double", "[", "]", "upperBound", "=", "{", "data", "[", "0", "]", ".", ...
Create a plot canvas with the pseudo hexmap plot of given data. @param data a data matrix to be shown in hexmap.
[ "Create", "a", "plot", "canvas", "with", "the", "pseudo", "hexmap", "plot", "of", "given", "data", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/Hexmap.java#L241-L255
17,195
haifengl/smile
plot/src/main/java/smile/swing/table/DateCellEditor.java
DateCellEditor.stopCellEditing
@Override public boolean stopCellEditing() { JFormattedTextField ftf = (JFormattedTextField) getComponent(); if (ftf.isEditValid()) { try { ftf.commitEdit(); } catch (java.text.ParseException ex) { } } else { //text is invalid ...
java
@Override public boolean stopCellEditing() { JFormattedTextField ftf = (JFormattedTextField) getComponent(); if (ftf.isEditValid()) { try { ftf.commitEdit(); } catch (java.text.ParseException ex) { } } else { //text is invalid ...
[ "@", "Override", "public", "boolean", "stopCellEditing", "(", ")", "{", "JFormattedTextField", "ftf", "=", "(", "JFormattedTextField", ")", "getComponent", "(", ")", ";", "if", "(", "ftf", ".", "isEditValid", "(", ")", ")", "{", "try", "{", "ftf", ".", "...
of this method so that everything gets cleaned up.
[ "of", "this", "method", "so", "that", "everything", "gets", "cleaned", "up", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/swing/table/DateCellEditor.java#L129-L144
17,196
haifengl/smile
plot/src/main/java/smile/plot/BarPlot.java
BarPlot.init
private void init() { width = Double.MAX_VALUE; for (int i = 1; i < data.length; i++) { double w = Math.abs(data[i][0] - data[i - 1][0]); if (width > w) { width = w; } } leftTop = new double[data.length][2]; rightTop = new doub...
java
private void init() { width = Double.MAX_VALUE; for (int i = 1; i < data.length; i++) { double w = Math.abs(data[i][0] - data[i - 1][0]); if (width > w) { width = w; } } leftTop = new double[data.length][2]; rightTop = new doub...
[ "private", "void", "init", "(", ")", "{", "width", "=", "Double", ".", "MAX_VALUE", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "data", ".", "length", ";", "i", "++", ")", "{", "double", "w", "=", "Math", ".", "abs", "(", "data", "[...
Calculate bar width and position.
[ "Calculate", "bar", "width", "and", "position", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/plot/src/main/java/smile/plot/BarPlot.java#L144-L171
17,197
haifengl/smile
math/src/main/java/smile/stat/distribution/HyperGeometricDistribution.java
HyperGeometricDistribution.rand
@Override public double rand() { int mm = m; int nn = n; if (mm > N / 2) { // invert mm mm = N - mm; } if (nn > N / 2) { // invert nn nn = N - nn; } if (nn > mm) { // swap nn and mm int...
java
@Override public double rand() { int mm = m; int nn = n; if (mm > N / 2) { // invert mm mm = N - mm; } if (nn > N / 2) { // invert nn nn = N - nn; } if (nn > mm) { // swap nn and mm int...
[ "@", "Override", "public", "double", "rand", "(", ")", "{", "int", "mm", "=", "m", ";", "int", "nn", "=", "n", ";", "if", "(", "mm", ">", "N", "/", "2", ")", "{", "// invert mm", "mm", "=", "N", "-", "mm", ";", "}", "if", "(", "nn", ">", ...
Uses inversion by chop-down search from the mode when the mean &lt; 20 and the patchwork-rejection method when the mean &gt; 20.
[ "Uses", "inversion", "by", "chop", "-", "down", "search", "from", "the", "mode", "when", "the", "mean", "&lt", ";", "20", "and", "the", "patchwork", "-", "rejection", "method", "when", "the", "mean", "&gt", ";", "20", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/stat/distribution/HyperGeometricDistribution.java#L179-L212
17,198
haifengl/smile
core/src/main/java/smile/clustering/linkage/Linkage.java
Linkage.init
void init(double[][] proximity) { size = proximity.length; this.proximity = new float[size * (size+1) / 2]; // row wise /* for (int i = 0, k = 0; i < size; i++) { double[] pi = proximity[i]; for (int j = 0; j <= i; j++, k++) { this.proximi...
java
void init(double[][] proximity) { size = proximity.length; this.proximity = new float[size * (size+1) / 2]; // row wise /* for (int i = 0, k = 0; i < size; i++) { double[] pi = proximity[i]; for (int j = 0; j <= i; j++, k++) { this.proximi...
[ "void", "init", "(", "double", "[", "]", "[", "]", "proximity", ")", "{", "size", "=", "proximity", ".", "length", ";", "this", ".", "proximity", "=", "new", "float", "[", "size", "*", "(", "size", "+", "1", ")", "/", "2", "]", ";", "// row wise"...
Initialize the linkage with the lower triangular proximity matrix.
[ "Initialize", "the", "linkage", "with", "the", "lower", "triangular", "proximity", "matrix", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/core/src/main/java/smile/clustering/linkage/Linkage.java#L46-L66
17,199
haifengl/smile
math/src/main/java/smile/math/distance/MinkowskiDistance.java
MinkowskiDistance.d
public double d(int[] x, int[] y) { if (x.length != y.length) throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); double dist = 0.0; if (weight == null) { for (int i = 0; i < x.length; i++) { ...
java
public double d(int[] x, int[] y) { if (x.length != y.length) throw new IllegalArgumentException(String.format("Arrays have different length: x[%d], y[%d]", x.length, y.length)); double dist = 0.0; if (weight == null) { for (int i = 0; i < x.length; i++) { ...
[ "public", "double", "d", "(", "int", "[", "]", "x", ",", "int", "[", "]", "y", ")", "{", "if", "(", "x", ".", "length", "!=", "y", ".", "length", ")", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"Arrays have diffe...
Minkowski distance between the two arrays of type integer.
[ "Minkowski", "distance", "between", "the", "two", "arrays", "of", "type", "integer", "." ]
e27e43e90fbaacce3f99d30120cf9dd6a764c33d
https://github.com/haifengl/smile/blob/e27e43e90fbaacce3f99d30120cf9dd6a764c33d/math/src/main/java/smile/math/distance/MinkowskiDistance.java#L77-L99