Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Update nodes doc from PR: 93 #69

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
57 changes: 57 additions & 0 deletions docs/nodes/nodes/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

[//]: # (Custom component imports)

import DocString from '@site/src/components/DocString';
import PythonCode from '@site/src/components/PythonCode';
import Parameters from '@site/src/components/Parameters';
import AppDisplay from '@site/src/components/AppDisplay';
import SectionBreak from '@site/src/components/SectionBreak';
import AppendixSection from '@site/src/components/AppendixSection';

[//]: # (Docstring)

import DocstringSource from '!!raw-loader!./a1-[autogen]/docstring.txt';
import PythonSource from '!!raw-loader!./a1-[autogen]/python_code.txt';
import ParametersSource from '!!raw-loader!./a1-[autogen]/parameters.yaml';

<DocString>{DocstringSource}</DocString>
<PythonCode GLink='bin/flojoy-io/docs/docs/AI_ML/CLASSIFICATION/ONE_HOT_ENCODING.py'>{PythonSource}</PythonCode>
<Parameters>{ParametersSource}</Parameters>

<SectionBreak />



[//]: # (Examples)

## Examples

import Example1 from './examples/EX1/example.md';
import App1 from '!!raw-loader!./examples/EX1/app.txt';
import Data1 from '!!raw-loader!./examples/EX1/output.txt';

<AppDisplay
data={Data1}
nodeLabel='ONE_HOT_ENCODING'>
{App1}
</AppDisplay>

<Example1 />

<SectionBreak />



[//]: # (Appendix)

import Notes from '!!raw-loader!./appendix/notes.md';
import Hardware from '!!raw-loader!./appendix/hardware.md';
import Media from '!!raw-loader!./appendix/media.md';

## Appendix

<AppendixSection index={0} folderPath='nodes/nodes/bin/flojoy-io/docs/docs/nodes/nodes/AI_ML/CLASSIFICATION/appendix/'>{Notes}</AppendixSection>
<AppendixSection index={1} folderPath='nodes/nodes/bin/flojoy-io/docs/docs/nodes/nodes/AI_ML/CLASSIFICATION/appendix/'>{Hardware}</AppendixSection>
<AppendixSection index={2} folderPath='nodes/nodes/bin/flojoy-io/docs/docs/nodes/nodes/AI_ML/CLASSIFICATION/appendix/'>{Media}</AppendixSection>


14 changes: 14 additions & 0 deletions docs/nodes/nodes/AI_ML/CLASSIFICATION/a1-[autogen]/docstring.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The ONE_HOT_ENCODING node creates a one hot encoding from a list of categorical features.
The `categories` parameter can be used to generate a one hot encoding without having to pass a dataframe.
By default, all categorical columns in the input dataframe will be encoded. The `columns`
parameter can be used to specify the columns to encode.

Parameters
----------
categories : list of str or list of int, optional
columns: list of str, optional

Returns
-------
matrix
The one hot encoding of the input features.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
categories:
default: ''
type: array
columns:
default: ''
type: array
36 changes: 36 additions & 0 deletions docs/nodes/nodes/AI_ML/CLASSIFICATION/a1-[autogen]/python_code.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from flojoy import flojoy, DataContainer
import pandas as pd


@flojoy
def ONE_HOT_ENCODING(dc_inputs: list[DataContainer], params: dict) -> DataContainer:


dc = dc_inputs[0] if len(dc_inputs) > 0 else None

if dc is not None and dc.type != "dataframe":
raise ValueError(
f"unsupported DataContainer type passed to ONE_HOT_ENCODING node: '{dc.type}'"
)

categories = params.get("categories", [])
columns = params.get("columns", [])

if categories:
data = pd.DataFrame({"category": categories})
# Force pandas to treat the column as categorical
data["category"] = data["category"].astype("category")
encoded = pd.get_dummies(data, dtype=int)

return DataContainer(type="dataframe", m=encoded)

if not dc:
raise ValueError(f"ONE_HOT_ENCODING node did not receive input DataContainer")

if columns:
encoded = pd.get_dummies(dc.m[columns])
else:
cat_df = dc.m.select_dtypes(include=["object", "category"])
encoded = pd.get_dummies(cat_df, dtype=int)

return DataContainer(type="dataframe", m=encoded)
Empty file.
Empty file.
166 changes: 166 additions & 0 deletions docs/nodes/nodes/AI_ML/CLASSIFICATION/examples/EX1/app.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"rfInstance": {
"nodes": [
{
"width": 150,
"height": 150,
"id": "ONE_HOT_ENCODING-b15db30d-818c-4c14-b6a9-2ecc0d76fffa",
"type": "CLASSIFICATION",
"data": {
"id": "ONE_HOT_ENCODING-b15db30d-818c-4c14-b6a9-2ecc0d76fffa",
"label": "ONE HOT ENCODING",
"func": "ONE_HOT_ENCODING",
"type": "CLASSIFICATION",
"ctrls": {
"categories": {
"functionName": "ONE_HOT_ENCODING",
"param": "categories",
"value": ""
},
"columns": {
"functionName": "ONE_HOT_ENCODING",
"param": "columns",
"value": "smoker,day"
}
},
"selected": false
},
"position": {
"x": 492.2217042786417,
"y": 150.33145519440131
},
"selected": false,
"positionAbsolute": {
"x": 492.2217042786417,
"y": 150.33145519440131
},
"dragging": true
},
{
"width": 150,
"height": 150,
"id": "PLOTLY_DATASET-3ec5e34e-b56a-4779-a8cd-e5e1c01d1689",
"type": "SAMPLE_DATASET",
"data": {
"id": "PLOTLY_DATASET-3ec5e34e-b56a-4779-a8cd-e5e1c01d1689",
"label": "PLOTLY DATASET",
"func": "PLOTLY_DATASET",
"type": "SAMPLE_DATASET",
"ctrls": {
"dataset_key": {
"functionName": "PLOTLY_DATASET",
"param": "dataset_key",
"value": "tips"
}
},
"selected": true
},
"position": {
"x": 165.0788471357846,
"y": 147.47431233725848
},
"selected": true,
"positionAbsolute": {
"x": 165.0788471357846,
"y": 147.47431233725848
},
"dragging": true
},
{
"width": 380,
"height": 293,
"id": "TABLE-a7e5677c-e1cd-466d-a3ec-36742974d261",
"type": "PLOTLY_VISOR",
"data": {
"id": "TABLE-a7e5677c-e1cd-466d-a3ec-36742974d261",
"label": "TABLE",
"func": "TABLE",
"type": "PLOTLY_VISOR",
"ctrls": {},
"selected": false
},
"position": {
"x": 727.9359899929276,
"y": 101.7600266229727
},
"selected": false,
"positionAbsolute": {
"x": 727.9359899929276,
"y": 101.7600266229727
},
"dragging": true
},
{
"width": 210,
"height": 130,
"id": "END-de791708-214d-46a3-a334-af3b779d7b49",
"type": "TERMINATOR",
"data": {
"id": "END-de791708-214d-46a3-a334-af3b779d7b49",
"label": "END",
"func": "END",
"type": "TERMINATOR",
"ctrls": {},
"selected": false
},
"position": {
"x": 1133.650275707213,
"y": 167.47431233725848
},
"selected": false,
"positionAbsolute": {
"x": 1133.650275707213,
"y": 167.47431233725848
},
"dragging": true
}
],
"edges": [
{
"source": "PLOTLY_DATASET-3ec5e34e-b56a-4779-a8cd-e5e1c01d1689",
"sourceHandle": "main",
"target": "ONE_HOT_ENCODING-b15db30d-818c-4c14-b6a9-2ecc0d76fffa",
"targetHandle": "ONE_HOT_ENCODING",
"id": "reactflow__edge-PLOTLY_DATASET-3ec5e34e-b56a-4779-a8cd-e5e1c01d1689main-ONE_HOT_ENCODING-b15db30d-818c-4c14-b6a9-2ecc0d76fffaONE_HOT_ENCODING"
},
{
"source": "ONE_HOT_ENCODING-b15db30d-818c-4c14-b6a9-2ecc0d76fffa",
"sourceHandle": "main",
"target": "TABLE-a7e5677c-e1cd-466d-a3ec-36742974d261",
"targetHandle": "TABLE",
"id": "reactflow__edge-ONE_HOT_ENCODING-b15db30d-818c-4c14-b6a9-2ecc0d76fffamain-TABLE-a7e5677c-e1cd-466d-a3ec-36742974d261TABLE"
},
{
"source": "TABLE-a7e5677c-e1cd-466d-a3ec-36742974d261",
"sourceHandle": "main",
"target": "END-de791708-214d-46a3-a334-af3b779d7b49",
"targetHandle": "END",
"id": "reactflow__edge-TABLE-a7e5677c-e1cd-466d-a3ec-36742974d261main-END-de791708-214d-46a3-a334-af3b779d7b49END"
}
],
"viewport": {
"x": 34.964285714285666,
"y": 190.74999999999997,
"zoom": 0.5
}
},
"ctrlsManifest": [
{
"type": "input",
"name": "Slider",
"id": "INPUT_PLACEHOLDER",
"hidden": false,
"minHeight": 1,
"minWidth": 2,
"layout": {
"x": 0,
"y": 0,
"h": 2,
"w": 2,
"minH": 1,
"minW": 2,
"i": "INPUT_PLACEHOLDER"
}
}
]
}
3 changes: 3 additions & 0 deletions docs/nodes/nodes/AI_ML/CLASSIFICATION/examples/EX1/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In this example, `ONE_HOT_ENCODING` is passed the `tips` dataset from the `PLOTLY_DATASET` node.

`ONE_HOT_ENCODING` is passed `smoker,day` for the `columns` parameter, so the output consists of a dataframe with one hot encodings for only the `smoker` and `day` columns from the input dataset.
57 changes: 57 additions & 0 deletions docs/nodes/nodes/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

[//]: # (Custom component imports)

import DocString from '@site/src/components/DocString';
import PythonCode from '@site/src/components/PythonCode';
import Parameters from '@site/src/components/Parameters';
import AppDisplay from '@site/src/components/AppDisplay';
import SectionBreak from '@site/src/components/SectionBreak';
import AppendixSection from '@site/src/components/AppendixSection';

[//]: # (Docstring)

import DocstringSource from '!!raw-loader!./a1-[autogen]/docstring.txt';
import PythonSource from '!!raw-loader!./a1-[autogen]/python_code.txt';
import ParametersSource from '!!raw-loader!./a1-[autogen]/parameters.yaml';

<DocString>{DocstringSource}</DocString>
<PythonCode GLink='bin/flojoy-io/docs/docs/AI_ML/OBJECT_DETECTION/OBJECT_DETECTION.py'>{PythonSource}</PythonCode>
<Parameters>{ParametersSource}</Parameters>

<SectionBreak />



[//]: # (Examples)

## Examples

import Example1 from './examples/EX1/example.md';
import App1 from '!!raw-loader!./examples/EX1/app.txt';
import Data1 from '!!raw-loader!./examples/EX1/output.txt';

<AppDisplay
data={Data1}
nodeLabel='OBJECT_DETECTION'>
{App1}
</AppDisplay>

<Example1 />

<SectionBreak />



[//]: # (Appendix)

import Notes from '!!raw-loader!./appendix/notes.md';
import Hardware from '!!raw-loader!./appendix/hardware.md';
import Media from '!!raw-loader!./appendix/media.md';

## Appendix

<AppendixSection index={0} folderPath='nodes/nodes/bin/flojoy-io/docs/docs/nodes/nodes/AI_ML/OBJECT_DETECTION/appendix/'>{Notes}</AppendixSection>
<AppendixSection index={1} folderPath='nodes/nodes/bin/flojoy-io/docs/docs/nodes/nodes/AI_ML/OBJECT_DETECTION/appendix/'>{Hardware}</AppendixSection>
<AppendixSection index={2} folderPath='nodes/nodes/bin/flojoy-io/docs/docs/nodes/nodes/AI_ML/OBJECT_DETECTION/appendix/'>{Media}</AppendixSection>


12 changes: 12 additions & 0 deletions docs/nodes/nodes/AI_ML/OBJECT_DETECTION/a1-[autogen]/docstring.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Performs object detection on the input `DataContainer` class, specifically for the 'image' type,
represented by the RGB(A) channels.

Args:
dc_inputs (list[DataContainer]): List of DataContainer objects containing image channels.
params (dict): Additional parameters for object detection (not used in this function).

Returns:
DataContainer: A `DataContainer` class of type 'image' representing the output image with object detection results.

Raises:
Exception: If an error occurs during object detection.
Loading