Skip to content

Commit

Permalink
GitHub Actions build openturns/otsvm 6733810987
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Nov 2, 2023
1 parent 58196af commit 360330b
Show file tree
Hide file tree
Showing 36 changed files with 1,082 additions and 571 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"outputs": [],
"source": [
"import openturns as ot\nimport otsvm\n\n# create a function, here we create the Sobol function\ndimension = 3\nmeanTh = 1.0\na = ot.Point(dimension)\ninputVariables = ot.Description(dimension)\nformula = \"1.0\"\ncovTh = 1.0\nfor i in range(dimension):\n a[i] = 0.5 * i\n covTh = covTh * (1.0 + 1.0 / (3.0 * (1.0 + a[i]) ** 2))\n inputVariables[i] = \"xi\" + str(i)\n formula += (\n \" * ((abs(4.0 * xi\"\n + str(i)\n + \" -2.0) + \"\n + str(a[i])\n + \") / (1.0 + \"\n + str(a[i])\n + \"))\"\n )\ncovTh = covTh - 1.0\nmodel = ot.SymbolicFunction(inputVariables, ot.Description(1, formula))\n\n# create the input distribution\not.RandomGenerator.SetSeed(0)\nmarginals = ot.DistributionCollection(dimension)\nfor i in range(dimension):\n marginals[i] = ot.Uniform(0.0, 1.0)\ndistribution = ot.ComposedDistribution(marginals)\n\n# create lists of kernel parameters and tradeoff factors\ntradeoff = [0.01, 0.1, 1, 10, 100, 1000]\nkernel = [0.001, 0.01, 0.1, 1, 10, 100]\n\n# first example : create the problem with an input and output samples:\n# first, we create samples\ndataIn = distribution.getSample(250)\ndataOut = model(dataIn)\n# second, we create our svm regression object, we must select the third parameter\n# in an enumerate in the list { NormalRBF, Linear, Sigmoid, Polynomial }\nalgo = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.NormalRbf)\n# third, we set kernel parameter and tradeoff factor\nalgo.setTradeoffFactor(tradeoff)\nalgo.setKernelParameter(kernel)\n# Perform the algorithm\nalgo.run()\n# Stream out the results\nresult = algo.getResult()\n# get the residual error\nresidual = result.getResiduals()\n# get the relative error\nrelativeError = result.getRelativeErrors()\nprint(f\"residual={residual} error={relativeError}\")\n\n# second example : create the problem with an experiment plane:\n# first, we create the plane\nmyExperiment = ot.MonteCarloExperiment(distribution, 250)\ndataIn = myExperiment.generate()\ndataOut = model(dataIn)\n# second, we create our svm regression object, the first parameter is the\n# function\nalgo2 = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.Linear)\n# third, we set kernel parameter and tradeoff factor\nalgo2.setTradeoffFactor(tradeoff)\nalgo2.setKernelParameter(kernel)\n# Perform the algorithm\nalgo2.run()\n# Stream out the results\nresult = algo2.getResult()\n# get the residual error\nresidual = result.getResiduals()\n# get the relative error\nrelativeError = result.getRelativeErrors()\nprint(f\"residual={residual} error={relativeError}\")\n\n# third example is here to present you the SVMResourceMap class.\n# Users can fix others parameters like the degree and the constant of the\n# Polynomial Kernel,the cacheSize, the number of folds or the epsilon\n# first, we create samples\ndataIn = distribution.getSample(250)\ndataOut = model(dataIn)\n# second, we create our svm regression object\n# here, we select the Polynomial Kernel but by default his degree is 3. We want a\n# degree of 2\not.ResourceMap.Set(\"LibSVM-DegreePolynomialKernel\", \"2\")\n# now the degree of the Polynomial kernel is 2\nalgo = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.Polynomial)\n# third, we set kernel parameter and tradeoff factor\nalgo.setTradeoffFactor(tradeoff)\nalgo.setKernelParameter(kernel)\n# Perform the algorithm\n#algo.run()\n## Stream out the results\n#result = algo.getResult()\n#print(result)\n## get the residual error\n#residual = result.getResiduals()\n## get the relative error\n#relativeError = result.getRelativeErrors()"
"import openturns as ot\nimport otsvm\n\n# create a function, here we create the Sobol function\ndimension = 3\nmeanTh = 1.0\na = ot.Point(dimension)\ninputVariables = ot.Description(dimension)\nformula = \"1.0\"\ncovTh = 1.0\nfor i in range(dimension):\n a[i] = 0.5 * i\n covTh = covTh * (1.0 + 1.0 / (3.0 * (1.0 + a[i]) ** 2))\n inputVariables[i] = \"xi\" + str(i)\n formula += (\n \" * ((abs(4.0 * xi\"\n + str(i)\n + \" -2.0) + \"\n + str(a[i])\n + \") / (1.0 + \"\n + str(a[i])\n + \"))\"\n )\ncovTh = covTh - 1.0\nmodel = ot.SymbolicFunction(inputVariables, ot.Description(1, formula))\n\n# create the input distribution\not.RandomGenerator.SetSeed(0)\nmarginals = ot.DistributionCollection(dimension)\nfor i in range(dimension):\n marginals[i] = ot.Uniform(0.0, 1.0)\ndistribution = ot.ComposedDistribution(marginals)\n\n# create lists of kernel parameters and tradeoff factors\ntradeoff = [0.01, 0.1, 1, 10, 100, 1000]\nkernel = [0.001, 0.01, 0.1, 1, 10, 100]\n\n# first example : create the problem with an input and output samples:\n# first, we create samples\ndataIn = distribution.getSample(250)\ndataOut = model(dataIn)\n# second, we create our svm regression object, we must select the third parameter\n# in an enumerate in the list { NormalRBF, Linear, Sigmoid, Polynomial }\nalgo = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.NormalRbf)\n# third, we set kernel parameter and tradeoff factor\nalgo.setTradeoffFactor(tradeoff)\nalgo.setKernelParameter(kernel)\n# Perform the algorithm\nalgo.run()\n# Stream out the results\nresult = algo.getResult()\n# get the residual error\nresidual = result.getResiduals()\n# get the relative error\nrelativeError = result.getRelativeErrors()\nprint(f\"residual={residual} error={relativeError}\")\n\n# second example : create the problem with an experiment plane:\n# first, we create the plane\nmyExperiment = ot.MonteCarloExperiment(distribution, 250)\ndataIn = myExperiment.generate()\ndataOut = model(dataIn)\n# second, we create our svm regression object, the first parameter is the\n# function\nalgo2 = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.Linear)\n# third, we set kernel parameter and tradeoff factor\nalgo2.setTradeoffFactor(tradeoff)\nalgo2.setKernelParameter(kernel)\n# Perform the algorithm\nalgo2.run()\n# Stream out the results\nresult = algo2.getResult()\n# get the residual error\nresidual = result.getResiduals()\n# get the relative error\nrelativeError = result.getRelativeErrors()\nprint(f\"residual={residual} error={relativeError}\")\n\n# third example is here to present you the SVMResourceMap class.\n# Users can fix others parameters like the degree and the constant of the\n# Polynomial Kernel,the cacheSize, the number of folds or the epsilon\n# first, we create samples\ndataIn = distribution.getSample(250)\ndataOut = model(dataIn)\n# second, we create our svm regression object\n# here, we select the Polynomial Kernel but by default his degree is 3. We want a\n# degree of 2\not.ResourceMap.Set(\"LibSVM-DegreePolynomialKernel\", \"2\")\n# now the degree of the Polynomial kernel is 2\nalgo = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.Polynomial)\n# third, we set kernel parameter and tradeoff factor\nalgo.setTradeoffFactor(tradeoff)\nalgo.setKernelParameter(kernel)\n# Perform the algorithm\n#algo.run()\n## Stream out the results\n#result = algo.getResult()\n#print(result)\n## get the residual error\n#residual = result.getResiduals()\n## get the relative error\n#relativeError = result.getRelativeErrors()"
]
}
],
Expand All @@ -42,7 +42,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
dataOut = model(dataIn)
# second, we create our svm regression object, we must select the third parameter
# in an enumerate in the list { NormalRBF, Linear, Sigmoid, Polynomial }
algo = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.NormalRbf)
algo = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.NormalRbf)
# third, we set kernel parameter and tradeoff factor
algo.setTradeoffFactor(tradeoff)
algo.setKernelParameter(kernel)
Expand All @@ -85,7 +85,7 @@
dataOut = model(dataIn)
# second, we create our svm regression object, the first parameter is the
# function
algo2 = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.Linear)
algo2 = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.Linear)
# third, we set kernel parameter and tradeoff factor
algo2.setTradeoffFactor(tradeoff)
algo2.setKernelParameter(kernel)
Expand All @@ -110,7 +110,7 @@
# degree of 2
ot.ResourceMap.Set("LibSVM-DegreePolynomialKernel", "2")
# now the degree of the Polynomial kernel is 2
algo = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.Polynomial)
algo = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.Polynomial)
# third, we set kernel parameter and tradeoff factor
algo.setTradeoffFactor(tradeoff)
algo.setKernelParameter(kernel)
Expand Down
8 changes: 4 additions & 4 deletions otsvm/master/_sources/auto_examples/plot_example1.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Usually, the algorithm always converges, but this can take a long while, mostly
dataOut = model(dataIn)
# second, we create our svm regression object, we must select the third parameter
# in an enumerate in the list { NormalRBF, Linear, Sigmoid, Polynomial }
algo = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.NormalRbf)
algo = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.NormalRbf)
# third, we set kernel parameter and tradeoff factor
algo.setTradeoffFactor(tradeoff)
algo.setKernelParameter(kernel)
Expand All @@ -107,7 +107,7 @@ Usually, the algorithm always converges, but this can take a long while, mostly
dataOut = model(dataIn)
# second, we create our svm regression object, the first parameter is the
# function
algo2 = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.Linear)
algo2 = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.Linear)
# third, we set kernel parameter and tradeoff factor
algo2.setTradeoffFactor(tradeoff)
algo2.setKernelParameter(kernel)
Expand All @@ -132,7 +132,7 @@ Usually, the algorithm always converges, but this can take a long while, mostly
# degree of 2
ot.ResourceMap.Set("LibSVM-DegreePolynomialKernel", "2")
# now the degree of the Polynomial kernel is 2
algo = otsvm.SVMRegression(dataIn, dataOut, otsvm.LibSVM.Polynomial)
algo = otsvm.LibSVMRegression(dataIn, dataOut, otsvm.LibSVM.Polynomial)
# third, we set kernel parameter and tradeoff factor
algo.setTradeoffFactor(tradeoff)
algo.setKernelParameter(kernel)
Expand Down Expand Up @@ -162,7 +162,7 @@ Usually, the algorithm always converges, but this can take a long while, mostly
.. rst-class:: sphx-glr-timing

**Total running time of the script:** ( 0 minutes 6.452 seconds)
**Total running time of the script:** (0 minutes 4.452 seconds)


.. _sphx_glr_download_auto_examples_plot_example1.py:
Expand Down
2 changes: 1 addition & 1 deletion otsvm/master/_sources/auto_examples/plot_example2.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ otsvm enables to:
.. rst-class:: sphx-glr-timing

**Total running time of the script:** ( 0 minutes 2.537 seconds)
**Total running time of the script:** (0 minutes 1.962 seconds)


.. _sphx_glr_download_auto_examples_plot_example2.py:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

Computation times
=================
**00:08.990** total execution time for **auto_examples** files:
**00:06.414** total execution time for **auto_examples** files:

+-----------------------------------------------------------------------+-----------+--------+
| :ref:`sphx_glr_auto_examples_plot_example1.py` (``plot_example1.py``) | 00:06.452 | 0.0 MB |
| :ref:`sphx_glr_auto_examples_plot_example1.py` (``plot_example1.py``) | 00:04.452 | 0.0 MB |
+-----------------------------------------------------------------------+-----------+--------+
| :ref:`sphx_glr_auto_examples_plot_example2.py` (``plot_example2.py``) | 00:02.537 | 0.0 MB |
| :ref:`sphx_glr_auto_examples_plot_example2.py` (``plot_example2.py``) | 00:01.962 | 0.0 MB |
+-----------------------------------------------------------------------+-----------+--------+
22 changes: 22 additions & 0 deletions otsvm/master/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ a.headerlink {
visibility: hidden;
}

a:visited {
color: #551A8B;
}

h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
Expand Down Expand Up @@ -670,6 +674,16 @@ dd {
margin-left: 30px;
}

.sig dd {
margin-top: 0px;
margin-bottom: 0px;
}

.sig dl {
margin-top: 0px;
margin-bottom: 0px;
}

dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
Expand Down Expand Up @@ -738,6 +752,14 @@ abbr, acronym {
cursor: help;
}

.translated {
background-color: rgba(207, 255, 207, 0.2)
}

.untranslated {
background-color: rgba(255, 207, 207, 0.2)
}

/* -- code displays --------------------------------------------------------- */

pre {
Expand Down
2 changes: 1 addition & 1 deletion otsvm/master/_static/classic.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ a {
}

a:visited {
color: #355f7c;
color: #551a8b;
text-decoration: none;
}

Expand Down
3 changes: 1 addition & 2 deletions otsvm/master/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
const DOCUMENTATION_OPTIONS = {
VERSION: '0.12',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
Expand Down
1 change: 1 addition & 0 deletions otsvm/master/_static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
Expand Down
26 changes: 17 additions & 9 deletions otsvm/master/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ const _removeChildren = (element) => {
const _escapeRegExp = (string) =>
string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string

const _displayItem = (item, searchTerms) => {
const _displayItem = (item, searchTerms, highlightTerms) => {
const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT;
const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
const contentRoot = document.documentElement.dataset.content_root;

const [docName, title, anchor, descr, score, _filename] = item;

Expand All @@ -75,20 +75,24 @@ const _displayItem = (item, searchTerms) => {
if (dirname.match(/\/index\/$/))
dirname = dirname.substring(0, dirname.length - 6);
else if (dirname === "index/") dirname = "";
requestUrl = docUrlRoot + dirname;
requestUrl = contentRoot + dirname;
linkUrl = requestUrl;
} else {
// normal html builders
requestUrl = docUrlRoot + docName + docFileSuffix;
requestUrl = contentRoot + docName + docFileSuffix;
linkUrl = docName + docLinkSuffix;
}
let linkEl = listItem.appendChild(document.createElement("a"));
linkEl.href = linkUrl + anchor;
linkEl.dataset.score = score;
linkEl.innerHTML = title;
if (descr)
if (descr) {
listItem.appendChild(document.createElement("span")).innerHTML =
" (" + descr + ")";
// highlight search terms in the description
if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
}
else if (showSearchSummary)
fetch(requestUrl)
.then((responseData) => responseData.text())
Expand All @@ -97,6 +101,9 @@ const _displayItem = (item, searchTerms) => {
listItem.appendChild(
Search.makeSearchSummary(data, searchTerms)
);
// highlight search terms in the summary
if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
});
Search.output.appendChild(listItem);
};
Expand All @@ -115,14 +122,15 @@ const _finishSearch = (resultCount) => {
const _displayNextItem = (
results,
resultCount,
searchTerms
searchTerms,
highlightTerms,
) => {
// results left, load the summary and display it
// this is intended to be dynamic (don't sub resultsCount)
if (results.length) {
_displayItem(results.pop(), searchTerms);
_displayItem(results.pop(), searchTerms, highlightTerms);
setTimeout(
() => _displayNextItem(results, resultCount, searchTerms),
() => _displayNextItem(results, resultCount, searchTerms, highlightTerms),
5
);
}
Expand Down Expand Up @@ -360,7 +368,7 @@ const Search = {
// console.info("search results:", Search.lastresults);

// print the results
_displayNextItem(results, results.length, searchTerms);
_displayNextItem(results, results.length, searchTerms, highlightTerms);
},

/**
Expand Down
1 change: 1 addition & 0 deletions otsvm/master/_static/sg_gallery-dataframe.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ table.dataframe {
color: var(--sg-text-color);
font-size: 12px;
table-layout: fixed;
width: auto;
}
table.dataframe thead {
border-bottom: 1px solid var(--sg-text-color);
Expand Down
16 changes: 13 additions & 3 deletions otsvm/master/_static/sphinx_highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ const _highlight = (node, addItems, text, className) => {
}

span.appendChild(document.createTextNode(val.substr(pos, text.length)));
const rest = document.createTextNode(val.substr(pos + text.length));
parent.insertBefore(
span,
parent.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
rest,
node.nextSibling
)
);
node.nodeValue = val.substr(0, pos);
/* There may be more occurrences of search term in this node. So call this
* function recursively on the remaining fragment.
*/
_highlight(rest, addItems, text, className);

if (isInSVG) {
const rect = document.createElementNS(
Expand Down Expand Up @@ -140,5 +145,10 @@ const SphinxHighlight = {
},
};

_ready(SphinxHighlight.highlightSearchWords);
_ready(SphinxHighlight.initEscapeListener);
_ready(() => {
/* Do not call highlightSearchWords() when we are on the search page.
* It will highlight words from the *previous* search query.
*/
if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords();
SphinxHighlight.initEscapeListener();
});
Loading

0 comments on commit 360330b

Please sign in to comment.