Skip to content

Commit

Permalink
Merge pull request #116 from 1chooo/ho-dev
Browse files Browse the repository at this point in the history
add: classifier playground
  • Loading branch information
1chooo authored Sep 11, 2023
2 parents 5dac104 + f39f04f commit 6b01b26
Show file tree
Hide file tree
Showing 11 changed files with 862 additions and 19 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,3 @@ Released under [MIT](./LICENSE) by [Hugo ChunHo Lin](https://github.com/1chooo).
This software can be modified and reused without restriction.
The original license must be included with any copies of this software.
If a significant portion of the source code is used, please provide a link back to this repository.

## Refinaid Team
<table>
<tr>
<td align="center"><a href="https://1chooo-github-io.vercel.app/"><img src="https://avatars.githubusercontent.com/u/94162591?v=4" width="100px;" alt=""/><br /><sub><b>1chooo</b></sub></a><br /><a href="https://github.com/1chooo/simple-ai/commits?author=1chooo" title="Code">💻 🧳</a></td>
<td align="center"><a href="https://github.com/ReeveWu"><img src="https://avatars.githubusercontent.com/u/110542858?v=4" width="100px;" alt=""/><br /><sub><b>ReeveWu</b></sub></a><br /><a href="https://github.com/1chooo/simple-ai/commits?author=ReeveWu" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/VincentLi1216"><img src="https://avatars.githubusercontent.com/u/98581766?v=4" width="100px;" alt=""/><br /><sub><b>VincentLi1216</b></sub></a><br /><a href="https://github.com/1chooo/simple-ai/commits?author=VincentLi1216" title="Code">💻</a></td>
</tr>
</table>
23 changes: 14 additions & 9 deletions Refinaid/App/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse, FileResponse
from fastapi.staticfiles import StaticFiles
from Refinaid.Playground.Classifier.Launch import build_ui
from Refinaid.gui.Launch import build_ui
from fastapi import Form, Depends, HTTPException
import gradio as gr
from Refinaid.gui.Launch import build_ui

PLAYGROUND_PATH = "/gradio"

Expand All @@ -23,19 +24,23 @@
)

os.makedirs("static", exist_ok=True)
app.mount("/static", StaticFiles(directory="static"), name="static")
app.mount(
"/static",
StaticFiles(directory="static"),
name="static",
)

templates = Jinja2Templates(directory="templates")

demo = build_ui()
demo.favicon_path = (
classifier_demo = build_ui()
classifier_demo.favicon_path = (
os.sep +
"static" +
os.sep +
"favicon.png"
)
app = gr.mount_gradio_app(
app, demo, path=PLAYGROUND_PATH,
app, classifier_demo, path=PLAYGROUND_PATH,
)

@app.get("/", response_class=HTMLResponse)
Expand Down Expand Up @@ -69,13 +74,13 @@ async def page_signup(request: Request, ):
)

@app.get("/about_us", response_class=HTMLResponse)
async def page_teaching(request: Request, ):
async def page_about_us(request: Request, ):
return templates.TemplateResponse(
f"about_us.html", {"request": request}
)

@app.get("/license", response_class=HTMLResponse)
async def page_teaching(request: Request, ):
async def page_license(request: Request, ):
return templates.TemplateResponse(
f"license.html", {"request": request}
)
Expand Down Expand Up @@ -105,13 +110,13 @@ async def page_orders(request: Request, ):
)

@app.get("/playgrounds", response_class=HTMLResponse)
async def page_orders(request: Request, ):
async def page_playgrounds(request: Request, ):
return templates.TemplateResponse(
f"playgrounds.html", {"request": request}
)

@app.get("/favicon.ico")
async def favicon():
return FileResponse(
os.getcwd() + demo.favicon_path
os.getcwd() + classifier_demo.favicon_path
)
31 changes: 31 additions & 0 deletions Refinaid/Playground/Classifier/Dashborad/Header.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
'''
Create Date: 2023/09/11
Author: @1chooo(Hugo ChunHo Lin)
Version: v0.1.2
'''

import gradio as gr
from Refinaid.gui.Information import PageContent
from typing import Any

class PageHeader:

def __init__(self, page_content: PageContent) -> None:
self.page_content = page_content

def get_home_header(
self, *args: Any, **kwargs: Any) -> gr.Markdown:
our_heading = gr.Markdown(
self.page_content.home_header
)

return our_heading

def get_preprocessing_header(
self, *args: Any, **kwargs: Any) -> gr.Markdown:
our_preprocessing_header = gr.Markdown(
self.page_content.preprocessing_header
)

return our_preprocessing_header
225 changes: 225 additions & 0 deletions Refinaid/Playground/Classifier/Dashborad/Preprocessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
# -*- coding: utf-8 -*-
'''
Create Date: 2023/09/11
Author: @1chooo(Hugo ChunHo Lin)
Version: v0.1.2
'''

import gradio as gr
from Refinaid.gui.Information import PageContent
from typing import Any, Tuple
from Refinaid.Action.Load import get_dataframe

class PreprocessingComponent:

def __init__(self, page_content: PageContent) -> None:
self.page_content = page_content

def get_dataset_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Markdown,
gr.Dropdown
]:

dataset_header = gr.Markdown("### Dataset")

dataset_choices = self.page_content.dataset_choices

selected_dataset_name = gr.Dropdown(
label="Select Dataset",
value="Titanic",
choices=dataset_choices,
interactive=True,
)

return (
dataset_header,
selected_dataset_name
)

def get_select_mutiple_parameters_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Markdown,
gr.Dropdown
]:
select_mutiple_parameters_header = gr.Markdown(
"### Select Mutiple Parameters"
)
select_mutiple_parameters_dropdown = gr.Dropdown(
label="Select Mutiple Parameters",
value=[
'PassengerId', 'Pclass', 'Sex',
'Age', 'SibSp', 'Parch', 'Ticket',
'Fare', 'Cabin', 'Embarked'
],
choices=[
'PassengerId', 'Pclass', 'Sex',
'Age', 'SibSp', 'Parch', 'Ticket',
'Fare', 'Cabin', 'Embarked'
],
interactive=True,
multiselect=True,
)

return (
select_mutiple_parameters_header,
select_mutiple_parameters_dropdown
)

def get_missing_values_handling_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Markdown,
gr.Radio
]:

missing_values_handling_header = gr.Markdown(
"### Missing Values Handling"
)
missing_value_checkbox = gr.Radio(
label="Select a Method",
value="Drop Nan",
choices=[
"Drop Nan",
"By Columns"
],
interactive=True,
)
return (
missing_values_handling_header,
missing_value_checkbox
)

def get_data_scale_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Markdown,
gr.Radio
]:

data_scale_header = gr.Markdown(
"### Data Scaling"
)
data_scale_dropdown = gr.Radio(
value="None",
choices=[
"None",
"Standard",
"Min-Max"
],
label="Please select a method",
interactive=True,
)

return (
data_scale_header,
data_scale_dropdown
)

def get_data_split_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Markdown,
gr.Slider,
gr.Slider,
gr.Slider
]:
data_split_header = gr.Markdown(
"### Data Split\nTotal value should be 100%"
)

training_slider = gr.Slider(
label="Training Set",
value=70,
minimum=0,
maximum=100,
step=5,
interactive=True,
)
validation_slider = gr.Slider(
label="Validation Set",
value=10,
minimum=0,
maximum=100,
step=5,
interactive=True,
)
testing_slider = gr.Slider(
label="Testing Set",
value=20,
minimum=0,
maximum=100,
step=5,
interactive=True,
)

return (
data_split_header,
training_slider,
validation_slider,
testing_slider
)

def get_submit_dataset_setting_btn(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Button
]:

submit_dataset_setting_btn = gr.Button(
value="Submit Data Preprocessing Results",
)

return (
submit_dataset_setting_btn
)

def get_preprocessing_visulize_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Markdown, gr.ScatterPlot
]:

preprocessing_visulize_header = gr.Markdown(
"### Data Visualization in Preprocessing"
)

preprocessing_visulize_scatter_plot = gr.ScatterPlot(
value=get_dataframe("Titanic"),
label="Data Visualization",
x="PassengerId",
y="Pclass",
title='Scatter Plot in Data Visualization',
# height=400,
# width=400,
caption='Observe the relationship between parameters',
)

return (
preprocessing_visulize_header,
preprocessing_visulize_scatter_plot
)

def get_preprocessing_visualize_axis_info(
self, *args: Any, **kwargs: Any) -> Tuple[
gr.Dropdown, gr.Dropdown
]:
x_axis_dropdown = gr.Dropdown(
label="X Axis",
value='PassengerId',
choices=[
'PassengerId', 'Pclass', 'Age',
'SibSp', 'Parch', 'Fare'
],
interactive=True,
)
y_axis_dropdown = gr.Dropdown(
label="Y Axis",
value='Pclass',
choices=[
'PassengerId', 'Pclass', 'Age',
'SibSp', 'Parch', 'Fare'
],
interactive=True,
)

return (
x_axis_dropdown,
y_axis_dropdown
)

Loading

0 comments on commit 6b01b26

Please sign in to comment.