11 |
--------------------------------------------------------------------------------
/apps/ml/includes/ml.json:
--------------------------------------------------------------------------------
1 | {
2 | "NO_OF_ROWS":10000,
3 | "algoTypes" : {
4 | "classification" : "Classification",
5 | "numericalPrediction":"Numerical_Prediction",
6 | "clustering":"Clustering"
7 | },
8 | "featureTypes" : {
9 | "categorical" : "CATEGORICAL",
10 | "numerical" : "NUMERICAL"
11 | },
12 | "imputeOptions" : {
13 | "discard":"DISCARD",
14 | "regressionImputation":"REGRESSION_IMPUTATION",
15 | "replaceWithMean":"REPLACE_WTH_MEAN"
16 | }
17 | }
--------------------------------------------------------------------------------
/apps/ml/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | target/
3 | test-output/
4 | # Mobile Tools for Java (J2ME)
5 | .mtj.tmp/
6 | # Eclipse project files
7 | .classpath
8 | .project
9 | .settings
10 | # Idea project files
11 | .idea
12 | *.iml
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | # OSX files
18 | .DS_Store
19 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
20 | hs_err_pid*
21 | *.iml
22 | .classpath
23 | .project
24 | .prefs
25 | sonar-pom.xml
26 | ._*
27 | *.mar
28 | *~
29 | *.em
30 | *.log
31 | *.db
32 | components/ml/*/bin/*
33 | components/extensions/*/bin/*
34 |
--------------------------------------------------------------------------------
/features/ml/org.wso2.carbon.ml.jaggery.app.feature/resources/p2.inf:
--------------------------------------------------------------------------------
1 | instructions.configure = \
2 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/);\
3 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/);\
4 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\
5 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.jaggery.app_${feature.version}/apps/ml/,target:${installFolder}/../../deployment/server/jaggeryapps/ml/,overwrite:true);\
6 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/resources/META-INF/services.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 | true
9 | true
10 | /permission/protected/manage
11 |
12 |
--------------------------------------------------------------------------------
/apps/ml/site/conf/site.json:
--------------------------------------------------------------------------------
1 | {
2 | "context" : "/ml",
3 | "hostname" : "localhost",
4 | "httpsport" : "9443",
5 | "request_url":"READ_FROM_REQUEST",
6 | "tagWiseMode" :"false",
7 | "tagGroupKey" :"-group",
8 | "ssoConfiguration" : {
9 | "enabled" : "false",
10 | "issuer" : "ML",
11 | "identityProviderURL" : "https://localhost:9443/samlsso",
12 | "keyStorePassword" : "",
13 | "identityAlias" : "",
14 | "responseSigningEnabled":"true",
15 | "keyStoreName" :""
16 | },
17 | "forum" : {
18 | "topicsPerPage" : "5",
19 | "repliesPerPage" : "5",
20 | "resourceIdentifier" : "common"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/apps/ml/session/sessionCheck.jag:
--------------------------------------------------------------------------------
1 | <%
2 | include("../jagg/jagg.jag");
3 |
4 | (function () {
5 | response.contentType = "application/json; charset=UTF-8";
6 | var log = new Log();
7 | var action = request.getParameter("action");
8 | if (action === "sessionCheck") {
9 | if (log.isDebugEnabled()) {
10 | log.debug("Session check for" + jagg.getUser());
11 | }
12 | if(jagg.getUser() == null){
13 | print({
14 | error:true,
15 | message:'sessionOut'
16 | });
17 | }
18 | } else {
19 | print({
20 | error:true,
21 | message:msg.error.invalidAction(action)
22 | });
23 | }
24 | }());
25 | %>
--------------------------------------------------------------------------------
/features/ml/org.wso2.carbon.ml.rest.api.feature/src/main/resources/p2.inf:
--------------------------------------------------------------------------------
1 | instructions.configure = \
2 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/);\
3 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/);\
4 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
5 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.rest.api_${feature.version}/api.war,target:${installFolder}/../../deployment/server/webapps/api.war,overwrite:true);\
6 | org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../features/org.wso2.carbon.ml.rest.api_${feature.version}/api.war);\
7 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/handler/AuthenticationContext.java:
--------------------------------------------------------------------------------
1 | package org.wso2.carbon.ml.rest.api.handler;
2 |
3 | import org.wso2.carbon.context.PrivilegedCarbonContext;
4 |
5 | public class AuthenticationContext {
6 |
7 | public static boolean isAthenticated() {
8 | // If the user-name, tenant Domain and tenant ID is not set in carbon context, conclude as not authenticated.
9 | // This is done to authenticate each request.
10 | PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
11 | return (carbonContext.getUsername()!= null && carbonContext.getTenantDomain() != null && carbonContext.getTenantId() != 0);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/features/ml/org.wso2.carbon.ml.core.feature/src/main/resources/p2.inf:
--------------------------------------------------------------------------------
1 | instructions.configure = \
2 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.core_${feature.version}/conf/machine-learner.xml,target:${installFolder}/../../conf/machine-learner.xml,overwrite:true);\
3 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.core_${feature.version}/conf/etc/h2o-config.xml,target:${installFolder}/../../conf/etc/h2o-config.xml,overwrite:true);\
4 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.core_${feature.version}/conf/etc/ml-email-templates.xml,target:${installFolder}/../../conf/etc/ml-email-templates.xml,overwrite:true);\
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/test/resources/fcMalformedSample.csv:
--------------------------------------------------------------------------------
1 | 3,2564,55,15,210,38,497,228,207,109,914,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 | 6,2434,11,14,408,164,955,204,210,141,977,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
3 | 1,2962,88,16,190,23,6095,242,212,95,3811,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
4 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
5 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
6 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
7 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
8 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
9 | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # carbon-ml
2 |
3 | ---
4 | ## Note
5 |
6 | We have discontinued WSO2 Machine Learner Product and as a result this repository has been deprecated. We still support machine learning model integration with WSO2 Data Analytics Server (https://github.com/wso2/product-das).
7 |
8 | ---
9 |
10 | Latest Released Version v1.1.0
11 |
12 | This repository contains the source code of modules belong to WSO2 Machine Learner product. Some of these modules are used by other products of the platform too.
13 |
14 | ## How to Contribute
15 | * Please report issues at [ML JIRA] (https://wso2.org/jira/browse/ML).
16 | * Send your bug fixes pull requests to [master branch] (https://github.com/wso2/carbon-ml/tree/master)
17 |
18 | ## Contact us
19 | WSO2 Carbon developers can be contacted via the mailing lists:
20 |
21 | * Carbon Developers List : dev@wso2.org
22 | * Carbon Architecture List : architecture@wso2.org
23 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/test/java/org/wso2/carbon/ml/core/spark/transformations/DoubleArrayToLabeledPointTest.java:
--------------------------------------------------------------------------------
1 | package org.wso2.carbon.ml.core.spark.transformations;
2 |
3 | import org.apache.spark.mllib.linalg.Vectors;
4 | import org.apache.spark.mllib.regression.LabeledPoint;
5 | import org.testng.Assert;
6 | import org.testng.annotations.Test;
7 |
8 | public class DoubleArrayToLabeledPointTest {
9 |
10 | @Test
11 | public void testTransformation() {
12 | DoubleArrayToLabeledPoint doubleArrayToLabeledPoint = new DoubleArrayToLabeledPoint.Builder().build();
13 | LabeledPoint labeledPoint = doubleArrayToLabeledPoint.call(new double[] { 1.1, 2.0, 2.1, 3.4, 0 });
14 | Assert.assertNotNull(labeledPoint);
15 | Assert.assertEquals(labeledPoint.label(), 0.0);
16 | Assert.assertEquals(labeledPoint.features(), Vectors.dense(new double[] { 1.1, 2.0, 2.1, 3.4 }));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.custom.adapter/README.md:
--------------------------------------------------------------------------------
1 | ML Custom Adapter Extension
2 | ===========================
3 |
4 | This OSGi bundle demonstrates how you could extend WSO2 ML input/output adapters.
5 |
6 | 1. This bundle is a fragment bundle of **org.wso2.carbon.ml.core** bundle.
7 | 2. You can build the bundle and copy it into ```{ML_HOME}/repository/components/dropins``` folder.
8 | 3. Once you copy the bundle, you could configure the new adapter using ```{ML_HOME}/repository/conf/machine-learner.xml``` file. Please refer to the [WSO2 ML documentation](https://docs.wso2.com/display/ML100/WSO2+ML-Specific+Configurations#WSO2ML-SpecificConfigurations-Input/outputhandlingconfigurations) for more information. In order to try this sample, you have to change the **file.in** property as below in **machine-learner.xml** file;
9 |
10 | ```
11 |
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.mediator.predict.ui/src/main/resources/org/wso2/carbon/ml/mediator/predict/ui/i18n/Resources.properties:
--------------------------------------------------------------------------------
1 | predict.mediator=Predict Mediator
2 | mediator.predict.header=Predict Mediator
3 | mediator.predict.model.name=Model Storage Location
4 | mediator.predict.load.model=Load Model
5 | mediator.predict.error.msg=An error occurred while processing the request
6 | mediator.predict.model.not.found.msg=Model not found
7 | mediator.predict.invalid.model.msg=Please enter a valid model storage location
8 | mediator.predict.model.loaded.success=Model loaded successfully
9 | mediator.predict.features=Features
10 | mediator.predict.feature.name=Feature Name
11 | mediator.predict.expression=Expression
12 | mediator.predict.namespaces=Namespaces
13 | mediator.predict.prediction.output=Prediction Output
14 | mediator.predict.prediction.property=Property
15 | mediator.predict.prediction.percentile=Percentile Value
16 | mediator.predict.prediction.value=Value
17 |
18 |
19 |
--------------------------------------------------------------------------------
/apps/ml/includes/tenantAware.jag:
--------------------------------------------------------------------------------
1 | <%
2 | // Redirects to the login page if the user has not signed-in
3 | include("./header.jag");
4 | user = jagg.getUser();
5 |
6 | (function () {
7 | if (!user) {
8 | // create redirect link with query parameters if exist
9 | var requestedPage = request.getRequestURI().replace("/ml/site", "..");
10 | var parameters = request.getAllParameters("UTF-8");
11 | var keys = Object.keys(parameters);
12 | // if query parameters exist add them to URL
13 | if(keys.length > 0) {
14 | var lastKey = keys[keys.length-1];
15 | var parametersString = "?";
16 | for (var key in parameters) {
17 | parametersString += key + "=" + parameters[key];
18 | if (key != lastKey) {
19 | parametersString += "&";
20 | }
21 | }
22 | requestedPage += parametersString;
23 | }
24 | // put redirect link as a session value
25 | session.put('requestedPage', requestedPage);
26 |
27 | response.sendRedirect(getRedirectPathForNonAuthenticatedUser());
28 | return;
29 | }
30 | }());
31 | %>
32 |
--------------------------------------------------------------------------------
/apps/ml/session/sessionCheck.js:
--------------------------------------------------------------------------------
1 | /* Session check function for UI button clicks */
2 |
3 | var jagg = jagg || {};
4 |
5 | (function() {
6 | jagg.syncPost = function(url, data, callback, type) {
7 | return jQuery.ajax({
8 | type: "POST",
9 | url: url,
10 | data: data,
11 | async: false,
12 | success: callback,
13 | dataType: "json"
14 | });
15 | };
16 |
17 | jagg.isSessionOut = function() {
18 | var loggedOut = false;
19 | jagg.syncPost("../../session/sessionCheck.jag", {
20 | action: "sessionCheck"
21 | },
22 | function(result) {
23 | if (result != null) {
24 | if (result.message == "sessionOut") {
25 | loggedOut = true;
26 | }
27 | }
28 | }, "json");
29 | return loggedOut;
30 | };
31 |
32 | jagg.sessionAwareJs = function() {
33 | if (jagg.isSessionOut()) {
34 | window.location.href = "../home/login.jag";
35 | }
36 | };
37 | }());
--------------------------------------------------------------------------------
/samples/model-usage/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2015 WSO2, Inc. (http://wso2.com)
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | log4j.rootLogger=INFO, console, Default
18 | log4j.appender.Default=org.apache.log4j.RollingFileAppender
19 | log4j.appender.Default.File=""
20 | log4j.appender.Default.Append=true
21 | log4j.appender.Default.layout=org.apache.log4j.PatternLayout
22 | log4j.appender.console=org.apache.log4j.ConsoleAppender
23 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
24 | log4j.appender.console.layout.ConversionPattern=%-5p [%c] - %m%n
25 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/AlgorithmNameException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class AlgorithmNameException extends IllegalStateException {
22 | private static final long serialVersionUID = 7178085223069282980L;
23 |
24 | public AlgorithmNameException(String message) {
25 | super(message);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/FeatureType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.commons.domain;
19 |
20 | public class FeatureType {
21 | public static final String NUMERICAL = "NUMERICAL";
22 | public static final String CATEGORICAL = "CATEGORICAL";
23 |
24 | /*
25 | * private Constructor to prevent any other class from instantiating.
26 | */
27 | private FeatureType() {
28 | }
29 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/H2OConfigurationParserException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class H2OConfigurationParserException extends Exception {
22 | private static final long serialVersionUID = -1750191859183521821L;
23 |
24 | public H2OConfigurationParserException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/SparkConfigurationParserException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class SparkConfigurationParserException extends Exception {
22 | private static final long serialVersionUID = -1750191859183521821L;
23 |
24 | public SparkConfigurationParserException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/interfaces/PMMLModelContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.wso2.carbon.ml.core.interfaces;
17 |
18 | import org.apache.spark.mllib.pmml.PMMLExportable;
19 | import org.wso2.carbon.ml.core.exceptions.MLPmmlExportException;
20 |
21 |
22 | /**
23 | All MLModels(wrapper models) which support pmml export should implement this interface
24 | */
25 | public interface PMMLModelContainer {
26 |
27 | PMMLExportable getPMMLExportable() throws MLPmmlExportException;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/exceptions/SparkConfigException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.exceptions;
19 |
20 | /**
21 | * This exception will be thrown when spark configuration related issues are occurred.
22 | */
23 | public class SparkConfigException extends Exception {
24 |
25 | public SparkConfigException(String message, Throwable cause) {
26 | super(message, cause);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/features/ml/org.wso2.carbon.ml.database.feature/src/main/resources/p2.inf:
--------------------------------------------------------------------------------
1 | instructions.configure = \
2 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.database_${feature.version}/conf/datasources/ml-datasources.xml,target:${installFolder}/../../conf/datasources/ml-datasources.xml,overwrite:true);\
3 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../dbscripts); \
4 | org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../dbscripts/ml); \
5 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.database_${feature.version}/dbscripts/h2.sql,target:${installFolder}/../../../dbscripts/ml/h2.sql,overwrite:true);\
6 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.database_${feature.version}/dbscripts/mysql.sql,target:${installFolder}/../../../dbscripts/ml/mysql.sql,overwrite:true);\
7 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.ml.database_${feature.version}/repository/database/WSO2ML_DB.h2.db/,target:${installFolder}/../../database/WSO2ML_DB.h2.db,overwrite:true);\
8 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/ModelSummary.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.commons.domain;
20 |
21 | import java.io.Serializable;
22 |
23 | public interface ModelSummary extends Serializable {
24 |
25 | /**
26 | * @return Model summary type
27 | */
28 | public String getModelSummaryType();
29 |
30 | /**
31 | * @return Array of features associated with the Model
32 | */
33 | public String[] getFeatures();
34 | }
35 |
--------------------------------------------------------------------------------
/apps/ml/jagg/jagg.jag:
--------------------------------------------------------------------------------
1 | <%
2 | //TODO : remove this when log configs are implemented
3 | Log.prototype.isDebugEnabled = function () {
4 | return false;
5 | };
6 |
7 | //TODO : remove this when Context HO is implemented.
8 | var context = context || {
9 | put:function (key, value) {
10 | session.put(key, value);
11 | },
12 | get:function (key) {
13 | return session.get(key);
14 | },
15 | remove:function (key) {
16 | session.remove(key);
17 | }
18 | };
19 |
20 | var site = require("/site/conf/site.json");
21 |
22 | var jagg = jagg || (function () {
23 | var data;
24 | var setData = function (d) {
25 | data = d;
26 | };
27 |
28 | var getData = function () {
29 | return data;
30 | };
31 |
32 | var getUser = function () {
33 | return session.get("logged.user");
34 | };
35 |
36 | var setUser = function (user) {
37 | session.put("logged.user", user);
38 | };
39 |
40 | var getAbsoluteUrl = function (path) {
41 | return site.context + path;
42 | };
43 |
44 | return {
45 | setUser:setUser,
46 | getUser:getUser,
47 | data:getData,
48 | getAbsoluteUrl:getAbsoluteUrl
49 | };
50 |
51 | }());
52 | %>
53 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLInputAdapterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLInputAdapterException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLInputAdapterException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLInputAdapterException(String message) {
29 | super(message);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/DatasetSummaryException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.exceptions;
19 |
20 | public class DatasetSummaryException extends Exception {
21 |
22 | private static final long serialVersionUID = 2242488353030239918L;
23 |
24 | public DatasetSummaryException(String message) {
25 | super(message);
26 | }
27 |
28 | public DatasetSummaryException(String message, Throwable cause) {
29 | super(message, cause);
30 | }
31 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/ImputeOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.commons.domain;
19 |
20 | public class ImputeOption {
21 | public static final String DISCARD = "DISCARD";
22 | public static final String REPLACE_WTH_MEAN = "REPLACE_WTH_MEAN";
23 | public static final String REGRESSION_IMPUTATION = "REGRESSION_IMPUTATION";
24 |
25 | /*
26 | * private Constructor to prevent any other class from instantiating.
27 | */
28 | private ImputeOption() {
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/model/MLErrorBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.rest.api.model;
19 |
20 | /**
21 | * Represent an Error in ML.
22 | */
23 | public class MLErrorBean {
24 |
25 | private String error;
26 |
27 | public MLErrorBean(String msg) {
28 | error = msg;
29 | }
30 |
31 | public String getException() {
32 | return error;
33 | }
34 |
35 | public void setException(String exception) {
36 | this.error = exception;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLInputValidationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLInputValidationException extends Exception {
22 |
23 | private static final long serialVersionUID = -3051317701667536564L;
24 |
25 | public MLInputValidationException(String message, Throwable cause) {
26 | super(message, cause);
27 | }
28 |
29 | public MLInputValidationException(String message) {
30 | super(message);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.database/src/main/java/org/wso2/carbon/ml/database/exceptions/DatabaseHandlerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.database.exceptions;
20 |
21 | public class DatabaseHandlerException extends Exception {
22 |
23 | private static final long serialVersionUID = 8861294012972059965L;
24 |
25 | public DatabaseHandlerException(String message) {
26 | super(message);
27 | }
28 |
29 | public DatabaseHandlerException(String message, Throwable cause) {
30 | super(message, cause);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/features/ml/org.wso2.carbon.ml.database.feature/src/main/resources/conf/datasources/ml-datasources.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WSO2ML_DB
5 | The datasource used for Machine Learner database
6 |
7 | jdbc/WSO2ML_DB
8 |
9 |
10 |
11 | jdbc:h2:repository/database/WSO2ML_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000;WRITE_DELAY=0
12 | wso2carbon
13 | wso2carbon
14 | org.h2.Driver
15 | 50
16 | 60000
17 | true
18 | SELECT 1
19 | 30000
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/assembly/docs.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | docs
21 |
22 | zip
23 |
24 | false
25 |
26 |
27 | target/site/apidocs
28 | ${pom.artifactId}-${pom.version}-docs
29 | 644
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/assembly/docs.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | docs
21 |
22 | zip
23 |
24 | false
25 |
26 |
27 | target/site/apidocs
28 | ${pom.artifactId}-${pom.version}-docs
29 | 644
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/DatasetPreProcessingException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.exceptions;
19 |
20 | public class DatasetPreProcessingException extends Exception {
21 |
22 | private static final long serialVersionUID = 2242488353030239918L;
23 |
24 | public DatasetPreProcessingException(String message) {
25 | super(message);
26 | }
27 |
28 | public DatasetPreProcessingException(String message, Throwable cause) {
29 | super(message, cause);
30 | }
31 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.database/src/main/assembly/docs.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | docs
21 |
22 | zip
23 |
24 | false
25 |
26 |
27 | target/site/apidocs
28 | ${pom.artifactId}-${pom.version}-docs
29 | 644
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/exceptions/DecompositionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.exceptions;
19 |
20 | /**
21 | * This class represents exceptions related to decomposition component.
22 | */
23 | public class DecompositionException extends Exception {
24 |
25 | public DecompositionException(String message, Throwable cause) {
26 | super(message, cause);
27 | }
28 |
29 | public DecompositionException(String message) {
30 | super(message);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/assembly/docs.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | docs
21 |
22 | zip
23 |
24 | false
25 |
26 |
27 | target/site/apidocs
28 | ${pom.artifactId}-${pom.version}-docs
29 | 644
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLPmmlExportException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.ml.core.exceptions;
18 |
19 | public class MLPmmlExportException extends Exception {
20 |
21 | private static final long serialVersionUID = 5000099339103508708L;
22 |
23 | public MLPmmlExportException(String message, Throwable cause) {
24 | super(message, cause);
25 | }
26 |
27 | public MLPmmlExportException(String message) {
28 | super(message);
29 | }
30 |
31 | public MLPmmlExportException(Throwable cause) {
32 | super(cause);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/model/MLResponseBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.rest.api.model;
19 |
20 | /**
21 | * Represents a response in ML
22 | */
23 | public class MLResponseBean {
24 |
25 | private Object response;
26 |
27 | public MLResponseBean(Object response) {
28 | this.response = response;
29 | }
30 |
31 | public Object getResponse() {
32 | return response;
33 | }
34 |
35 | public void setResponse(Object response) {
36 | this.response = response;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.database/src/main/java/org/wso2/carbon/ml/database/exceptions/MLConfigurationParserException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.database.exceptions;
20 |
21 | public class MLConfigurationParserException extends Exception {
22 |
23 | private static final long serialVersionUID = 8192740425418424448L;
24 |
25 | public MLConfigurationParserException(String message) {
26 | super(message);
27 | }
28 |
29 | public MLConfigurationParserException(String message, Throwable cause) {
30 | super(message, cause);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/MLRestAPI.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.wso2.carbon.ml.rest.api;
17 |
18 | import org.apache.commons.logging.Log;
19 | import org.apache.commons.logging.LogFactory;
20 | import org.wso2.carbon.context.CarbonContext;
21 |
22 | public abstract class MLRestAPI {
23 | protected static final Log auditLog = LogFactory.getLog("AUDIT_LOG");
24 | private String tenantID = null;
25 |
26 | protected String getTenantID() {
27 | int x = CarbonContext.getThreadLocalCarbonContext().getTenantId();
28 | tenantID = String.valueOf(x);
29 |
30 | return tenantID;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLModelBuilderException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLModelBuilderException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLModelBuilderException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLModelBuilderException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLModelBuilderException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLModelHandlerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLModelHandlerException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLModelHandlerException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLModelHandlerException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLModelHandlerException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLOutputAdapterException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLOutputAdapterException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLOutputAdapterException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLOutputAdapterException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLOutputAdapterException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLDataProcessingException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLDataProcessingException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLDataProcessingException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLDataProcessingException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLDataProcessingException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLModelPublisherException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLModelPublisherException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLModelPublisherException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLModelPublisherException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLModelPublisherException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLProjectHandlerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLProjectHandlerException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLProjectHandlerException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLProjectHandlerException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLProjectHandlerException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLAnalysisHandlerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLAnalysisHandlerException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLAnalysisHandlerException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLAnalysisHandlerException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLAnalysisHandlerException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/test/java/org/wso2/carbon/ml/core/utils/MLUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.utils;
19 |
20 | import org.testng.Assert;
21 | import org.testng.annotations.Test;
22 | import org.testng.annotations.BeforeClass;
23 |
24 | public class MLUtilsTest {
25 | @BeforeClass
26 | public void beforeClass() {
27 | }
28 |
29 | @Test
30 | public void getDate() {
31 | String date = MLUtils.getDate();
32 | Assert.assertEquals(date.contains("-"), true);
33 | Assert.assertEquals(date.contains("_"), true);
34 | Assert.assertEquals(!date.contains(":"), true);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLMalformedDatasetException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLMalformedDatasetException extends Exception {
22 | private static final long serialVersionUID = -8346783977372279074L;
23 |
24 | public MLMalformedDatasetException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLMalformedDatasetException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLMalformedDatasetException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/SubDatasetMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.spark.transformations;
19 |
20 | import org.apache.spark.api.java.function.Function;
21 | import org.apache.spark.mllib.regression.LabeledPoint;
22 | import scala.Tuple2;
23 |
24 | public class SubDatasetMapper implements Function, LabeledPoint> {
25 |
26 | private static final long serialVersionUID = -8231758770837121018L;
27 |
28 | @Override
29 | public LabeledPoint call(Tuple2 labelWithIndex) {
30 | return labelWithIndex._1;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/exceptions/MLEmailNotificationSenderException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.exceptions;
20 |
21 | public class MLEmailNotificationSenderException extends Exception {
22 | private static final long serialVersionUID = 240005254948442058L;
23 |
24 | public MLEmailNotificationSenderException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 |
28 | public MLEmailNotificationSenderException(String message) {
29 | super(message);
30 | }
31 |
32 | public MLEmailNotificationSenderException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/apps/ml/js/operationsmenu.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | /*
20 | * Setting-up global variables.
21 | */
22 | var modalPopup = '.wr-modalpopup',
23 | modalPopupContent = modalPopup + ' .modalpopup-content'
24 |
25 | /*
26 | * On operation click function.
27 | * @param selection: Selected operation
28 | */
29 | function operationSelect(selection) {
30 | $(modalPopupContent).html($('.popup-content[data-operation=' + selection + ']').html());
31 | showPopup();
32 | }
33 |
34 | /*
35 | * show popup function.
36 | */
37 | function showPopup() {
38 | $(modalPopup).show();
39 | }
40 |
41 | /*
42 | * hide popup function.
43 | */
44 | function hidePopup() {
45 | $(modalPopupContent).html('');
46 | $(modalPopup).hide();
47 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/RestAPIConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.ml.rest.api;
18 |
19 |
20 | public class RestAPIConstants {
21 |
22 | public static final String RESOURCE_NOT_FOUND = "Resource not found : ";
23 | public static final String TYPE_JSON = "application/json";
24 |
25 | //Request Headers
26 | public static final String HTTP_REQUEST_HEADER = "HTTP.REQUEST";
27 | public static final String AUTHENTICATION_HEADER = "WWW-Authenticate";
28 | public static final String CERTIFICATE_HEADER = "javax.servlet.request.X509Certificate";
29 |
30 | // Authentication types
31 | public static final String BASIC_AUTHENTICATION = "Basic";
32 | }
33 |
--------------------------------------------------------------------------------
/apps/ml/css/d3.parsets.css:
--------------------------------------------------------------------------------
1 | .dimension { cursor: ns-resize; }
2 | .category { cursor: ew-resize; }
3 | .dimension tspan.name { font-size: 12px; fill: #333; font-weight: normal; }
4 | .dimension tspan.sort { fill: #000; cursor: pointer; opacity: 0; }
5 | .dimension tspan.sort:hover { fill: #333; }
6 | .dimension:hover tspan.name { fill: #000; }
7 | .dimension:hover tspan.sort { opacity: 1; }
8 | .dimension line { stroke: #000; }
9 | .dimension rect { stroke: none; fill-opacity: 0; }
10 | .dimension > rect, .category-background { fill: #fff; }
11 | .dimension > rect { display: none; }
12 | .category:hover rect { fill-opacity: .3; }
13 | .dimension:hover > rect { fill-opacity: .3; }
14 | .ribbon path { stroke-opacity: 0; fill-opacity: .5; }
15 | .ribbon path.active { fill-opacity: .9; }
16 | .ribbon-mouse path { fill-opacity: 0; }
17 |
18 | .category-0 { fill: #1f77b4; stroke: #1f77b4; }
19 | .category-1 { fill: #ff7f0e; stroke: #ff7f0e; }
20 | .category-2 { fill: #2ca02c; stroke: #2ca02c; }
21 | .category-3 { fill: #d62728; stroke: #d62728; }
22 | .category-4 { fill: #9467bd; stroke: #9467bd; }
23 | .category-5 { fill: #8c564b; stroke: #8c564b; }
24 | .category-6 { fill: #e377c2; stroke: #e377c2; }
25 | .category-7 { fill: #7f7f7f; stroke: #7f7f7f; }
26 | .category-8 { fill: #bcbd22; stroke: #bcbd22; }
27 | .category-9 { fill: #17becf; stroke: #17becf; }
28 |
29 | .parsets-tooltip {
30 | background-color: rgba(242, 242, 242, .6);
31 | font-size: 12px; fill: #333;
32 | position: absolute;
33 | padding: 5px;
34 | }
35 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/interfaces/MLInputAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.interfaces;
19 |
20 | import java.io.InputStream;
21 |
22 | import org.wso2.carbon.ml.core.exceptions.MLInputAdapterException;
23 |
24 | /**
25 | * This interface should be implemented, if you need to read content from a given path.
26 | */
27 | public interface MLInputAdapter {
28 |
29 | /**
30 | * Read from a given path of a selected data source.
31 | * @param path a path that makes sense to the selected implementation.
32 | * @return the read content as an {@link InputStream}
33 | * @throws MLInputAdapterException on a read failure.
34 | */
35 | InputStream read(String path) throws MLInputAdapterException;
36 | }
37 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/MLStorage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.commons.domain;
19 |
20 | /**
21 | * Represent Model storage information.
22 | */
23 | public class MLStorage {
24 |
25 | private String type = "file";
26 | private String location = "/tmp";
27 | public String getType() {
28 | return type;
29 | }
30 | public void setType(String type) {
31 | this.type = type;
32 | }
33 | public String getLocation() {
34 | return location;
35 | }
36 | public void setLocation(String location) {
37 | this.location = location;
38 | }
39 | @Override
40 | public String toString() {
41 | return "MLStorage [type=" + type + ", location=" + location + "]";
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/model/MLVersionBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.rest.api.model;
19 |
20 | /**
21 | * Represents a Data-set Version in ML
22 | */
23 | public class MLVersionBean {
24 |
25 | private long id;
26 | private String version;
27 | private String status;
28 |
29 | public long getId() {
30 | return id;
31 | }
32 | public void setId(long id) {
33 | this.id = id;
34 | }
35 | public String getVersion() {
36 | return version;
37 | }
38 | public void setVersion(String version) {
39 | this.version = version;
40 | }
41 | public String getStatus() {
42 | return status;
43 | }
44 | public void setStatus(String status) {
45 | this.status = status;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.ui/META-INF/component.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
34 |
35 |
--------------------------------------------------------------------------------
/apps/ml/css/data.css:
--------------------------------------------------------------------------------
1 | .graphtitle{
2 | text-align:center;
3 | margin-top: 4em;
4 | }
5 |
6 | .graphSummary{
7 | text-align:left;
8 | margin-left: 10%;
9 | margin-top: -15px;
10 | margin-bottom: 30px;
11 | }
12 |
13 | .graph{
14 | margin-bottom: 2em;
15 | }
16 |
17 | #scatterPlotFeatures{
18 | margin-left: 30px;
19 | }
20 |
21 | #scatterPlot{
22 | float: center;
23 | width: 50em;
24 | margin: auto;
25 | }
26 |
27 | #histograms{
28 | float: center;
29 | width: 45em;
30 | margin-top: -2em;
31 | margin-left: auto;
32 | margin-right: auto;
33 | }
34 |
35 | .half-width-column{
36 | float: left;
37 | width: 50%;
38 | }
39 |
40 | #histogram1 svg, #histogram2 svg{
41 | height: 18em;
42 | }
43 |
44 | /* Parallel Sets */
45 | #categoricalFeatureSelect{
46 | width: 300px;
47 | height: 400px;
48 | overflow: auto;
49 | }
50 |
51 | /* Trellis Chart */
52 | #trellisChart svg {
53 | font: 10px sans-serif;
54 | }
55 |
56 | #trellisChart .axis,.frame {
57 | shape-rendering: crispEdges;
58 | }
59 |
60 | #trellisChart .axis line {
61 | stroke: #ddd;
62 | }
63 |
64 | #trellisChart .axis path {
65 | display: none;
66 | }
67 |
68 | #trellisChart .frame {
69 | fill: none;
70 | stroke: #aaa;
71 | }
72 |
73 | #trellisChart circle {
74 | fill-opacity: 0.5; /* 0.7 */
75 | }
76 |
77 | #trellisChart circle.hidden {
78 | fill: #ccc !important;
79 | }
80 |
81 | #trellisChart .extent {
82 | fill: #000;
83 | fill-opacity: .125;
84 | stroke: #fff;
85 | }
86 |
87 | #numericalFeatureSelect{
88 | width: 300px;
89 | height: 400px;
90 | overflow: auto;
91 | }
92 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/interfaces/MLOutputAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.interfaces;
19 |
20 | import java.io.InputStream;
21 |
22 | import org.wso2.carbon.ml.core.exceptions.MLOutputAdapterException;
23 |
24 | /**
25 | * This interface should be implemented, if you need to write an input stream to a given path of a specific data source.
26 | */
27 | public interface MLOutputAdapter {
28 |
29 | /**
30 | * Write a given input stream to a given target path.
31 | *
32 | * @param outPath targeted path. eg: /test.txt
33 | * @param in {@link InputStream} to be written. This should be closed by this method.
34 | * @throws MLOutputAdapterException on a write failure.
35 | */
36 | void write(String outPath, InputStream in) throws MLOutputAdapterException;
37 | }
38 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/spark/transformations/DataPointToFeatureMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.spark.transformations;
19 |
20 | import org.apache.spark.api.java.function.Function;
21 | import org.apache.spark.mllib.linalg.Vector;
22 | import org.apache.spark.mllib.regression.LabeledPoint;
23 |
24 | /**
25 | * This maps each data point to features
26 | */
27 | public class DataPointToFeatureMapper implements Function {
28 |
29 | /**
30 | * Returns the feature of each LabelPoint
31 | *
32 | * @param labeledPoint
33 | * @return
34 | * @throws Exception
35 | */
36 | @Override
37 | public Vector call(LabeledPoint labeledPoint) throws Exception {
38 | return labeledPoint.features();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/exceptions/UnAuthorizedException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.ml.rest.api.exceptions;
18 |
19 | import javax.ws.rs.WebApplicationException;
20 | import javax.ws.rs.core.MediaType;
21 | import javax.ws.rs.core.Response;
22 |
23 | public class UnAuthorizedException extends WebApplicationException {
24 |
25 | private static final long serialVersionUID = 7926392228513189682L;
26 |
27 | public UnAuthorizedException(String message) {
28 | super(Response.status(Response.Status.BAD_REQUEST).entity(message).type(MediaType.APPLICATION_XML_TYPE)
29 | .build());
30 | }
31 |
32 | public UnAuthorizedException(String message, Throwable cause) {
33 | super(cause, Response.status(Response.Status.BAD_REQUEST).entity(message).type(MediaType.APPLICATION_XML_TYPE)
34 | .build());
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/ScatterPlotPoints.java:
--------------------------------------------------------------------------------
1 | package org.wso2.carbon.ml.commons.domain;
2 |
3 | public class ScatterPlotPoints {
4 | private int tenantId;
5 | private String user;
6 | private long versionsetId;
7 | private String xAxisFeature;
8 | private String yAxisFeature;
9 | private String groupByFeature;
10 |
11 | public int getTenantId() {
12 | return tenantId;
13 | }
14 |
15 | public void setTenantId(int tenantId) {
16 | this.tenantId = tenantId;
17 | }
18 |
19 | public String getUser() {
20 | return user;
21 | }
22 |
23 | public void setUser(String user) {
24 | this.user = user;
25 | }
26 |
27 | public long getVersionsetId() {
28 | return versionsetId;
29 | }
30 |
31 | public void setVersionsetId(long valueSetId) {
32 | this.versionsetId = valueSetId;
33 | }
34 |
35 | public String getxAxisFeature() {
36 | return xAxisFeature;
37 | }
38 |
39 | public void setxAxisFeature(String xAxisFeature) {
40 | this.xAxisFeature = xAxisFeature;
41 | }
42 |
43 | public String getyAxisFeature() {
44 | return yAxisFeature;
45 | }
46 |
47 | public void setyAxisFeature(String yAxisFeature) {
48 | this.yAxisFeature = yAxisFeature;
49 | }
50 |
51 | public String getGroupByFeature() {
52 | return groupByFeature;
53 | }
54 |
55 | public void setGroupByFeature(String groupByFeature) {
56 | this.groupByFeature = groupByFeature;
57 | }
58 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/factories/DatasetType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.factories;
19 |
20 | /**
21 | * Holds all dataset types.
22 | */
23 | public enum DatasetType {
24 | FILE("file"), DAS("das"), HDFS("hdfs");
25 |
26 | private String value = null;
27 |
28 | private DatasetType(String value) {
29 | this.value = value;
30 | }
31 |
32 | public String getValue() {
33 | return this.value;
34 | }
35 |
36 | /**
37 | * get {@link DatasetType} for a given value.
38 | */
39 | public static DatasetType getDatasetType(String value) {
40 | for (DatasetType type : DatasetType.values()) {
41 | if (type.getValue().equalsIgnoreCase(value)) {
42 | return type;
43 | }
44 | }
45 | return null;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.ui/src/org/wso2/carbon/ml/ui/MLUIActivator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.ui;
20 |
21 | import org.osgi.framework.BundleActivator;
22 | import org.osgi.framework.BundleContext;
23 | import org.wso2.carbon.ml.commons.constants.MLConstants;
24 |
25 | public class MLUIActivator implements BundleActivator {
26 |
27 | private static BundleContext context;
28 |
29 | static BundleContext getContext() {
30 | return context;
31 | }
32 |
33 | public void start(BundleContext bundleContext) throws Exception {
34 | if (!Boolean.parseBoolean(System.getProperty(MLConstants.DISABLE_ML))) {
35 | MLUIActivator.context = bundleContext;
36 | } else {
37 | MLUIActivator.context = null;
38 | }
39 | }
40 |
41 | public void stop(BundleContext bundleContext) throws Exception {
42 | MLUIActivator.context = null;
43 | }
44 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/spark/transformations/DataPointToResponseMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.spark.transformations;
19 |
20 | import org.apache.spark.api.java.function.Function;
21 | import org.apache.spark.mllib.regression.LabeledPoint;
22 | import org.wso2.carbon.ml.decomposition.exceptions.DecompositionException;
23 |
24 | /**
25 | * This maps data point to response variable
26 | */
27 | public class DataPointToResponseMapper implements Function {
28 |
29 | /**
30 | * Returns the label of each LabelPoint
31 | *
32 | * @param labeledPoint
33 | * @return
34 | * @throws DecompositionException
35 | */
36 | @Override
37 | public Double call(LabeledPoint labeledPoint) throws DecompositionException {
38 | return labeledPoint.label();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/apps/ml/includes/header.jag:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%
4 | // This is a generic header file to be included in all the pages.
5 |
6 | include("/jagg/jagg.jag");
7 | var site = require("/site/conf/site.json");
8 |
9 | var getRedirectPathForNonAuthenticatedUser = function () {
10 | var requestedPage = request.getRequestURI();
11 | var tenantParam = "";
12 | if (request.getQueryString() != null) {
13 | requestedPage = requestedPage + '?' + encodeURIComponent(request.getQueryString());
14 | var tenantDomain = getTenantDomain();
15 | if(tenantDomain != null){
16 | tenantParam = "&tenant=" + tenantDomain;
17 | }
18 | }
19 | var redirectPath = jagg.getAbsoluteUrl("/?requestedPage=" + requestedPage + tenantParam);
20 | return redirectPath;
21 | };
22 |
23 | var getTenantDomain=function() {
24 | return request.getParameter("tenant");
25 | };
26 |
27 | // Filter out tenant parameter
28 | var request_tenant = request.getParameter("tenant");
29 | var illegalChars = /([~!@#;%^*+={}\|\\<>\"\',])/;
30 | var illegalCharsInput = /(\<[a-zA-Z0-9\s\/]*>)/;
31 | if (illegalChars.test(request_tenant) || illegalCharsInput.test(request_tenant)) {
32 | // redirect to 404
33 | exit();
34 | }
35 |
36 | if (site.request_url == "READ_FROM_REQUEST") {
37 | var request_url = request.getRequestURL().split(request.getRequestURI())[0] + request.getContextPath();
38 | } else {
39 | var request_url = site.request_url;
40 | }
41 | %>
42 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/spark/dto/PCAResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.spark.dto;
19 |
20 | /**
21 | * This class is used to transfer information between visualizePCA method and other applications.
22 | */
23 | public class PCAResult {
24 | private double firstComponent;
25 | private double secondComponent;
26 | private double label;
27 |
28 | public PCAResult(double firstComponent, double secondComponent, double label) {
29 | this.firstComponent = firstComponent;
30 | this.secondComponent = secondComponent;
31 | this.label = label;
32 | }
33 |
34 | public double getFirstComponent() {
35 | return firstComponent;
36 | }
37 |
38 | public double getSecondComponent() {
39 | return secondComponent;
40 | }
41 |
42 | public double getLabel() {
43 | return label;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/config/MLProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.commons.domain.config;
20 |
21 | import java.io.Serializable;
22 |
23 | import javax.xml.bind.annotation.XmlAttribute;
24 |
25 | /**
26 | * DTO class for JAXB binding of MLProperty
27 | */
28 | public class MLProperty implements Serializable {
29 | private static final long serialVersionUID = -2314030361825726083L;
30 | private String name;
31 | private String value;
32 |
33 | @XmlAttribute(name = "name")
34 | public String getName() {
35 | return name;
36 | }
37 | public void setName(String name) {
38 | this.name = name;
39 | }
40 | @XmlAttribute(name = "value")
41 | public String getValue() {
42 | return value;
43 | }
44 | public void setValue(String value) {
45 | this.value = value;
46 | }
47 |
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.ui/web/mlui/index.jsp:
--------------------------------------------------------------------------------
1 |
18 |
19 | <%@ page import="java.lang.*"%>
20 |
21 |
22 |
23 |
24 |
25 |
39 |
40 |
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.mediator.predict.ui/src/main/java/org/wso2/carbon/ml/mediator/predict/ui/PredictMediatorService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.mediator.predict.ui;
19 |
20 | import org.wso2.carbon.mediator.service.AbstractMediatorService;
21 | import org.wso2.carbon.mediator.service.ui.Mediator;
22 |
23 | public class PredictMediatorService extends AbstractMediatorService {
24 |
25 | public String getTagLocalName() {
26 | return PredictMediatorConstants.PREDICT_TAG_LOCAL_NAME;
27 | }
28 |
29 | public String getDisplayName() {
30 | return PredictMediatorConstants.PREDICT_DISPLAY_NAME;
31 | }
32 |
33 | public String getLogicalName() {
34 | return PredictMediatorConstants.PREDICT_LOGICAL_NAME;
35 | }
36 |
37 | public String getGroupName() {
38 | return PredictMediatorConstants.GROUP_NAME;
39 | }
40 |
41 | public Mediator getMediator() {
42 | return new PredictMediator();
43 | }
44 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/test/java/org/wso2/carbon/ml/core/spark/transformations/MeanImputationTest.java:
--------------------------------------------------------------------------------
1 | package org.wso2.carbon.ml.core.spark.transformations;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.testng.Assert;
6 | import org.testng.annotations.Test;
7 | import org.wso2.carbon.ml.core.exceptions.MLModelBuilderException;
8 |
9 | public class MeanImputationTest {
10 | HashMap meanImputationValues;
11 |
12 | public MeanImputationTest() {
13 | meanImputationValues = new HashMap();
14 | meanImputationValues.put(0, 1.2);
15 | meanImputationValues.put(1, 2.2);
16 | meanImputationValues.put(2, 3.2);
17 | meanImputationValues.put(3, 4.2);
18 | }
19 |
20 | @Test
21 | public void testMeanImputation() throws MLModelBuilderException {
22 | MeanImputation meanImputation = new MeanImputation.Builder().imputations(meanImputationValues).build();
23 | String[] meanImputedRow = meanImputation.call(new String[] { "1.2", "2.5", "3.5", "4.3" });
24 | Assert.assertEquals(meanImputedRow, new String[] { "1.2", "2.5", "3.5", "4.3" });
25 | meanImputedRow = meanImputation.call(new String[] { "1.2", "?", "3.5", "4.3" });
26 | Assert.assertEquals(meanImputedRow, new String[] { "1.2", "2.2", "3.5", "4.3" });
27 | meanImputedRow = meanImputation.call(new String[] { "1.2", "2.5", "NA", "4.3" });
28 | Assert.assertEquals(meanImputedRow, new String[] { "1.2", "2.5", "3.2", "4.3" });
29 | meanImputedRow = meanImputation.call(new String[] { "1.2", "2.5", "3.5", "" });
30 | Assert.assertEquals(meanImputedRow, new String[] { "1.2", "2.5", "3.5", "4.2" });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/apps/ml/site/home/ajax/authenticate.jag:
--------------------------------------------------------------------------------
1 | <%
2 | var log = new Log();
3 | var username = request.getParameter("userName");
4 | var password = request.getParameter("password");
5 | var authEncoded = request.getParameter("authEncoded");
6 | var site = require("/site/conf/site.json");
7 | var carbon = require('carbon');
8 | var message = "";
9 | var statusCode = 200;
10 | response.contentType = 'application/json';
11 |
12 | try{
13 | var server = new carbon.server.Server("https://" + site.hostname+":" + site.httpsport + "/admin");
14 | var success = server.authenticate(username,password);
15 |
16 | if (success === true) {
17 | var MultitenantUtils = Packages.org.wso2.carbon.utils.multitenancy.MultitenantUtils;
18 | var tenantDomain = MultitenantUtils.getTenantDomain(username);
19 | var tenantId = carbon.server.tenantId({'domain': tenantDomain});
20 | session.put("logged.user", username);
21 | session.put("tenantId", tenantId);
22 | session.put("authEncoded", authEncoded);
23 | message = 'login success';
24 | } else {
25 | message = 'Login failed, please check your user name and password.';
26 | statusCode = 401;
27 | }
28 |
29 | } catch(e) {
30 | var errorMessage = "An error occured while authenticating user: " + username+ " error message: "+e.message;
31 | log.error(errorMessage);
32 | message = "An error occured while authenticating user " + username + ".";
33 | statusCode = 500;
34 | } finally {
35 | response.status = statusCode;
36 | response.content = { status: message};
37 | }
38 | %>
39 |
--------------------------------------------------------------------------------
/components/extensions/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | carbon-ml
23 | org.wso2.carbon.ml
24 | 1.2.6-SNAPSHOT
25 | ../../pom.xml
26 |
27 | 4.0.0
28 | extensions
29 | pom
30 | WSO2 Machine Learner Extensions
31 |
32 | org.wso2.carbon.ml.mediator.predict
33 | org.wso2.carbon.ml.mediator.predict.ui
34 | org.wso2.carbon.ml.siddhi.extension
35 | org.wso2.carbon.ml.custom.adapter
36 |
37 |
38 |
--------------------------------------------------------------------------------
/samples/model-usage/README.MD:
--------------------------------------------------------------------------------
1 | WSO2 Machine Learner Sample - Using a downloaded ML Model generated using WSO2 ML in plain Java code
2 | ====================================================================================================
3 |
4 | Generated Model
5 | ===============
6 |
7 | Path to model : resources/downloaded-ml-model
8 | Dataset used : https://archive.ics.uci.edu/ml/datasets/Pima+Indians+Diabetes
9 | Algorithm : Logistic-Regression
10 | Response variable : Class
11 |
12 | To build the sample
13 | ===================
14 | mvn clean install
15 |
16 | To run the sample
17 | =================
18 | mvn exec:java
19 |
20 | Outcome
21 | =======
22 | Running the sample will print the details of the MLModel and the prediction as below.
23 |
24 | INFO [MLModelUsageSample] - Algorithm Type : Classification
25 | INFO [MLModelUsageSample] - Algorithm Name : LOGISTIC_REGRESSION
26 | INFO [MLModelUsageSample] - Response Variable : Class
27 | INFO [MLModelUsageSample] - Features : [Feature [name=Age, index=7, type=NUMERICAL, imputeOption=DISCARD, include=true],
28 | Feature [name=BMI, index=5, type=NUMERICAL, imputeOption=DISCARD, include=true],
29 | Feature [name=DBP, index=2, type=NUMERICAL, imputeOption=DISCARD, include=true],
30 | Feature [name=DPF, index=6, type=NUMERICAL, imputeOption=DISCARD, include=true],
31 | Feature [name=NumPregnancies, index=0, type=NUMERICAL, imputeOption=DISCARD, include=true],
32 | Feature [name=PG2, index=1, type=NUMERICAL, imputeOption=DISCARD, include=true],
33 | Feature [name=SI2, index=4, type=NUMERICAL, imputeOption=DISCARD, include=true],
34 | Feature [name=TSFT, index=3, type=NUMERICAL, imputeOption=DISCARD, include=true]]
35 |
36 | INFO [MLModelUsageSample] - Predictions : [0, 0]
37 |
38 |
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.mediator.predict.ui/src/main/resources/web/predict-mediator/js/mediator-util.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | // input validator function
20 | function mlMediatorValidate() {
21 | var modelName = document.getElementById('mediatorInputId').value;
22 | if(modelName == null || modelName==""){
23 | CARBON.showErrorDialog(classi18n["mediator.predict.validInputmsg"]);
24 | return false;
25 | }
26 | return true;
27 | }
28 |
29 | // delete a raw from a table
30 | function deleteRow(src) {
31 | var index = src.parentNode.parentNode.rowIndex;
32 | var inputVariablesTable = document.getElementById('inputVariablesTable');
33 | inputVariablesTable.deleteRow(index);
34 | var noOfRows = inputVariablesTable.rows.length;
35 | if (noOfRows == 1) { // deleting the last raw, hide the table header
36 | document.getElementById('inputVariablesTable').style.display = 'none';
37 | document.getElementById('titleLabel').style.display = 'none';
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/h2o/H2OSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.h2o;
20 |
21 | import java.util.List;
22 |
23 | import javax.xml.bind.annotation.XmlAccessType;
24 | import javax.xml.bind.annotation.XmlAccessorType;
25 | import javax.xml.bind.annotation.XmlElement;
26 | import javax.xml.bind.annotation.XmlRootElement;
27 |
28 | /**
29 | * DTO class for JAXB binding of H2OConfigurationParser
30 | */
31 | @XmlRootElement(name = "h2oSettings")
32 | @XmlAccessorType(XmlAccessType.FIELD)
33 | public class H2OSettings {
34 | @XmlElement(name = "property")
35 | private List properties;
36 |
37 | /**
38 | * @return Returns h2o properties
39 | */
40 | public List getProperties() {
41 | return properties;
42 | }
43 |
44 | /**
45 | * @param properties Sets h2o properties
46 | */
47 | public void setProperties(List properties) {
48 | this.properties = properties;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/impl/FileInputAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.impl;
19 |
20 | import java.io.File;
21 | import java.io.FileInputStream;
22 | import java.io.FileNotFoundException;
23 | import java.io.InputStream;
24 |
25 | import org.wso2.carbon.ml.core.exceptions.MLInputAdapterException;
26 | import org.wso2.carbon.ml.core.interfaces.MLInputAdapter;
27 |
28 | /**
29 | * Implementation of {@link MLInputAdapter} for regular file system.
30 | */
31 | public class FileInputAdapter implements MLInputAdapter {
32 |
33 | @Override
34 | public InputStream read(String path) throws MLInputAdapterException {
35 | try {
36 | FileInputStream inputStream = new FileInputStream(new File(path));
37 | return inputStream;
38 | } catch (FileNotFoundException | IllegalArgumentException e) {
39 | throw new MLInputAdapterException(String.format("Failed to read the data-set from uri %s: %s", path, e), e);
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/SparkSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark;
20 |
21 | import javax.xml.bind.annotation.XmlAccessType;
22 | import javax.xml.bind.annotation.XmlAccessorType;
23 | import javax.xml.bind.annotation.XmlElement;
24 | import javax.xml.bind.annotation.XmlRootElement;
25 | import java.util.List;
26 |
27 | /**
28 | * DTO class for JAXB binding of SparkConfigurationParser
29 | */
30 | @XmlRootElement(name = "sparkSettings")
31 | @XmlAccessorType(XmlAccessType.FIELD)
32 | public class SparkSettings {
33 | @XmlElement(name = "property")
34 | private List properties;
35 |
36 | /**
37 | * @return Returns spark properties
38 | */
39 | public List getProperties() {
40 | return properties;
41 | }
42 |
43 | /**
44 | * @param properties Sets spark properties
45 | */
46 | public void setProperties(List properties) {
47 | this.properties = properties;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/test/java/org/wso2/carbon/ml/core/spark/transformations/NormalizationTest.java:
--------------------------------------------------------------------------------
1 | package org.wso2.carbon.ml.core.spark.transformations;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.testng.Assert;
7 | import org.testng.annotations.Test;
8 | import org.wso2.carbon.ml.core.exceptions.MLModelBuilderException;
9 |
10 | public class NormalizationTest {
11 |
12 | private final List max;
13 | private final List min;
14 |
15 | public NormalizationTest() {
16 | this.max = new ArrayList();
17 | this.min = new ArrayList();
18 |
19 | max.add(10.0);
20 | max.add(5.0);
21 | max.add(50.0);
22 | max.add(1.0);
23 |
24 | min.add(2.0);
25 | min.add(0.0);
26 | min.add(10.0);
27 | min.add(1.0);
28 | }
29 |
30 | @Test
31 | public void testNormalization() throws MLModelBuilderException {
32 |
33 | Normalization normalization = new Normalization.Builder().minMax(max, min).build();
34 | double[] normalizedRow = normalization.call(new double[] { 1.0, 7.0, 30.0, 1.0 });
35 | Assert.assertEquals(normalizedRow, new double[] { 0.0, 1.0, 0.5, 0.5 });
36 | normalizedRow = normalization.call(new double[] { 5.0, 3.0, 20.0, 2.0 });
37 | Assert.assertEquals(normalizedRow, new double[] { 0.375, 0.6, 0.25, 1.0 });
38 | normalizedRow = normalization.call(new double[] { 9.0, -5.0, 8.0, 0.0 });
39 | Assert.assertEquals(normalizedRow, new double[] { 0.875, 0.0, 0.0, 0.0 });
40 | normalizedRow = normalization.call(new double[] { 10.0, 6.0, 45.0, 3.0 });
41 | Assert.assertEquals(normalizedRow, new double[] { 1.0, 1.0, 0.875, 1.0 });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/components/ml/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | carbon-ml
22 | org.wso2.carbon.ml
23 | 1.2.6-SNAPSHOT
24 | ../../pom.xml
25 |
26 | 4.0.0
27 | ml
28 | pom
29 | WSO2 Machine Learner Components
30 |
31 | org.wso2.carbon.ml.commons
32 | org.wso2.carbon.ml.database
33 |
34 | org.wso2.carbon.ml.core
35 | org.wso2.carbon.ml.rest.api
36 | org.wso2.carbon.ml.ui
37 |
38 |
39 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/model/MLAnalysisBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.rest.api.model;
19 |
20 | /**
21 | * Represent an Analysis in ML.
22 | */
23 | public class MLAnalysisBean {
24 |
25 | private long id;
26 | private long projectId;
27 | private String name;
28 | private String comments;
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 |
38 | public String getComments() {
39 | return comments;
40 | }
41 |
42 | public void setComments(String comments) {
43 | this.comments = comments;
44 | }
45 |
46 | public long getProjectId() {
47 | return projectId;
48 | }
49 |
50 | public void setProjectId(long projectId) {
51 | this.projectId = projectId;
52 | }
53 |
54 | public long getId() {
55 | return id;
56 | }
57 |
58 | public void setId(long id) {
59 | this.id = id;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/config/Storage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.commons.domain.config;
20 |
21 | import java.io.Serializable;
22 |
23 | import javax.xml.bind.annotation.XmlElement;
24 |
25 | /**
26 | * DTO class for JAXB binding of a Storage
27 | */
28 | public class Storage implements Serializable {
29 |
30 | private static final long serialVersionUID = 1320087479354297195L;
31 | private String storageType;
32 | private String storageDirectory;
33 |
34 | @XmlElement(name = "StorageType")
35 | public String getStorageType() {
36 | return storageType;
37 | }
38 | public void setStorageType(String storageType) {
39 | this.storageType = storageType;
40 | }
41 | @XmlElement(name = "StorageDirectory")
42 | public String getStorageDirectory() {
43 | return storageDirectory;
44 | }
45 | public void setStorageDirectory(String storageDirectory) {
46 | this.storageDirectory = storageDirectory;
47 | }
48 |
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.database/src/main/java/org/wso2/carbon/ml/database/internal/MLDataSource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.database.internal;
19 |
20 | import javax.naming.Context;
21 | import javax.naming.InitialContext;
22 | import javax.naming.NamingException;
23 | import javax.sql.DataSource;
24 | import java.sql.SQLException;
25 |
26 |
27 | public class MLDataSource {
28 | private DataSource dataSource;
29 |
30 | public MLDataSource(String mlDatasourceUrl) throws SQLException {
31 | try {
32 | Context initContext = new InitialContext();
33 | dataSource = (DataSource) initContext.lookup(mlDatasourceUrl);
34 |
35 | } catch (NamingException e) {
36 | throw new SQLException(
37 | "An error occurred while obtaining the data source: " + e.getMessage(), e);
38 | }
39 | }
40 |
41 | /**
42 | * Get the data source
43 | * @return {@link javax.sql.DataSource} object
44 | */
45 | public DataSource getDataSource(){
46 | return dataSource;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.database/src/main/java/org/wso2/carbon/ml/database/internal/ds/MLDatabaseServiceValueHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.database.internal.ds;
19 |
20 |
21 | import org.wso2.carbon.ml.database.DatabaseService;
22 | import org.wso2.carbon.utils.ConfigurationContextService;
23 |
24 | public class MLDatabaseServiceValueHolder {
25 | private static DatabaseService databaseService;
26 | private static ConfigurationContextService contextService;
27 |
28 | public static void registerDatabaseService(DatabaseService databaseService){
29 | MLDatabaseServiceValueHolder.databaseService = databaseService;
30 | }
31 |
32 | public static DatabaseService getDatabaseService(){
33 | return databaseService;
34 | }
35 |
36 | public static void setContextService(ConfigurationContextService contextService) {
37 | MLDatabaseServiceValueHolder.contextService = contextService;
38 | }
39 |
40 | public static ConfigurationContextService getContextService() {
41 | return contextService;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/internal/SparkSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.internal;
19 |
20 | import javax.xml.bind.annotation.XmlAccessType;
21 | import javax.xml.bind.annotation.XmlAccessorType;
22 | import javax.xml.bind.annotation.XmlElement;
23 | import javax.xml.bind.annotation.XmlRootElement;
24 | import java.util.List;
25 |
26 | /**
27 | * DTO class for JAXB binding of SparkConfigurationParser.
28 | */
29 | @XmlRootElement(name = "sparkSettings")
30 | @XmlAccessorType(XmlAccessType.FIELD)
31 | public class SparkSettings {
32 |
33 | @XmlElement(name = "property")
34 | private List properties;
35 |
36 | /**
37 | * @return Returns spark properties
38 | */
39 | public List getProperties() {
40 | return properties;
41 | }
42 |
43 | /**
44 | * @param properties Sets spark properties
45 | */
46 | public void setProperties(List properties) {
47 | this.properties = properties;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/features/extensions/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | org.wso2.carbon.ml
22 | carbon-ml
23 | 1.2.6-SNAPSHOT
24 | ../../pom.xml
25 |
26 |
27 | 4.0.0
28 | ml-extension-features
29 | pom
30 | WSO2 Carbon - Machine Learner Extension Features
31 | http://wso2.org
32 |
33 |
34 | org.wso2.carbon.ml.mediator.predict.server.feature
35 | org.wso2.carbon.ml.mediator.predict.ui.feature
36 | org.wso2.carbon.ml.mediator.predict.feature
37 | org.wso2.carbon.ml.siddhi.extension.feature
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/factories/AlgorithmType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.factories;
19 |
20 | /**
21 | * Holds all algorithm types.
22 | */
23 | public enum AlgorithmType {
24 | CLASSIFICATION("Classification"), NUMERICAL_PREDICTION("Numerical_Prediction"), CLUSTERING(
25 | "Clustering"), ANOMALY_DETECTION("Anomaly_Detection"), DEEPLEARNING("Deeplearning"), RECOMMENDATION(
26 | "Recommendation");
27 |
28 | private String value = null;
29 |
30 | private AlgorithmType(String value) {
31 | this.value = value;
32 | }
33 |
34 | public String getValue() {
35 | return this.value;
36 | }
37 |
38 | /**
39 | * get {@link AlgorithmType} for a given value.
40 | */
41 | public static AlgorithmType getAlgorithmType(String value) {
42 | for (AlgorithmType type : AlgorithmType.values()) {
43 | if (type.getValue().equalsIgnoreCase(value)) {
44 | return type;
45 | }
46 | }
47 | return null;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/h2o/H2OProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.h2o;
20 |
21 | import javax.xml.bind.annotation.XmlAttribute;
22 | import javax.xml.bind.annotation.XmlValue;
23 |
24 | /**
25 | * DTO class for JAXB binding of H2OConfigurationParser
26 | */
27 | public class H2OProperty {
28 | private String property;
29 | private String name;
30 |
31 | /**
32 | * @return Retuns h2o property name
33 | */
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | /**
39 | * @param name Sets h2o property name
40 | */
41 | @XmlAttribute
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | /**
47 | * @return Returns h2o property value
48 | */
49 | public String getProperty() {
50 | return property;
51 | }
52 |
53 | /**
54 | * @param property Sets h2o property value
55 | */
56 | @XmlValue
57 | public void setProperty(String property) {
58 | this.property = property;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/DoubleArrayToVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.transformations;
20 |
21 | import org.apache.spark.api.java.function.Function;
22 | import org.apache.spark.mllib.linalg.Vector;
23 | import org.apache.spark.mllib.linalg.Vectors;
24 |
25 | /**
26 | * This class transforms double array to labeled point
27 | */
28 | public class DoubleArrayToVector implements Function {
29 |
30 | private static final long serialVersionUID = 8329428281317101710L;
31 |
32 | private DoubleArrayToVector() {
33 | }
34 |
35 | /**
36 | * Function to transform double array into labeled point.
37 | *
38 | * @param features Double array of tokens
39 | * @return Vector
40 | */
41 | @Override
42 | public Vector call(double[] features) {
43 | return Vectors.dense(features);
44 | }
45 |
46 | public static class Builder {
47 | public DoubleArrayToVector build() {
48 | return new DoubleArrayToVector();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/internal/DecompositionConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.internal;
19 |
20 | /**
21 | * This class contains a set of common constants used by decomposition module.
22 | */
23 | public class DecompositionConstants {
24 |
25 | // Spark configuration related constants
26 | public static final String SPARK_CONFIG_XML = "repository/conf/etc/spark-config.xml";
27 |
28 | // Dataset related constants
29 | public static final String EMPTY = "";
30 | public static final String NA = "NA";
31 | public static final String CSV = "csv";
32 | public static final String TSV = "tsv";
33 |
34 | // Constants related to drawing random samples
35 | public static final int RANDOM_SAMPLE_SIZE = 10000;
36 | public static final long RANDOM_SEED = 1024L;
37 |
38 | // System property names
39 | public static final String HOME = "user.home";
40 | public static final String FILE_SEPARATOR = "file.separator";
41 |
42 | public static final String ML_PROJECTS = "MLProjects";
43 | }
44 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/SparkProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark;
20 |
21 | import javax.xml.bind.annotation.XmlAttribute;
22 | import javax.xml.bind.annotation.XmlValue;
23 |
24 | /**
25 | * DTO class for JAXB binding of SparkConfigurationParser
26 | */
27 | public class SparkProperty {
28 | private String property;
29 | private String name;
30 |
31 | /**
32 | * @return Retuns spark property name
33 | */
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | /**
39 | * @param name Sets spark property name
40 | */
41 | @XmlAttribute
42 | public void setName(String name) {
43 | this.name = name;
44 | }
45 |
46 | /**
47 | * @return Returns spark property value
48 | */
49 | public String getProperty() {
50 | return property;
51 | }
52 |
53 | /**
54 | * @param property Sets spark property value
55 | */
56 | @XmlValue
57 | public void setProperty(String property) {
58 | this.property = property;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/summary/PredictedVsActual.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.summary;
20 |
21 | import java.io.Serializable;
22 |
23 | /**
24 | * DTO class to store predicted vs. actual value
25 | */
26 | public class PredictedVsActual implements Serializable {
27 |
28 | private static final long serialVersionUID = 6763495729970627524L;
29 | private double predicted;
30 | private double actual;
31 |
32 | /**
33 | * @return Returns predicted value
34 | */
35 | public double getPredicted() {
36 | return predicted;
37 | }
38 |
39 | /**
40 | * @param predicted Sets predicted value
41 | */
42 | public void setPredicted(double predicted) {
43 | this.predicted = predicted;
44 | }
45 |
46 | /**
47 | * @return Returns actual value
48 | */
49 | public double getActual() {
50 | return actual;
51 | }
52 |
53 | /**
54 | * @param actual Sets actual value
55 | */
56 | public void setActual(double actual) {
57 | this.actual = actual;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/internal/ds/DecompositionServiceValueHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.internal.ds;
19 |
20 | import org.wso2.carbon.ml.database.DatabaseService;
21 | import org.wso2.carbon.ml.decomposition.DecompositionService;
22 |
23 | /**
24 | * The value holder used in the decomposition module
25 | */
26 | public class DecompositionServiceValueHolder {
27 | private static DecompositionService decompositionService;
28 | private static DatabaseService databaseService;
29 |
30 | public static void registerModelService(DecompositionService service) {
31 | DecompositionServiceValueHolder.decompositionService = service;
32 | }
33 |
34 | public static DecompositionService getModelService() {
35 | return decompositionService;
36 | }
37 |
38 | public static void registerDatabaseService(DatabaseService service) {
39 | DecompositionServiceValueHolder.databaseService = service;
40 | }
41 |
42 | public static DatabaseService getDatabaseService() {
43 | return databaseService;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/internal/SparkProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.internal;
19 |
20 | import javax.xml.bind.annotation.XmlAttribute;
21 | import javax.xml.bind.annotation.XmlValue;
22 |
23 | /**
24 | * DTO class for JAXB binding of SparkConfigurationParser.
25 | */
26 | public class SparkProperty {
27 | private String property;
28 | private String name;
29 |
30 | /**
31 | * @return Returns spark property name
32 | */
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | /**
38 | * @param name Sets spark property name
39 | */
40 | @XmlAttribute
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 |
45 | /**
46 | * @return Returns spark property value
47 | */
48 | public String getProperty() {
49 | return property;
50 | }
51 |
52 | /**
53 | * @param property Sets spark property value
54 | */
55 | @XmlValue
56 | public void setProperty(String property) {
57 | this.property = property;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/features/ml/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | carbon-ml
23 | org.wso2.carbon.ml
24 | 1.2.6-SNAPSHOT
25 | ../../pom.xml
26 |
27 | 4.0.0
28 | ml-features
29 | pom
30 | WSO2 Machine Learner Features
31 |
32 | org.wso2.carbon.ml.core.feature
33 | org.wso2.carbon.ml.commons.feature
34 | org.wso2.carbon.ml.feature
35 | org.wso2.carbon.ml.database.feature
36 | org.wso2.carbon.ml.rest.api.feature
37 | org.wso2.carbon.ml.jaggery.app.feature
38 | org.wso2.carbon.ml.ui.feature
39 |
40 |
41 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/RemoveResponseColumn.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.transformations;
20 |
21 | import org.apache.spark.api.java.function.Function;
22 |
23 | /**
24 | * This class removes response columns
25 | * It is assume that the response column is the last column. If the response column is not the last column,
26 | * RemoveDiscardedFeatures transformation should be applied prior to this transformation to restructure the response
27 | * column as the last column
28 | */
29 | public class RemoveResponseColumn implements Function {
30 |
31 | private static final long serialVersionUID = 5227320285806133114L;
32 |
33 | /**
34 | * Function to remove response column.
35 | *
36 | * @param tokens String array of tokens
37 | * @return String array
38 | */
39 | @Override
40 | public String[] call(String[] tokens) {
41 |
42 | String[] features = new String[tokens.length - 1];
43 |
44 | for (int i = 0; i < features.length; i++) {
45 | features[i] = tokens[i];
46 | }
47 | return features;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/features/ml/org.wso2.carbon.ml.core.feature/src/main/resources/conf/etc/ml-email-templates.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
23 |
24 |
25 |
26 | WSO2 ML - Model Building Complete
27 |
28 | Hi {1},
29 |
30 | The ML Model building has been successfully completed.
31 |
32 | Please click the following link to view the summary of the model.
33 |
34 | {2}
35 |
36 |
42 |
43 |
44 |
45 | WSO2 ML - Model Building Failed
46 |
47 | Hi {1},
48 |
49 | The ML Model building has been Failed.
50 |
51 | Please click the following link to rebuild a model.
52 |
53 | {2}
54 |
55 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/apps/ml/jaggery.conf:
--------------------------------------------------------------------------------
1 | {
2 | "welcomeFiles":["index.jag"],
3 | "securityConstraints":[
4 | {
5 | "securityConstraint":{
6 | "webResourceCollection":{
7 | "name":"site",
8 | "urlPatterns":["/site/conf/site.json"],
9 | "methods":["GET", "POST", "PUT", "DELETE"]
10 | },
11 | "authRoles":["admin"]
12 | }
13 | }
14 | ],
15 |
16 | "urlMappings":[
17 | {
18 | "url":"/ml/home",
19 | "path":"/site/home/home.jag"
20 | },
21 | {
22 | "url":"/apis/explore",
23 | "path":"/site/exploreData/exploreData.jag"
24 | }
25 | ],
26 | "listeners": [
27 | {
28 | "class": "org.owasp.csrfguard.CsrfGuardServletContextListener"
29 | },
30 | {
31 | "class": "org.owasp.csrfguard.CsrfGuardHttpSessionListener"
32 | }
33 | ],
34 | "servlets": [
35 | {
36 | "name": "JavaScriptServlet",
37 | "class": "org.owasp.csrfguard.servlet.JavaScriptServlet"
38 | }
39 | ],
40 | "servletMappings": [
41 | {
42 | "name": "JavaScriptServlet",
43 | "url": "/csrf.js"
44 | }
45 | ],
46 | "contextParams": [
47 | {
48 | "name": "Owasp.CsrfGuard.Config",
49 | "value": "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
50 | }
51 | ],
52 |
53 | "filters":[
54 | {
55 | "name":"HttpHeaderSecurityFilter",
56 | "class":"org.apache.catalina.filters.HttpHeaderSecurityFilter",
57 | "params" : [{"name" : "hstsMaxAgeSeconds", "value" : "15768000"}]
58 | }
59 | ],
60 |
61 | "filterMappings":[
62 | {
63 | "name":"HttpHeaderSecurityFilter",
64 | "url":"*"
65 | }
66 | ]
67 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/MLHyperParameter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.commons.domain;
19 |
20 | import javax.xml.bind.annotation.XmlElement;
21 |
22 | /**
23 | * Represent a Hyper Parameter in ML.
24 | */
25 | public class MLHyperParameter {
26 |
27 | private String key;
28 | private String value;
29 | private String description;
30 |
31 | @XmlElement(name = "Name")
32 | public String getKey() {
33 | return key;
34 | }
35 |
36 | public void setKey(String key) {
37 | this.key = key;
38 | }
39 |
40 | @XmlElement(name = "Value")
41 | public String getValue() {
42 | return value;
43 | }
44 |
45 | public void setValue(String value) {
46 | this.value = value;
47 | }
48 |
49 | @XmlElement(name = "Description")
50 | public String getDescription() {
51 | return description;
52 | }
53 |
54 | public void setDescription(String description) {
55 | this.description = description;
56 | }
57 |
58 | @Override
59 | public String toString() {
60 | return "MLHyperParameter [key=" + key + ", value=" + value + ", description=" + description + "]";
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/summary/FeatureImportance.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.summary;
20 |
21 | import java.io.Serializable;
22 |
23 | /**
24 | * DTO class to store feature vs. value value
25 | */
26 | public class FeatureImportance implements Serializable {
27 |
28 | private static final long serialVersionUID = 4836787591464024343L;
29 | private String label; //feature name. This is refer to as "label" according to the requirement of the graph.
30 | private double value; //weight. This is refer to as "value" according to the requirement of the graph.
31 |
32 | /**
33 | * @return Returns feature name
34 | */
35 | public String getLabel() {
36 | return label;
37 | }
38 |
39 | /**
40 | * Sets feature name
41 | * @param label feature name
42 | */
43 | public void setLabel(String label) {
44 | this.label = label;
45 | }
46 |
47 | /**
48 | * @return Returns value
49 | */
50 | public double getValue() {
51 | return value;
52 | }
53 |
54 | /**
55 | * @param value Sets value
56 | */
57 | public void setValue(double value) {
58 | this.value = value;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/apps/ml/site/conf/ui-messages.jag:
--------------------------------------------------------------------------------
1 | <%
2 | var error = {
3 |
4 | backendError:function (action) {
5 | return "Error occurred while executing the action " + action;
6 | },
7 |
8 | authError:function (action) {
9 | return "Error occurred while executing the action " + action;
10 | },
11 |
12 | contentMissing:function(action) {
13 | return "Please provide all needed content in order to " + action;
14 | },
15 |
16 | invalidAction:function(action) {
17 | return action + " is not supported";
18 | },
19 |
20 | pageNotFoundAction:function() {
21 | return {
22 | title:"The page cannot be found.",
23 | h1:"Error 404",
24 | msg:"The page you are looking for might have been removed,had its name changed or is temporarily unavailable."
25 | };
26 | },
27 |
28 | internalServerErrorAction:function() {
29 | return {
30 | title:"The page cannot be displayed.",
31 | h1:"Error 500",
32 | msg:"The server encountered an internal error or misconfiguration and was unable to complete your request."
33 | };
34 | },
35 |
36 | authErrorAction:function() {
37 | return {
38 | title:"Authorization Required.",
39 | h1:"Error 401",
40 | msg:"The server couldn't verify that you are authorized to access the requested resource."
41 | };
42 | },
43 |
44 | forbidAction:function() {
45 | return {
46 | title:"Forbidden.",
47 | h1:"Error 403",
48 | msg:"You don't have permission to access anything with that kind of request."
49 | };
50 | },
51 |
52 | workflowRequired:function (action) {
53 |
54 | return "Missing Parameters. Please provide the workflowReference and status";
55 |
56 | },
57 |
58 | workflowCredentialsRequired:function (action) {
59 | return "Please provide valid credentials.";
60 | }
61 | };
62 | %>
63 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/StringArrayToDoubleArray.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.transformations;
20 |
21 | import org.apache.spark.api.java.function.Function;
22 | import org.wso2.carbon.ml.core.exceptions.MLModelBuilderException;
23 |
24 | public class StringArrayToDoubleArray implements Function {
25 |
26 | private static final long serialVersionUID = 6885775018049237606L;
27 |
28 | private StringArrayToDoubleArray() {
29 | }
30 |
31 | @Override
32 | public double[] call(String[] tokens) throws MLModelBuilderException {
33 | try {
34 | double[] features = new double[tokens.length];
35 | for (int i = 0; i < tokens.length; ++i) {
36 | features[i] = Double.parseDouble(tokens[i]);
37 | }
38 | return features;
39 | } catch (Exception e) {
40 | throw new MLModelBuilderException("An error occurred while transforming tokens: " + e.getMessage(), e);
41 | }
42 | }
43 |
44 | public static class Builder {
45 | public StringArrayToDoubleArray build() {
46 | return new StringArrayToDoubleArray();
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.mediator.predict.ui/src/main/java/org/wso2/carbon/ml/mediator/predict/ui/PredictMediatorActivator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.mediator.predict.ui;
20 |
21 | import org.apache.commons.logging.Log;
22 | import org.apache.commons.logging.LogFactory;
23 | import org.osgi.framework.BundleActivator;
24 | import org.osgi.framework.BundleContext;
25 | import org.wso2.carbon.mediator.service.MediatorService;
26 |
27 | public class PredictMediatorActivator implements BundleActivator {
28 |
29 | private static final Log log = LogFactory.getLog(PredictMediatorActivator.class);
30 |
31 | public void start(BundleContext bundleContext) {
32 |
33 | if (log.isDebugEnabled()) {
34 | log.debug("Starting the predict mediator component ...");
35 | }
36 |
37 | bundleContext.registerService(
38 | MediatorService.class.getName(), new PredictMediatorService(), null);
39 |
40 | if (log.isDebugEnabled()) {
41 | log.debug("Successfully registered the predict mediator service");
42 | }
43 | }
44 |
45 | public void stop(BundleContext bundleContext) {
46 | if (log.isDebugEnabled()) {
47 | log.debug("Stopped the predict mediator component ...");
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.custom.adapter/src/main/java/org/wso2/carbon/ml/custom/adapter/input/CustomMLInputAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.custom.adapter.input;
19 |
20 | import java.io.File;
21 | import java.io.FileInputStream;
22 | import java.io.FileNotFoundException;
23 | import java.io.InputStream;
24 |
25 | import org.wso2.carbon.ml.core.exceptions.MLInputAdapterException;
26 | import org.wso2.carbon.ml.core.interfaces.MLInputAdapter;
27 |
28 | /**
29 | * This is a sample custom extension for a ML input adapter. You could follow the same pattern and implement a ML output
30 | * adapter too.
31 | */
32 | public class CustomMLInputAdapter implements MLInputAdapter {
33 |
34 | @Override
35 | public InputStream read(String path) throws MLInputAdapterException {
36 | try {
37 | FileInputStream inputStream = new FileInputStream(new File(path));
38 | return inputStream;
39 | } catch (FileNotFoundException e) {
40 | throw new MLInputAdapterException(String.format("Failed to read the data-set from uri %s: %s", path, e), e);
41 | } catch (IllegalArgumentException e) {
42 | throw new MLInputAdapterException(String.format("Failed to read the data-set from uri %s: %s", path, e), e);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.decomposition/src/main/java/org/wso2/carbon/ml/decomposition/spark/transformations/HeaderRemovingFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.decomposition.spark.transformations;
19 |
20 | import org.apache.spark.api.java.function.Function;
21 | import org.wso2.carbon.ml.decomposition.exceptions.DecompositionException;
22 |
23 | /**
24 | * This filter removes the header of a given dataset
25 | */
26 | public class HeaderRemovingFilter implements Function {
27 | private String header;
28 |
29 | public HeaderRemovingFilter(String header) {
30 | this.header = header;
31 | }
32 |
33 | /**
34 | * This method check whether a given line is header or not
35 | *
36 | * @param line Row in the dataset
37 | * @return
38 | * @throws DecompositionException
39 | */
40 | @Override
41 | public Boolean call(String line) throws DecompositionException {
42 | try {
43 | Boolean isRow = true;
44 | if (line.equals(this.header)) {
45 | isRow = false;
46 | }
47 | return isRow;
48 | } catch (Exception e) {
49 | throw new DecompositionException("An error occurred while removing header row: " + e.getMessage(), e);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/ClusterPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.commons.domain;
20 |
21 | import java.io.Serializable;
22 | import java.util.Arrays;
23 |
24 | /**
25 | * DTO class to store k-means cluster point
26 | */
27 | public class ClusterPoint implements Serializable {
28 |
29 | private static final long serialVersionUID = 2038403143111019647L;
30 | private double[] features;
31 | private int cluster;
32 |
33 | /**
34 | * @return Returns cluster label e.g: 1,2 etc.
35 | */
36 | public int getCluster() {
37 | return cluster;
38 | }
39 |
40 | /**
41 | * @param cluster Sets cluster label
42 | */
43 | public void setCluster(int cluster) {
44 | this.cluster = cluster;
45 | }
46 |
47 | /**
48 | * @return Returns features of a cluster point
49 | */
50 | public double[] getFeatures() {
51 | return features;
52 | }
53 |
54 | /**
55 | * @param features Sets features of a cluster point
56 | */
57 | public void setFeatures(double[] features) {
58 | if (features == null) {
59 | this.features = new double[0];
60 | } else {
61 | this.features = Arrays.copyOf(features, features.length);
62 | }
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/HeaderFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.transformations;
20 |
21 | import org.apache.spark.api.java.function.Function;
22 | import org.wso2.carbon.ml.core.internal.MLModelConfigurationContext;
23 |
24 | /**
25 | * A filter to remove header row
26 | */
27 | public class HeaderFilter implements Function {
28 |
29 | private static final long serialVersionUID = -6996897057400853414L;
30 | private final String header;
31 |
32 | private HeaderFilter(Builder builder) {
33 | this.header = builder.header;
34 | }
35 |
36 | @Override
37 | public Boolean call(String line) {
38 | Boolean isRow = true;
39 | if (line.equals(this.header)) {
40 | isRow = false;
41 | }
42 | return isRow;
43 | }
44 |
45 | public static class Builder {
46 | private String header;
47 |
48 | public Builder init(MLModelConfigurationContext ctx) {
49 | this.header = ctx.getHeaderRow();
50 | return this;
51 | }
52 |
53 | public Builder header(String header) {
54 | this.header = header;
55 | return this;
56 | }
57 |
58 | public HeaderFilter build() {
59 | return new HeaderFilter(this);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/components/extensions/org.wso2.carbon.ml.mediator.predict/src/main/java/org/wso2/carbon/ml/mediator/predict/PredictMediatorConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.mediator.predict;
20 |
21 | import org.apache.synapse.SynapseConstants;
22 | import org.apache.synapse.config.xml.XMLConfigConstants;
23 | import javax.xml.namespace.QName;
24 |
25 | public class PredictMediatorConstants {
26 |
27 | public static final QName PREDICT_QNAME = new QName(SynapseConstants.SYNAPSE_NAMESPACE, "predict");
28 |
29 | public static final QName MODEL_QNAME = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "model");
30 | public static final QName FEATURES_QNAME = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "features");
31 | public static final QName FEATURE_QNAME = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "feature");
32 | public static final QName PREDICTION_OUTPUT_QNAME = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "predictionOutput");
33 | public static final QName PERCENTILE_QNAME = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "percentile");
34 |
35 | public static final QName STORAGE_LOCATION_ATT = new QName("storage-location");
36 | public static final QName NAME_ATT = new QName("name");
37 | public static final QName EXPRESSION_ATT = new QName("expression");
38 | public static final QName PROPERTY_ATT = new QName("property");
39 | public static final QName VALUE_ATT = new QName("value");
40 | }
41 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/interfaces/MLModelBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.interfaces;
19 |
20 | import org.apache.commons.logging.Log;
21 | import org.apache.commons.logging.LogFactory;
22 | import org.wso2.carbon.ml.commons.domain.MLModel;
23 | import org.wso2.carbon.ml.core.exceptions.MLModelBuilderException;
24 | import org.wso2.carbon.ml.core.internal.MLModelConfigurationContext;
25 |
26 | /**
27 | * All Model Builders should extend this class.
28 | */
29 | public abstract class MLModelBuilder {
30 |
31 | private static final Log log = LogFactory.getLog(MLModelBuilder.class);
32 | private MLModelConfigurationContext context = null;
33 |
34 | public MLModelBuilder(MLModelConfigurationContext context) {
35 | this.setContext(context);
36 | }
37 |
38 | /**
39 | * Build a model using the context.
40 | * @return build {@link MLModel}
41 | * @throws MLModelBuilderException if failed to build the model.
42 | */
43 | public abstract MLModel build() throws MLModelBuilderException;
44 |
45 | public void handleIgnoreException(String msg, Exception e) {
46 | log.error(msg, e);
47 | }
48 |
49 | public MLModelConfigurationContext getContext() {
50 | return context;
51 | }
52 |
53 | public void setContext(MLModelConfigurationContext context) {
54 | this.context = context;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/MissingValuesFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.transformations;
20 |
21 | import org.apache.spark.api.java.function.Function;
22 | import org.wso2.carbon.ml.commons.constants.MLConstants;
23 | import org.wso2.carbon.ml.core.exceptions.MLModelBuilderException;
24 |
25 | /**
26 | * A filter to remove rows containing missing values
27 | */
28 | public class MissingValuesFilter implements Function {
29 |
30 | private static final long serialVersionUID = -4767804423665643237L;
31 |
32 | private MissingValuesFilter() {
33 | }
34 |
35 | @Override
36 | public Boolean call(String[] tokens) throws Exception {
37 | try {
38 | Boolean keep = true;
39 | for (String token : tokens) {
40 | if (MLConstants.MISSING_VALUES.contains(token)) {
41 | keep = false;
42 | break;
43 | }
44 | }
45 | return keep;
46 | } catch (Exception e) {
47 | throw new MLModelBuilderException("An error occurred while removing missing value rows: " + e.getMessage(),
48 | e);
49 | }
50 | }
51 |
52 | public static class Builder {
53 | public MissingValuesFilter build() {
54 | return new MissingValuesFilter();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.commons/src/main/java/org/wso2/carbon/ml/commons/domain/config/HyperParameter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.commons.domain.config;
20 |
21 | import java.io.Serializable;
22 |
23 | import javax.xml.bind.annotation.XmlElement;
24 |
25 | /**
26 | * DTO class for JAXB binding of MLAlgorithmConfigurationParser
27 | */
28 | public class HyperParameter implements Serializable {
29 | private static final long serialVersionUID = -2314030361825726083L;
30 | private String parameter;
31 | private String value;
32 |
33 | /**
34 | * @return Returns hyper-parameter name
35 | */
36 | @XmlElement(name = "Name")
37 | public String getParameter() {
38 | return parameter;
39 | }
40 |
41 | /**
42 | * @param parameter Sets hyper-parameter name
43 | */
44 | public void setParameter(String parameter) {
45 | this.parameter = parameter;
46 | }
47 |
48 | /**
49 | * @return Returns hyper-parameter value
50 | */
51 | @XmlElement(name = "Value")
52 | public String getValue() {
53 | return value;
54 | }
55 |
56 | /**
57 | * @param value Sets hyper-parameter value
58 | */
59 | public void setValue(String value) {
60 | this.value = value;
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return "HyperParameter [parameter=" + parameter + ", value=" + value + "]";
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/test/resources/fcSample.tsv:
--------------------------------------------------------------------------------
1 | Cover_Type Elevation Aspect Slope Horizontal_Distance_To_Hydrology Vertical_Distance_To_Hydrology Horizontal_Distance_To_Roadways Hillshade_9am Hillshade_Noon Hillshade_3pm Horizontal_Distance_To_Fire_Points Wilderness_Area1 Wilderness_Area2 Wilderness_Area3 Wilderness_Area4 Soil_Type1 Soil_Type2 Soil_Type3 Soil_Type4 Soil_Type5 Soil_Type6 Soil_Type7 Soil_Type8 Soil_Type9 Soil_Type10 Soil_Type11 Soil_Type12 Soil_Type13 Soil_Type14 Soil_Type15 Soil_Type16 Soil_Type17 Soil_Type18 Soil_Type19 Soil_Type20 Soil_Type21 Soil_Type22 Soil_Type23 Soil_Type24 Soil_Type25 Soil_Type26 Soil_Type27 Soil_Type28 Soil_Type29 Soil_Type30 Soil_Type31 Soil_Type32 Soil_Type33 Soil_Type34 Soil_Type35 Soil_Type36 Soil_Type37 Soil_Type38 Soil_Type39 Soil_Type40
2 | 3 2564 55 15 210 38 497 228 207 109 914 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 | 6 2434 11 14 408 164 955 204 210 141 977 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 | 1 2962 88 16 190 23 6095 242 212 95 3811 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 | 6 2370 275 24 180 64 1248 147 237 225 1430 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 | 4 2298 133 30 417 172 1209 251 210 63 693 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 | 5 2808 253 17 228 81 1630 180 249 205 2280 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 | 2 2457 282 22 90 24 283 154 235 218 42 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9 | 1 3097 300 14 67 14 4663 180 234 194 1383 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10 | 1 3291 297 4 180 5 5702 208 238 169 680 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
11 | 5 2757 129 12 0 0 2751 240 232 120 2259 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
12 | 4 2274 109 17 170 86 1276 247 218 94 1026 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
--------------------------------------------------------------------------------
/apps/ml/site/conf/locales/js/i18nResources_es.json:
--------------------------------------------------------------------------------
1 | {
2 | "info": {
3 | "appSelect": "Selecciona por favor una aplicaci�n antes de suscribirse",
4 | "wait": "Espera por favor..." ,
5 | "subscription": "Suscripci�n realizada con exito" ,
6 | "subscriptionSuccess": "�Felicitaciones! Te has suscrito con exito a la API. Vaya por favor a la p�gina 'Mis suscripciones' para revisar su suscripci�n y generar los Access Key.",
7 | "subscriptionPending": "Congratulations! Your subscription request has been submitted and is now awaiting approval.",
8 | "gotoSubsPage": "Ir a Mis Suscripciones",
9 | "stayPage": "Permanecer en esta p�gina",
10 | "returntoAPIPage": "�Volver a la p�gina de la API?",
11 | "yes": "S�",
12 | "no": "No",
13 | "charsLeft": "Caracteres restantes",
14 |
15 |
16 | },
17 | "confirm": {
18 | "delete": "Confirme borrado",
19 | "deleteMsg": "�Est�s seguro que deseas eliminar la aplicaci�n?",
20 | "deleteMsgPostfix": "Esto cancelar� todas las suscripciones y las claves existentes asociados con la aplicaci�n.",
21 | "unsubscribeMsg": "�Est�s seguro que deseas cancelar la suscripci�n a "
22 |
23 |
24 | },
25 | "titles":{
26 | "save":"Guardar",
27 | "cancel":"Cancelar",
28 | "production":"Producci�n",
29 | "sandbox":"Sandbox",
30 | "hideKeys":" Ocultar Keys",
31 | "showKeys":" Mostrar Keys",
32 | "regenerate":"Volver a generar"
33 | },
34 | "resultMsgs":{
35 | "showKey":"Las claves est�n disponibles. Haga clic en el bot�n 'Mostrar Keys' para visualizarlas."
36 |
37 | },
38 | "validationMsgs":{
39 | "invalidEmail": "Direcci�n de correo electr�nico no v�lida",
40 | "fieldRequired": "Este campo es obligatorio.",
41 | "exceedChars": "El nombre excede l�mite de caracteres (70)",
42 | "illegalChars": "El nombre contiene uno o m�s caracteres no v�lidos",
43 | "illegalName": "El nombre contiene uno o m�s caracteres no v�lidos",
44 | "invalid": "No v�lido",
45 | "valid": "V�lido",
46 | "testUri": "Probar URI",
47 | "validating": "Validando.."
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/SubDatasetFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.spark.transformations;
19 |
20 | import org.apache.spark.api.java.function.Function;
21 | import org.apache.spark.mllib.regression.LabeledPoint;
22 |
23 | import scala.Tuple2;
24 |
25 | public class SubDatasetFilter implements Function, Boolean> {
26 |
27 | private static final long serialVersionUID = 8685683197157772862L;
28 | private long startIndex;
29 | private long endIndex;
30 |
31 | private SubDatasetFilter(Builder builder) {
32 | this.startIndex = builder.start;
33 | this.endIndex = builder.end;
34 | }
35 |
36 | @Override
37 | public Boolean call(Tuple2 labeledTuple) {
38 | if (labeledTuple._2 >= startIndex && labeledTuple._2 <= endIndex) {
39 | return true;
40 | }
41 | return false;
42 | }
43 |
44 | public static class Builder {
45 | private long start;
46 | private long end;
47 |
48 | public Builder startIndex(long startIndex) {
49 | this.start = startIndex;
50 | return this;
51 | }
52 |
53 | public Builder endIndex(long endIndex) {
54 | this.end = endIndex;
55 | return this;
56 | }
57 |
58 | public SubDatasetFilter build() {
59 | return new SubDatasetFilter(this);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/transformations/LineToTokens.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.spark.transformations;
20 |
21 | import org.apache.spark.api.java.function.Function;
22 | import org.wso2.carbon.ml.core.internal.MLModelConfigurationContext;
23 | import org.wso2.carbon.ml.core.utils.MLUtils;
24 |
25 | import java.util.regex.Pattern;
26 |
27 | /**
28 | * This class transforms each line (line-by-line) into an array of String tokens
29 | */
30 | public class LineToTokens implements Function {
31 |
32 | private static final long serialVersionUID = -5025419727399292773L;
33 | private final Pattern tokenSeparator;
34 |
35 | public LineToTokens(Builder builder) {
36 | this.tokenSeparator = builder.tokenSeparator;
37 | }
38 |
39 | @Override
40 | public String[] call(String line) {
41 | return tokenSeparator.split(line);
42 | }
43 |
44 | public static class Builder {
45 | private Pattern tokenSeparator;
46 |
47 | public Builder init(MLModelConfigurationContext ctx) {
48 | this.tokenSeparator = MLUtils.getPatternFromDelimiter(ctx.getColumnSeparator());
49 | return this;
50 | }
51 |
52 | public Builder separator(Pattern separator) {
53 | this.tokenSeparator = separator;
54 | return this;
55 | }
56 |
57 | public LineToTokens build() {
58 | return new LineToTokens(this);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.rest.api/src/main/java/org/wso2/carbon/ml/rest/api/model/MLDatasetBean.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.rest.api.model;
19 |
20 | import java.util.List;
21 |
22 | /**
23 | * Represent a Data-set in ML.
24 | */
25 | public class MLDatasetBean {
26 |
27 | private long id;
28 | private String name;
29 | private String comments;
30 | private String createdTime;
31 | private List versions;
32 | private String status;
33 |
34 | public long getId() {
35 | return id;
36 | }
37 | public void setId(long id) {
38 | this.id = id;
39 | }
40 | public String getName() {
41 | return name;
42 | }
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 | public String getComments() {
47 | return comments;
48 | }
49 | public void setComments(String comments) {
50 | this.comments = comments;
51 | }
52 | public String getCreatedTime() {
53 | return createdTime;
54 | }
55 | public void setCreatedTime(String createdTime) {
56 | this.createdTime = createdTime;
57 | }
58 | public List getVersions() {
59 | return versions;
60 | }
61 | public void setVersions(List versions) {
62 | this.versions = versions;
63 | }
64 | public String getStatus() {
65 | return status;
66 | }
67 | public void setStatus(String status) {
68 | this.status = status;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/impl/RegistryInputAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 |
19 | package org.wso2.carbon.ml.core.impl;
20 |
21 | import org.wso2.carbon.context.PrivilegedCarbonContext;
22 | import org.wso2.carbon.context.RegistryType;
23 | import org.wso2.carbon.ml.core.exceptions.MLInputAdapterException;
24 | import org.wso2.carbon.ml.core.interfaces.MLInputAdapter;
25 | import org.wso2.carbon.registry.api.Registry;
26 | import org.wso2.carbon.registry.api.RegistryException;
27 | import org.wso2.carbon.registry.api.Resource;
28 |
29 | import java.io.ByteArrayInputStream;
30 | import java.io.InputStream;
31 |
32 | /**
33 | * Implementation of {@link MLInputAdapter} for governance registry
34 | */
35 | public class RegistryInputAdapter implements MLInputAdapter {
36 |
37 | @Override
38 | public InputStream read(String path) throws MLInputAdapterException {
39 | try {
40 | PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
41 | Registry registry = carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
42 | Resource resource = registry.get(path);
43 | byte[] readArray = (byte[]) resource.getContent();
44 | ByteArrayInputStream bis = new ByteArrayInputStream(readArray);
45 | return bis;
46 | } catch (RegistryException e) {
47 | throw new MLInputAdapterException(String.format("Failed to read the model from uri %s: %s", path, e), e);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/models/MLDecisionTreeModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.spark.models;
19 |
20 | import java.io.Externalizable;
21 | import java.io.IOException;
22 | import java.io.ObjectInput;
23 | import java.io.ObjectOutput;
24 |
25 | import org.apache.spark.mllib.tree.model.DecisionTreeModel;
26 |
27 | /**
28 | * Wraps Spark's {@link DecisionTreeModel} model.
29 | */
30 | public class MLDecisionTreeModel implements Externalizable {
31 | private DecisionTreeModel model;
32 |
33 | public MLDecisionTreeModel() {
34 | }
35 |
36 | public MLDecisionTreeModel(DecisionTreeModel model) {
37 | this.model = model;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
44 | */
45 | @Override
46 | public void writeExternal(ObjectOutput out) throws IOException {
47 |
48 | out.writeObject(model);
49 | }
50 |
51 | /*
52 | * (non-Javadoc)
53 | *
54 | * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
55 | */
56 | @Override
57 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
58 |
59 | model = (DecisionTreeModel) in.readObject();
60 | }
61 |
62 | public DecisionTreeModel getModel() {
63 | return model;
64 | }
65 |
66 | public void setModel(DecisionTreeModel model) {
67 | this.model = model;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/components/ml/org.wso2.carbon.ml.core/src/main/java/org/wso2/carbon/ml/core/spark/models/MLRandomForestModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * WSO2 Inc. licenses this file to you under the Apache License,
5 | * Version 2.0 (the "License"); you may not use this file except
6 | * in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing,
12 | * software distributed under the License is distributed on an
13 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | * KIND, either express or implied. See the License for the
15 | * specific language governing permissions and limitations
16 | * under the License.
17 | */
18 | package org.wso2.carbon.ml.core.spark.models;
19 |
20 | import java.io.Externalizable;
21 | import java.io.IOException;
22 | import java.io.ObjectInput;
23 | import java.io.ObjectOutput;
24 |
25 | import org.apache.spark.mllib.tree.model.RandomForestModel;
26 |
27 | /**
28 | * Wraps Spark's {@link RandomForestModel} model.
29 | */
30 | public class MLRandomForestModel implements Externalizable {
31 | private RandomForestModel model;
32 |
33 | public MLRandomForestModel() {
34 | }
35 |
36 | public MLRandomForestModel(RandomForestModel model) {
37 | this.model = model;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
44 | */
45 | @Override
46 | public void writeExternal(ObjectOutput out) throws IOException {
47 |
48 | out.writeObject(model);
49 | }
50 |
51 | /*
52 | * (non-Javadoc)
53 | *
54 | * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
55 | */
56 | @Override
57 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
58 |
59 | model = (RandomForestModel) in.readObject();
60 | }
61 |
62 | public RandomForestModel getModel() {
63 | return model;
64 | }
65 |
66 | public void setModel(RandomForestModel model) {
67 | this.model = model;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------