Skip to content

Commit

Permalink
added API docs + cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinvanschoren committed Nov 6, 2023
1 parent cf09ab7 commit 245ab4c
Show file tree
Hide file tree
Showing 12 changed files with 6,327 additions and 22 deletions.
2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"react-syntax-highlighter": "15.5.0",
"react-timeago": "^7.2.0",
"redux": "4.2.1",
"swagger-ui-react": "^5.9.1",
"swagger-ui-themes": "^3.0.1",
"web-vitals": "3.5.0",
"yup": "1.3.2"
},
Expand Down
6 changes: 4 additions & 2 deletions app/public/locales/en/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ contribute:
- "OpenCollective"
- "GitHub Sponsors"
about:
helmet: "About"
helmet: "About us"
title: "About OpenML"
core: "Authors"
core_text: >
Expand Down Expand Up @@ -484,4 +484,6 @@ terms:
do our best efforts to promptly remove such information from our records.
### Consent
By using our website, you hereby consent to our Privacy Policy and agree to its terms.
By using our website, you hereby consent to our Privacy Policy and agree to its terms.
apis:
helmet: "APIs"
5,649 changes: 5,649 additions & 0 deletions app/public/openml-api.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions app/src/components/navbar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ const Input = styled(InputBase)`
padding-right: ${(props) => props.theme.spacing(2.5)};
padding-bottom: ${(props) => props.theme.spacing(2.5)};
padding-left: ${(props) => props.theme.spacing(2.5)};
min-width: 260px;
max-width: 100%;
min-width: 100vw;
}
& > input::placeholder {
Expand All @@ -90,12 +89,12 @@ const Input = styled(InputBase)`
${(props) => props.theme.breakpoints.up("md")} {
& > input {
min-width: 400px;
min-width: 440px;
}
}
${(props) => props.theme.breakpoints.up("lg")} {
& > input {
min-width: 600px;
min-width: 740px;
}
}
`;
Expand Down
189 changes: 189 additions & 0 deletions app/src/components/pages/apis/SwaggerUI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import styled from "@emotion/styled";

const StyledSwaggerUI = styled.div`
[id^="model-"][id*="_"] {
display: none;
}
[id^="model-"][id*="List"] {
display: none;
}
[id^="model-"][id*="Unprocessed"] {
display: none;
}
[id^="model-"][id*="Request"] {
display: none;
}
[id^="model-"][id*="Trace"] {
display: none;
}
.swagger-ui,
.swagger-ui *,
.swagger-ui .info .title,
.swagger-ui .info p,
.swagger-ui .info li,
.swagger-ui select,
.swagger-ui .opblock *,
.swagger-ui .opblock .opblock-section-header * {
color: ${(props) => props.theme.palette.text.primary};
}
.swagger-ui .info a {
color: ${(props) => props.theme.palette.text.secondary};
}
.swagger-ui select,
.swagger-ui .opblock,
.swagger-ui .opblock-tag,
.swagger-ui section.models .model-container,
.swagger-ui .opblock .opblock-section-header {
background-color: ${(props) => props.theme.palette.background.paper};
}
.swagger-ui .model,
.swagger-ui table.model tr.property-row td {
font-size: 10pt !important;
}
.swagger-ui .model-title {
font-size: 12pt !important;
}
.swagger-ui .model-toggle:after {
background: ${(props) =>
`url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='${encodeURIComponent(
props.theme.name == "DARK"
? props.theme.palette.primary.contrastText
: "#000",
)}' d='M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'/%3E%3C/svg%3E") 50% no-repeat`};
}
.swagger-ui .expand-methods svg,
.swagger-ui .opblock svg,
.swagger-ui .expand-operation svg {
fill: ${(props) =>
props.theme.name == "DARK"
? props.theme.palette.primary.contrastText
: "#000"};
}
.swagger-ui .scheme-container {
background: inherit;
box-shadow: none;
}
.swagger-ui .wrapper:nth-of-type(2n):before {
content: "Actions";
font-size: 18pt;
font-weight: 600;
}
#operations-tag-data {
margin-top: 20px;
}
.swagger-ui .scheme-container {
direction: rtl;
display: flex;
justify-content: flex-end;
padding: 0;
}
.swagger-ui section.schemes {
margin-left: auto;
}
.swagger-ui .servers {
width: 320px;
}
.swagger-ui .servers > label {
margin: 0;
}
.swagger-ui section.models .model-container {
margin: 0;
border-bottom: 1px solid rgba(59, 65, 81, 0.3);
border-radius: 0px;
box-shadow:
0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 3px 1px -2px rgba(0, 0, 0, 0.2),
0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.swagger-ui section.models .model-container:last-of-type {
margin: 0;
}
.swagger-ui section.models.is-open {
padding: 0px;
}
.swagger-ui section.models {
border: none;
}
.swagger-ui section.models h4 {
margin-bottom: 10px;
font-size: 18pt;
font-weight: 600;
}
.swagger-ui section.models.is-open h4 {
margin-top: 20px;
margin-bottom: 0px;
border-bottom: 0px;
}
.swagger-ui .info {
margin-bottom: 0px;
}
.swagger-ui .servers > label select {
height: 40px;
}
.swagger-ui table.model tr.property-row td {
padding: 0.6em;
font-size: 12pt;
}
.swagger-ui td .model .pointer .model-title {
display: none;
}
.swagger-ui .model-box {
padding-top: 7px;
padding-left: 5px;
padding-bottom: 7px;
}
.swagger-ui .model,
.model-title {
font-size: 12pt;
text-transform: lowercase;
}
.swagger-ui .model-title__text {
padding-left: 10px;
}
.swagger-ui td .model-toggle {
font-size: 20px;
top: 2px;
margin-left: 0px;
}
.swagger-ui td .brace-open {
font-size: 16px;
}
.renderedMarkdown {
}
.swagger-ui .opblock-tag {
margin: 0px;
box-shadow:
0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 3px 1px -2px rgba(0, 0, 0, 0.2),
0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.no-margin {
display: flex;
flex-direction: column;
}
.swagger-ui .opblock-tag-section h4 {
padding-left: 20px;
font-size: 12pt;
height: 50px;
}
.swagger-ui .opblock-get {
padding-left: 5px;
margin-bottom: 1px;
}
.swagger-ui .opblock-post {
padding-left: 5px;
margin-bottom: 1px;
order: 2;
}
.swagger-ui .opblock-delete {
padding-left: 5px;
margin-bottom: 1px;
order: 3;
}
.swagger-ui .opblock-summary {
height: 50px;
}
`;

export default StyledSwaggerUI;
34 changes: 34 additions & 0 deletions app/src/components/pages/apis/javaCodeExamples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Installation
export const InstallationExample = `// Download the jar file, or install via Maven. See the full docs.`;

// Query and download data
export const DataExample = `// Create a client. Your API key can be found in your account.
OpenmlConnector openml = new OpenmlConnector("api_key");
// List all datasets and their properties
DataSet[] datasets = openml.dataList();
// Get dataset by ID
DataSetDescription data = openml.dataGet(40996);
String file_url = data.getUrl();`;

// Run and publish models
export const RunExample = `// Build any model you like
Classifier model = new RandomForest();
// Download any OpenML task
Task t = openml.taskGet(3954);
// Load the data as WEKA Instances (optional)
Instances d = InstancesHelper.getDatasetFromTask(openml, t);
// Run and evaluate your model on the task, and upload to OpenML
Pair<Integer, Run> result = RunOpenmlJob.executeTask(openml, new WekaConfig(), 3954, model);`;

// Using Benchmarks
export const BenchmarkExample = `// List all tasks in a benchmark
Study benchmark = openml.studyGet("OpenML-CC18", "tasks");
Task[] tasks = benchmark.getTasks()
// Return benchmark results
EvaluationList el = openml.evaluationList(tasks, null, "area_under_roc_curve", 1000);`;
17 changes: 17 additions & 0 deletions app/src/components/pages/apis/juliaCodeExamples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Installation
export const InstallationExample = `using Pkg
Pkg.add("OpenML")`;

// Query and download data
export const DataExample = `using OpenML
using DataFrames
# List all datasets and their properties
ds = OpenML.list_datasets(output_format = DataFrame)
# Get dataset by ID
OpenML.describe_dataset(40996)
# Get the data itself as a dataframe (or otherwise)
table = OpenML.load(40996)
df = DataFrame(table)`;
46 changes: 46 additions & 0 deletions app/src/components/pages/apis/pythonCodeExamples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Installation
export const InstallationExample = `pip install openml`;

// Query and download data
export const DataExample = `import openml
# List all datasets and their properties
openml.datasets.list_datasets(output_format="dataframe")
# Get dataset by ID
dataset = openml.datasets.get_dataset(61)
# Get dataset by name
dataset = openml.datasets.get_dataset('Fashion-MNIST')
# Get the data itself as a dataframe (or otherwise)
X, y, _, _ = dataset.get_data(dataset_format="dataframe")`;

// Run and publish models
export const RunExample = `from sklearn import ensemble
from openml import tasks, runs
# Build any model you like
clf = ensemble.RandomForestClassifier()
# Download any OpenML task
task = tasks.get_task(3954)
# Run and evaluate your model on the task
run = runs.run_model_on_task(clf, task)
# Share the results on OpenML. Your API key can be found in your account.
# openml.config.apikey = 'YOUR_KEY'
run.publish()`;

// Using Benchmarks
export const BenchmarkExample = `# List all tasks in a benchmark
benchmark = openml.study.get_suite('OpenML-CC18')
tasks.list_tasks(output_format="dataframe", task_id=benchmark.tasks)
# Return benchmark results
openml.evaluations.list_evaluations(
function="area_under_roc_curve",
tasks=benchmark.tasks,
output_format="dataframe"
)`;
44 changes: 44 additions & 0 deletions app/src/components/pages/apis/rCodeExamples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Installation
export const InstallationExample = `# Note: The old OpenML package is superseded by the mlr3oml package.
# The documentation of the OpenML package can be found here: http://openml.github.io/openml-r/.
install.packages("mlr3oml")`;

// Query and download data
export const DataExample = `library(mlr3oml)
library(mlr3)
# Search for specific datasets
odatasets = list_oml_data(
number_features = c(10, 20),
number_instances = c(45000, 50000),
number_classes = 2
)
# Get dataset
odata = odt(id = 1590)
# Access the actual data
odata$data
# Convert to an mlr3::Task
tsk_adult = as_task(odata, target = "class")`;

// Run and publish models
export const RunExample = `# create an mlr3 Learner and Resampling and run a resample experiment
rr = resample(
task = tsk_adult,
learner = lrn("classif.rpart"),
resampling = rsmp("cv", folds = 10)
)`;

// Using Benchmarks
export const BenchmarkExample = `# Access a Benchmark Suite
ocollection = ocl(353)
# The IDs
ocollection$task_ids
id = ocollection$task_ids[1L]
# Create mlr3 Task and Resampling from the OpenML Task
task = tsk("oml", task_id = id)
resampling = rsmp("oml", task_id = id)`;
Loading

0 comments on commit 245ab4c

Please sign in to comment.