├── .gitignore ├── README.md ├── analysis_of_insertion_sort └── discussion.pdf ├── confluent.zip ├── dash_basic_callback ├── app.py └── test.py ├── dash_multipage_app └── app.py ├── dash_single_page_app_layout └── app.py ├── dash_supress_callback_exceptions └── app.py ├── dash_validation_layout └── app.py ├── facts_atoms_vars ├── Queries.txt └── code.pl ├── insertion_sort └── discussion.pdf ├── merge_sort_intro ├── divide_conquer-diagram.jpg └── lecture.pdf ├── plotly_deep_learning_app ├── Dockerfile ├── app.py ├── apps │ ├── __pycache__ │ │ ├── home.cpython-39.pyc │ │ ├── polls.cpython-39.pyc │ │ ├── polls_results.cpython-39.pyc │ │ └── showcase.cpython-39.pyc │ └── navigation.py ├── assets │ ├── 404.jpg │ ├── logo2.png │ └── styles.css ├── datasets │ └── images │ │ ├── apple.jpg │ │ ├── banana.jpg │ │ ├── bear.jpg │ │ ├── bear1.jpg │ │ ├── cat.jpg │ │ ├── charlyn chaplin.jpg │ │ ├── chikku.jpg │ │ ├── chikku1.jpg │ │ ├── fish.jpg │ │ └── tiger.jpg ├── index.py ├── pages │ ├── home.py │ ├── hownnlearns.py │ ├── not_found_404.py │ └── showcase.py └── requirements.txt ├── problem_solving_1 ├── Question_1.py ├── Question_2.py └── problem_solving_1.pdf ├── prolog_intro └── Prolog_Intro.jpg ├── prolog_problem_solving_1 ├── code.pl └── problems.pdf ├── splunk_nlp.tar.gz ├── structuring_dash_apps_part1 └── polling_app │ ├── app.py │ ├── apps │ ├── __pycache__ │ │ ├── home.cpython-39.pyc │ │ ├── polls.cpython-39.pyc │ │ └── polls_results.cpython-39.pyc │ ├── home.py │ ├── polls.py │ └── polls_results.py │ ├── datasets │ └── polls.csv │ └── index.py └── structuring_dash_apps_part2 └── polling_app ├── app.py ├── callbacks.py ├── datasets └── polls.csv ├── index.py └── layouts.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # algorithms 2 | This repo will contain all the codes and materials used in my computer science youtube channel https://www.youtube.com/channel/UC7J8myLv3tPabjeocxKQQKw 3 | -------------------------------------------------------------------------------- /analysis_of_insertion_sort/discussion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/analysis_of_insertion_sort/discussion.pdf -------------------------------------------------------------------------------- /confluent.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/confluent.zip -------------------------------------------------------------------------------- /dash_basic_callback/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | 6 | 7 | app = dash.Dash(__name__) 8 | 9 | app.layout = html.Div(children=[ 10 | html.H1(children="Welcome to the dash Polling app!"), 11 | html.Div(["Input: ", dcc.Input(id="input1",type="text", value="Initial Value")]), 12 | html.Br(), 13 | html.Div(id="output-div") 14 | ]) 15 | 16 | @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="input1",component_property="value")) 17 | def update_output_div(input_val): 18 | output_val = "Output: {}".format(input_val) 19 | return output_val 20 | 21 | 22 | if __name__ == "__main__": 23 | app.run_server(debug=True) -------------------------------------------------------------------------------- /dash_basic_callback/test.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def repeat(number_times): 4 | def func2(another_function): 5 | 6 | def wrapper_function(*args, **kwargs): 7 | print("The activities before calling {}".format(another_function)) 8 | for i in range(number_times): 9 | another_function(*args, **kwargs) 10 | print("The activities after calling {}".format(another_function)) 11 | 12 | return wrapper_function 13 | return func2 14 | 15 | @repeat(number_times=2) 16 | def func1(name): 17 | print("Hello {}, from func1".format(name)) 18 | 19 | 20 | #func1 = func2(func1) 21 | 22 | func1("Sid") -------------------------------------------------------------------------------- /dash_multipage_app/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | 6 | 7 | app = dash.Dash(__name__) 8 | 9 | app.layout = html.Div(children=[ 10 | #html.H1(children="Welcome to the dash Polling app!"), 11 | dcc.Location(id="url",refresh=False), 12 | # dcc.Link('Home',href="/"), 13 | # html.Br(), 14 | # dcc.Link('Polls',href="/polls"), 15 | # html.Br(), 16 | # dcc.Link('Poll Results',href="/poll-results"), 17 | html.Div(id="output-div") 18 | ]) 19 | 20 | home_layout = html.Div(children=[ 21 | html.H1(children="Welcome to the dash Polling app!"), 22 | dcc.Link('Home',href="/"), 23 | html.Br(), 24 | dcc.Link('Polls',href="/polls"), 25 | html.Br(), 26 | dcc.Link('Poll Results',href="/poll-results") 27 | ]) 28 | 29 | polls_layout = html.Div(children=[ 30 | html.H1(children="This is Polls page"), 31 | dcc.Link('Home',href="/") 32 | ]) 33 | 34 | polls_results_layout = html.Div(children=[ 35 | html.H1(children="This is Poll Results page"), 36 | dcc.Link('Home',href="/") 37 | ]) 38 | 39 | @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 40 | def update_output_div(pathname): 41 | if pathname == "/polls": 42 | return polls_layout 43 | elif pathname == "/poll-results": 44 | return polls_results_layout 45 | else: 46 | return home_layout 47 | #output_val = "Output: {}".format(pathname) 48 | #return output_val 49 | 50 | 51 | if __name__ == "__main__": 52 | app.run_server(debug=True) -------------------------------------------------------------------------------- /dash_single_page_app_layout/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_html_components as html 3 | 4 | app = dash.Dash(__name__) 5 | 6 | app.layout = html.Div(children=[ 7 | html.H1(children="Welcome to the dash Polling app!") 8 | ]) 9 | 10 | 11 | if __name__ == "__main__": 12 | app.run_server(debug=True) -------------------------------------------------------------------------------- /dash_supress_callback_exceptions/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | import dash_bootstrap_components as dbc 6 | import pandas as pd 7 | import os 8 | 9 | 10 | app = dash.Dash(__name__,suppress_callback_exceptions=True) 11 | 12 | app.layout = html.Div(children=[ 13 | #html.H1(children="Welcome to the dash Polling app!"), 14 | dcc.Location(id="url",refresh=False), 15 | # dcc.Link('Home',href="/"), 16 | # html.Br(), 17 | # dcc.Link('Polls',href="/polls"), 18 | # html.Br(), 19 | # dcc.Link('Poll Results',href="/poll-results"), 20 | html.Div(id="output-div") 21 | ]) 22 | 23 | home_layout = html.Div(children=[ 24 | html.H1(children="Welcome to the dash Polling app!"), 25 | dcc.Link('Home',href="/"), 26 | html.Br(), 27 | dcc.Link('Polls',href="/polls"), 28 | html.Br(), 29 | dcc.Link('Poll Results',href="/poll-results") 30 | ]) 31 | 32 | polls_layout = html.Div(children=[ 33 | html.H1(children="This is Polls page"), 34 | dcc.Link('Home',href="/"), 35 | html.Br(), 36 | html.Br(), 37 | html.Div([ 38 | "Select a Poll:", 39 | dcc.Dropdown(id="polls-name-dropdown", 40 | options=[{'label': i, 'value': i} for i in ["Poll1","Poll2", "Poll3"]]) 41 | ]), 42 | html.Br(), 43 | html.Br(), 44 | html.Div(id="polls-question-div") 45 | 46 | ]) 47 | 48 | polls_results_layout = html.Div(children=[ 49 | html.H1(children="This is Poll Results page"), 50 | dcc.Link('Home',href="/") 51 | ]) 52 | 53 | @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 54 | def update_output_div(pathname): 55 | if pathname == "/polls": 56 | return polls_layout 57 | elif pathname == "/poll-results": 58 | return polls_results_layout 59 | else: 60 | return home_layout 61 | #output_val = "Output: {}".format(pathname) 62 | #return output_val 63 | 64 | 65 | @app.callback(Output(component_id="polls-question-div",component_property="children"),Input(component_id="polls-name-dropdown",component_property="value")) 66 | def display_poll_question(pollname): 67 | poll_question_df = pd.read_csv(os.path.join(os.path.dirname(__file__),'datasets','polls.csv')) 68 | #print(poll_question_df) 69 | poll_question_filtered_df = poll_question_df.loc[poll_question_df["poll_name"] == str(pollname)] 70 | question_input = None 71 | if not poll_question_filtered_df.empty: 72 | question_input = html.Div([ 73 | dbc.Label(poll_question_filtered_df["question_text"]), 74 | dbc.RadioItems( 75 | options=[ 76 | {"label": poll_question_filtered_df["option1"], "value": 1}, 77 | {"label": poll_question_filtered_df["option2"], "value": 2}, 78 | {"label": poll_question_filtered_df["option3"], "value": 3}, 79 | {"label": poll_question_filtered_df["option4"], "value": 4} 80 | ], 81 | value=1, 82 | id="radioitems-input", 83 | ), 84 | ]) 85 | question_div = html.Div([ 86 | dbc.Form([question_input]) 87 | ]) 88 | 89 | return question_div 90 | 91 | 92 | if __name__ == "__main__": 93 | app.run_server(debug=True) -------------------------------------------------------------------------------- /dash_validation_layout/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | import dash_bootstrap_components as dbc 6 | import pandas as pd 7 | import os 8 | 9 | 10 | app = dash.Dash(__name__) 11 | 12 | url_content_layout = html.Div(children=[ 13 | dcc.Location(id="url",refresh=False), 14 | html.Div(id="output-div") 15 | ]) 16 | 17 | app.layout = url_content_layout 18 | 19 | home_layout = html.Div(children=[ 20 | html.H1(children="Welcome to the dash Polling app!"), 21 | dcc.Link('Home',href="/"), 22 | html.Br(), 23 | dcc.Link('Polls',href="/polls"), 24 | html.Br(), 25 | dcc.Link('Poll Results',href="/poll-results") 26 | ]) 27 | 28 | polls_layout = html.Div(children=[ 29 | html.H1(children="This is Polls page"), 30 | dcc.Link('Home',href="/"), 31 | html.Br(), 32 | html.Br(), 33 | html.Div([ 34 | "Select a Poll:", 35 | dcc.Dropdown(id="polls-name-dropdown", 36 | options=[{'label': i, 'value': i} for i in ["Poll1","Poll2", "Poll3"]]) 37 | ]), 38 | html.Br(), 39 | html.Br(), 40 | html.Div(id="polls-question-div") 41 | 42 | ]) 43 | 44 | polls_results_layout = html.Div(children=[ 45 | html.H1(children="This is Poll Results page"), 46 | dcc.Link('Home',href="/") 47 | ]) 48 | 49 | app.validation_layout = html.Div([ 50 | url_content_layout, 51 | home_layout, 52 | polls_layout, 53 | polls_results_layout 54 | ]) 55 | 56 | @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 57 | def update_output_div(pathname): 58 | if pathname == "/polls": 59 | return polls_layout 60 | elif pathname == "/poll-results": 61 | return polls_results_layout 62 | else: 63 | return home_layout 64 | #output_val = "Output: {}".format(pathname) 65 | #return output_val 66 | 67 | 68 | @app.callback(Output(component_id="polls-question-div",component_property="children"),Input(component_id="polls-name-dropdown",component_property="value")) 69 | def display_poll_question(pollname): 70 | poll_question_df = pd.read_csv(os.path.join(os.path.dirname(__file__),'datasets','polls.csv')) 71 | #print(poll_question_df) 72 | poll_question_filtered_df = poll_question_df.loc[poll_question_df["poll_name"] == str(pollname)] 73 | question_input = None 74 | if not poll_question_filtered_df.empty: 75 | question_input = html.Div([ 76 | dbc.Label(poll_question_filtered_df["question_text"]), 77 | dbc.RadioItems( 78 | options=[ 79 | {"label": poll_question_filtered_df["option1"], "value": 1}, 80 | {"label": poll_question_filtered_df["option2"], "value": 2}, 81 | {"label": poll_question_filtered_df["option3"], "value": 3}, 82 | {"label": poll_question_filtered_df["option4"], "value": 4} 83 | ], 84 | value=1, 85 | id="radioitems-input", 86 | ), 87 | ]) 88 | question_div = html.Div([ 89 | dbc.Form([question_input]) 90 | ]) 91 | 92 | return question_div 93 | 94 | 95 | if __name__ == "__main__": 96 | app.run_server(debug=True) -------------------------------------------------------------------------------- /facts_atoms_vars/Queries.txt: -------------------------------------------------------------------------------- 1 | 1.Is Bob a parent of Pat? 2 | parent(bob,pat). 3 | 4 | 2.Is Liz a parent of Pat? 5 | parent(liz,pat). 6 | 7 | 3.Is tom a parent of Ben? 8 | parent(tom,ben). 9 | 10 | 4. Who is Liz's parent? 11 | parent(X,liz). 12 | 13 | 5. Who are Bob's children? 14 | parent(bob,X). 15 | 16 | 6. Find X and Y such that X is a parent of Y 17 | parent(X,Y). 18 | 19 | 7. Who is a grandparent of Jim? 20 | parent( Y, jim), parent( X, Y). 21 | parent( X, Y),parent( Y, jim). 22 | 23 | 8. Who are Tom's grandchildren? 24 | parent( tomn X), parent( X, Y). 25 | 26 | 9. Do Ann and Pat have a common parent? 27 | parent( X, ann), parent( X, pat). -------------------------------------------------------------------------------- /facts_atoms_vars/code.pl: -------------------------------------------------------------------------------- 1 | parent(pam,bob). 2 | parent(tom,bob). 3 | parent(tom,liz). 4 | parent(bob,ann). 5 | parent(bob,pat). 6 | parent(pat,jim). 7 | 8 | -------------------------------------------------------------------------------- /insertion_sort/discussion.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/insertion_sort/discussion.pdf -------------------------------------------------------------------------------- /merge_sort_intro/divide_conquer-diagram.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/merge_sort_intro/divide_conquer-diagram.jpg -------------------------------------------------------------------------------- /merge_sort_intro/lecture.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/merge_sort_intro/lecture.pdf -------------------------------------------------------------------------------- /plotly_deep_learning_app/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.10 2 | 3 | ENV APP_HOME /app 4 | WORKDIR $APP_HOME 5 | COPY . ./ 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | EXPOSE 8080 10 | 11 | CMD python app.py -------------------------------------------------------------------------------- /plotly_deep_learning_app/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | import dash_bootstrap_components as dbc 3 | from dash import html 4 | import dash_uploader as du 5 | import os 6 | 7 | 8 | app = dash.Dash(__name__,use_pages=True,external_stylesheets=[dbc.themes.UNITED, dbc.icons.BOOTSTRAP],suppress_callback_exceptions=True) 9 | server = app.server 10 | 11 | UPLOAD_FOLDER_ROOT = os.path.join(os.path.dirname(__file__),"uploads") 12 | du.configure_upload(app, UPLOAD_FOLDER_ROOT) 13 | 14 | app.layout = html.Div(children=[ 15 | dash.page_container 16 | ]) 17 | 18 | 19 | if __name__ == "__main__": 20 | app.run_server(debug=True) 21 | #app.run_server(debug=False,host="0.0.0.0",port=8080) 22 | 23 | -------------------------------------------------------------------------------- /plotly_deep_learning_app/apps/__pycache__/home.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/apps/__pycache__/home.cpython-39.pyc -------------------------------------------------------------------------------- /plotly_deep_learning_app/apps/__pycache__/polls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/apps/__pycache__/polls.cpython-39.pyc -------------------------------------------------------------------------------- /plotly_deep_learning_app/apps/__pycache__/polls_results.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/apps/__pycache__/polls_results.cpython-39.pyc -------------------------------------------------------------------------------- /plotly_deep_learning_app/apps/__pycache__/showcase.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/apps/__pycache__/showcase.cpython-39.pyc -------------------------------------------------------------------------------- /plotly_deep_learning_app/apps/navigation.py: -------------------------------------------------------------------------------- 1 | import dash_bootstrap_components as dbc 2 | #import dash_html_components as html 3 | from dash import html 4 | #from app import app 5 | from dash.dependencies import Input, Output, State 6 | import dash 7 | 8 | # navbar = dbc.NavbarSimple( 9 | # children=[ 10 | # dbc.NavItem(dbc.NavLink("Home", href="/")), 11 | # dbc.NavItem(dbc.NavLink("Model Showcase", href="/showcase")), 12 | # dbc.DropdownMenu( 13 | # children=[ 14 | # dbc.DropdownMenuItem("More pages", header=True), 15 | # dbc.DropdownMenuItem("Model Showcase", href="/showcase") 16 | # ], 17 | # nav=True, 18 | # in_navbar=True, 19 | # label="More", 20 | # ), 21 | # ], 22 | # brand="Plotly Deep Learning App", 23 | # brand_href="/", 24 | # color="primary", 25 | # dark=True, 26 | # fluid=True, 27 | # links_left=True, 28 | # sticky='Top' 29 | # ) 30 | 31 | navbar = dbc.Navbar( 32 | dbc.Container( 33 | [ 34 | dbc.Row([ 35 | dbc.Col([ 36 | html.Img(src=dash.get_asset_url('logo2.png'), height="40px"), 37 | dbc.NavbarBrand("Plotly Deep Learning App", className="ms-2") 38 | ], 39 | width={"size":"auto"}) 40 | ], 41 | align="center", 42 | className="g-0"), 43 | 44 | dbc.Row([ 45 | dbc.Col([ 46 | dbc.Nav([ 47 | dbc.NavItem(dbc.NavLink("Home", href="/")), 48 | #dbc.NavItem(dbc.NavLink("Fundamentals", href="/fundamentals")), 49 | dbc.NavItem(dbc.DropdownMenu( 50 | children=[ 51 | dbc.DropdownMenuItem("How neural network learns", href="/hownnlearns") 52 | ], 53 | nav=True, 54 | in_navbar=True, 55 | label="Fundamentals", 56 | )), 57 | dbc.NavItem(dbc.NavLink("Model Showcase", href="/showcase/models")), 58 | dbc.NavItem(dbc.DropdownMenu( 59 | children=[ 60 | dbc.DropdownMenuItem("More pages", header=True), 61 | dbc.DropdownMenuItem("Model Showcase", href="/showcase/models") 62 | ], 63 | nav=True, 64 | in_navbar=True, 65 | label="More", 66 | )) 67 | ], 68 | navbar=True 69 | ) 70 | ], 71 | width={"size":"auto"}) 72 | ], 73 | align="center"), 74 | dbc.Col(dbc.NavbarToggler(id="navbar-toggler", n_clicks=0)), 75 | 76 | dbc.Row([ 77 | dbc.Col( 78 | dbc.Collapse( 79 | dbc.Nav([ 80 | dbc.NavItem(dbc.NavLink(html.I(className="bi bi-github"), href="https://github.com/siddharthajuprod07/algorithms/tree/master/plotly_deep_learning_app",external_link=True) ), 81 | dbc.NavItem(dbc.NavLink(html.I(className="bi bi bi-twitter"), href="https://twitter.com/splunk_ml",external_link=True) ), 82 | dbc.NavItem(dbc.NavLink(html.I(className="bi bi-youtube"), href="https://www.youtube.com/channel/UC7J8myLv3tPabjeocxKQQKw",external_link=True) ), 83 | dbc.Input(type="search", placeholder="Search"), 84 | dbc.Button( "Search", color="primary", className="ms-2", n_clicks=0 ), 85 | ] 86 | ), 87 | id="navbar-collapse", 88 | is_open=False, 89 | navbar=True 90 | ) 91 | ) 92 | ], 93 | align="center") 94 | ], 95 | fluid=True 96 | ), 97 | color="primary", 98 | dark=True 99 | ) 100 | 101 | 102 | @dash.callback( 103 | Output("navbar-collapse", "is_open"), 104 | [Input("navbar-toggler", "n_clicks")], 105 | [State("navbar-collapse", "is_open")], 106 | ) 107 | def toggle_navbar_collapse(n, is_open): 108 | if n: 109 | return not is_open 110 | return is_open -------------------------------------------------------------------------------- /plotly_deep_learning_app/assets/404.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/assets/404.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/assets/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/assets/logo2.png -------------------------------------------------------------------------------- /plotly_deep_learning_app/assets/styles.css: -------------------------------------------------------------------------------- 1 | .bg { 2 | /* The image used */ 3 | background-image: url("/assets/404.jpg"); 4 | 5 | /* Full height */ 6 | height: 100vh; 7 | width: 100wh; 8 | 9 | /* Center and scale the image nicely */ 10 | background-position: center; 11 | background-repeat: no-repeat; 12 | background-size: cover; 13 | } 14 | 15 | 16 | #home_btn_404 { 17 | position:absolute; 18 | margin-left:-50px; 19 | left:50%; 20 | bottom:50px; 21 | } -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/apple.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/apple.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/banana.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/banana.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/bear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/bear.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/bear1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/bear1.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/cat.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/charlyn chaplin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/charlyn chaplin.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/chikku.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/chikku.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/chikku1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/chikku1.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/fish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/fish.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/datasets/images/tiger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/plotly_deep_learning_app/datasets/images/tiger.jpg -------------------------------------------------------------------------------- /plotly_deep_learning_app/index.py: -------------------------------------------------------------------------------- 1 | 2 | # #import dash_html_components as html 3 | # from dash import html 4 | # #import dash_core_components as dcc 5 | # from dash import dcc 6 | # from dash.dependencies import Input, Output 7 | 8 | # from app import app 9 | # from apps import home, hownnlearns, showcase 10 | 11 | # url_content_layout = html.Div(children=[ 12 | # dcc.Location(id="url",refresh=False), 13 | # html.Div(id="output-div") 14 | # ]) 15 | 16 | # app.layout = url_content_layout 17 | 18 | # app.validation_layout = html.Div([ 19 | # url_content_layout, 20 | # home.home_layout, 21 | # showcase.model_showcase_layout, 22 | # hownnlearns.dl_content 23 | # ]) 24 | 25 | 26 | # @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 27 | # def update_output_div(pathname): 28 | # if pathname == "/showcase": 29 | # return showcase.model_showcase_layout 30 | # elif pathname == "/hownnlearns": 31 | # return hownnlearns.page_layout 32 | # else: 33 | # return home.home_layout 34 | 35 | 36 | # if __name__ == "__main__": 37 | # app.run_server(debug=True) -------------------------------------------------------------------------------- /plotly_deep_learning_app/pages/home.py: -------------------------------------------------------------------------------- 1 | 2 | #import dash_html_components as html 3 | from dash import html 4 | #import dash_core_components as dcc 5 | from dash import dcc 6 | from dash.dependencies import Input, Output 7 | from apps import navigation 8 | import dash 9 | 10 | dash.register_page(__name__,path='/',title="Plotly deep learning app",description="Deep learning simplified",image='logo2.png') 11 | 12 | layout = html.Div(children=[ 13 | navigation.navbar, 14 | html.H3(children="Welcome to Deep Learning Dash app!"), 15 | # dcc.Link('Home',href="/"), 16 | # html.Br(), 17 | # dcc.Link('model-showcase',href="/showcase") 18 | ]) -------------------------------------------------------------------------------- /plotly_deep_learning_app/pages/hownnlearns.py: -------------------------------------------------------------------------------- 1 | #import dash_html_components as html 2 | from dash import html 3 | #import dash_core_components as dcc 4 | from dash import dcc, ctx 5 | from dash.dependencies import Input, Output, State 6 | from apps import navigation 7 | import dash_bootstrap_components as dbc 8 | #from app import app 9 | import dash 10 | import tensorflow as tf 11 | import numpy as np 12 | import plotly.express as px 13 | import json 14 | import random 15 | import dash_mantine_components as dmc 16 | 17 | dash.register_page(__name__,path='/hownnlearns',title="How neural network learns",description="How neural network learns",image='logo2.png') 18 | 19 | breadcrumb=dbc.Container( 20 | dbc.Row( 21 | dbc.Col( 22 | dbc.Breadcrumb( 23 | items=[ 24 | {"label": "Home", "href": "/", "external_link": False}, 25 | { 26 | "label": "Fundamentals" 27 | }, 28 | {"label": "How Neural network Learns", "active": True}, 29 | ], 30 | ) 31 | ) 32 | ), 33 | fluid=True 34 | ) 35 | 36 | initial_paragraph_content = dbc.Container([ 37 | dbc.Row([ 38 | dbc.Col([ 39 | html.H3(html.B("How Neural Network Learns :")) 40 | ]) 41 | ]), 42 | dbc.Row([ 43 | dbc.Col([ 44 | html.P('''In this page we will learn how a neural network learns through an interactive way. We will take the MNIST dataset and try to classifiy the handwritten digits, 45 | while doing that we will try visualize each and every step and try to understand the math behind it. 46 | This problem is also called the "Hello World" problem of Deep learning.''') 47 | ]) 48 | ]), 49 | ], 50 | fluid=True) 51 | 52 | 53 | dl_content = dbc.Container([ 54 | dbc.Row([ 55 | dbc.Col( 56 | [ 57 | html.Div( 58 | dbc.Accordion( 59 | [ 60 | dbc.AccordionItem( 61 | [ 62 | html.Div(id="visualize_mnist_dataset_div") 63 | ], 64 | title="Step1 : Visualize MNIST dataset", 65 | item_id="visualize_mnist_dataset" 66 | ), 67 | dbc.AccordionItem( 68 | [ 69 | html.Div(id="training_mnist_div") 70 | ], 71 | title="Step2: Model Training", 72 | item_id="training_mnist" 73 | ), 74 | dbc.AccordionItem( 75 | [ 76 | html.Div(id="testing_mnist_div") 77 | ], 78 | title="Step2: Model Testing", 79 | item_id="testing_mnist" 80 | ), 81 | ], 82 | flush=True, 83 | start_collapsed= True, 84 | id="dl_accordion" 85 | ), 86 | ) 87 | ] 88 | ) 89 | ]) 90 | ], 91 | fluid=True) 92 | 93 | layout = html.Div([ 94 | navigation.navbar, 95 | breadcrumb, 96 | initial_paragraph_content, 97 | dl_content 98 | ] 99 | ) 100 | 101 | ## Callback to update accordion panel items content 102 | @dash.callback( 103 | [Output("visualize_mnist_dataset_div","children"), 104 | Output("training_mnist_div","children"), 105 | Output("testing_mnist_div","children")], 106 | [Input("dl_accordion","active_item")] 107 | ) 108 | def update_accordion_items(accordion_item): 109 | visualize_mnist = "" 110 | training_mnist ="" 111 | testing_mnist = "" 112 | (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() 113 | if accordion_item == "visualize_mnist_dataset": 114 | #visualize_mnist = "This is the content for MNIST viz" 115 | train_image_labels, train_image_counts = np.unique(y_train, return_counts=True) 116 | test_image_labels, test_image_counts = np.unique(y_test, return_counts=True) 117 | training_fig = px.pie(names=train_image_labels,values=train_image_counts,hole=0.3) 118 | training_fig.update_layout(annotations=[dict(text=str(len(y_train)),x=0.5, y=0.5,font_size = 20, showarrow=False)]) 119 | testing_fig = px.pie(names=test_image_labels,values=test_image_counts,hole=0.3) 120 | testing_fig.update_layout(annotations=[dict(text=str(len(y_test)),x=0.5, y=0.5,font_size = 20, showarrow=False)]) 121 | card_content_training = [ 122 | dbc.CardHeader("Training dataset distribution"), 123 | dbc.CardBody( 124 | [ 125 | dcc.Graph(figure=training_fig, id="training_fig") 126 | ] 127 | ), 128 | ] 129 | card_content_testing = [ 130 | dbc.CardHeader("Testing dataset distribution"), 131 | dbc.CardBody( 132 | [ 133 | dcc.Graph(figure=testing_fig, id="testing_fig") 134 | ] 135 | ), 136 | ] 137 | # card_label_img_display = [ 138 | # dbc.CardHeader("Click on the donut chart to display image (choosen randomly)"), 139 | # dbc.CardBody( 140 | # [ 141 | # html.Div(id="clicked_label_img_div") 142 | # ] 143 | # ), 144 | # ] 145 | visualize_mnist = dbc.Container([ 146 | dbc.Row([ 147 | dbc.Col([ 148 | dbc.Card(card_content_training,color="primary",outline=True) 149 | ], 150 | width={"size":"6"}), 151 | dbc.Col([ 152 | dbc.Card(card_content_testing,color="primary",outline=True) 153 | ], 154 | width={"size":"6"}), 155 | ]), 156 | dbc.Row([ 157 | dbc.Col([ 158 | html.Br() 159 | ]) 160 | ]), 161 | dbc.Row([ 162 | dbc.Col([ 163 | html.Div(id="clicked_label_img_div") 164 | #dbc.Card(card_label_img_display,color="primary",outline=True) 165 | ]) 166 | ]) 167 | ]) 168 | if accordion_item == "training_mnist": 169 | training_mnist = html.Div(children=[ 170 | dbc.Container(children=[ 171 | dbc.Row(children=[ 172 | dmc.ChipGroup( 173 | [dmc.Chip(x, value=x) for x in ["Single Neuron", "Neural Network"]], 174 | value="Single Neuron", 175 | id="training_chip_group" 176 | ) 177 | ]), 178 | dbc.Row(children=[ 179 | html.Div(id="training_chips_content") 180 | ]) 181 | ],fluid=True) 182 | 183 | ]) 184 | if accordion_item == "testing_mnist": 185 | testing_mnist = "This is the content for Model testing" 186 | return visualize_mnist,training_mnist,testing_mnist 187 | 188 | 189 | ## callback for drilldown 190 | @dash.callback( 191 | [Output("clicked_label_img_div","children")], 192 | [Input("training_fig","clickData"), 193 | Input("testing_fig","clickData")], 194 | prevent_initial_call=True 195 | ) 196 | def render_label_img(drilldown_data_training,drilldown_data_testing): 197 | callback_source= ctx.triggered_id 198 | source_dataset= "" 199 | print(callback_source) 200 | (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() # Will fix it later 201 | if callback_source == "training_fig": 202 | source_dataset = "Training" 203 | clicked_label = drilldown_data_training["points"][0]["label"] 204 | possible_indices = np.where(y_train == int(clicked_label)) 205 | choosen_index = np.random.choice(possible_indices[0]) 206 | fig = px.imshow(x_train[choosen_index]) 207 | if callback_source == "testing_fig": 208 | source_dataset = "Testing" 209 | clicked_label = drilldown_data_testing["points"][0]["label"] 210 | possible_indices = np.where(y_test == int(clicked_label)) 211 | choosen_index = np.random.choice(possible_indices[0]) 212 | fig = px.imshow(x_test[choosen_index]) 213 | 214 | card_label_img_display = [ 215 | dbc.CardHeader("Source Dataset : {}, clicked Image : {}, chosen index : {}".format(source_dataset,clicked_label,choosen_index)), 216 | dbc.CardBody( 217 | [ 218 | dcc.Graph(figure=fig) 219 | ] 220 | ), 221 | ] 222 | return [dbc.Card(card_label_img_display,color="primary",outline=True)] 223 | 224 | 225 | ## callback for drilldown 226 | @dash.callback( 227 | Output("training_chips_content","children"), 228 | Input("training_chip_group","value"), 229 | ) 230 | def render_chipgroup_item_content(selected_chip): 231 | training_chips_div_content = [] 232 | if selected_chip == "Single Neuron": 233 | training_chips_div_content = html.Div(children=[ 234 | dbc.Container(children=[ 235 | dbc.Row(children=[ 236 | dbc.Col(children=[ 237 | dmc.Stack( 238 | [ 239 | html.Div(children=[ 240 | dbc.Label("Choose activation"), 241 | dbc.RadioItems( 242 | options=[ 243 | {"label": "Perceptron", "value": "step"}, 244 | {"label": "Sigmoid function", "value": "sigmoid"}, 245 | {"label": "RELU function", "value": "relu"}, 246 | {"label": "tanh function", "value": "tanh"}, 247 | ], 248 | value="step", 249 | id="activation-radioitems-input", 250 | ), 251 | ]), 252 | dbc.InputGroup( 253 | [dbc.InputGroupText("X1"), dbc.Input(placeholder="",id="x1",value=0), 254 | dbc.InputGroupText("W1"), dbc.Input(placeholder="",id="w1",value=0)], 255 | className="mb-3", 256 | ), 257 | dbc.InputGroup( 258 | [dbc.InputGroupText("X2"), dbc.Input(placeholder="",id="x2",value=0), 259 | dbc.InputGroupText("W2"), dbc.Input(placeholder="",id="w2",value=0)], 260 | className="mb-3", 261 | ), 262 | dbc.InputGroup( 263 | [dbc.InputGroupText("X3"), dbc.Input(placeholder="",id="x3",value=0), 264 | dbc.InputGroupText("W3"), dbc.Input(placeholder="",id="w3",value=0)], 265 | className="mb-3", 266 | ), 267 | dbc.InputGroup( 268 | [dbc.InputGroupText("b"), dbc.Input(placeholder="",id="b",value=0)], 269 | className="mb-3", 270 | ), 271 | dbc.Button("Run", color="success", className="me-1",id="run_btn"), 272 | 273 | ], 274 | align="left", 275 | spacing="sm", 276 | ) 277 | ],width=2), 278 | dbc.Col(children=[ 279 | html.Div(id="activation_function_equation_div",children=[]), 280 | html.Div(id="activation_function_graph_div",children=[]) 281 | ],width=4), 282 | dbc.Col(children=[],width=6), 283 | ],justify="center",align="center") 284 | ],fluid=True) 285 | ],style={"margin":"20px"}) 286 | elif selected_chip == "Neural Network": 287 | training_chips_div_content = [] 288 | return training_chips_div_content 289 | 290 | 291 | ## Callback for the run button 292 | @dash.callback( 293 | Output("activation_function_equation_div","children"), 294 | Input("run_btn","n_clicks"), 295 | State("activation-radioitems-input","value"), 296 | prevent_initial_call=True 297 | ) 298 | def handle_run_btn(n,activation_func): 299 | activation_func_equation_div_content = [] 300 | if n: 301 | if activation_func == "step": 302 | activation_func_equation_div_content = html.Div(children=[ 303 | dcc.Markdown(''' 304 | $$ 305 | H(x) = \\begin{cases}1&(x\\geqq 0)\\\\0&(x\\lt 0)\\end{cases} 306 | $$ 307 | 308 | ''',mathjax=True) 309 | ]) 310 | elif activation_func == "sigmoid": 311 | activation_func_equation_div_content = html.Div(children=[ 312 | dcc.Markdown(''' 313 | $$ 314 | f(x) = \\frac{1}{1+e^{-x}} 315 | $$ 316 | 317 | ''',mathjax=True) 318 | ]) 319 | elif activation_func == "relu": 320 | activation_func_equation_div_content = activation_func_equation_div_content = html.Div(children=[ 321 | dcc.Markdown(''' 322 | $$ 323 | f(x) = \\max(0,x) 324 | $$ 325 | 326 | ''',mathjax=True) 327 | ]) 328 | elif activation_func == "tanh": 329 | activation_func_equation_div_content = activation_func_equation_div_content = activation_func_equation_div_content = html.Div(children=[ 330 | dcc.Markdown(''' 331 | $$ 332 | tanh(x) = \\frac{sinh(x)}{cosh(x)} = \\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} 333 | $$ 334 | 335 | ''',mathjax=True) 336 | ]) 337 | return activation_func_equation_div_content 338 | 339 | -------------------------------------------------------------------------------- /plotly_deep_learning_app/pages/not_found_404.py: -------------------------------------------------------------------------------- 1 | from dash import html 2 | import dash 3 | import dash_bootstrap_components as dbc 4 | 5 | dash.register_page(__name__,title="Page not found") 6 | 7 | layout =html.Div(children=[ 8 | dbc.Button("Go back to Home", size="lg", id="home_btn_404",href="/"), 9 | ],className="bg") 10 | 11 | 12 | -------------------------------------------------------------------------------- /plotly_deep_learning_app/pages/showcase.py: -------------------------------------------------------------------------------- 1 | #import dash_html_components as html 2 | from dash import html 3 | #import dash_core_components as dcc 4 | from dash import dcc 5 | from dash.dependencies import Input, Output 6 | import dash_bootstrap_components as dbc 7 | import pandas as pd 8 | import os 9 | #from app import app 10 | import tensorflow as tf 11 | from tensorflow.keras.applications.resnet50 import decode_predictions,preprocess_input 12 | from tensorflow.keras import utils 13 | import numpy as np 14 | from dash import dash_table 15 | from apps import navigation 16 | import dash 17 | import dash_uploader as du 18 | import uuid 19 | 20 | dash.register_page(__name__,path_template='/showcase/',title="Deep learning models") 21 | 22 | # IMAGE_DATASET_HOME = os.path.join(os.path.dirname(__file__),'..','datasets','images') 23 | # imagefiles_list = [f for f in os.listdir(IMAGE_DATASET_HOME) if os.path.isfile(os.path.join(IMAGE_DATASET_HOME,f))] 24 | upload_id = uuid.uuid1() 25 | 26 | # layout = html.Div(children=[ 27 | # navigation.navbar, 28 | # # html.H1(children="This is model showcase page"), 29 | # # dcc.Link('Home',href="/"), 30 | # html.Br(), 31 | # html.H3(children="1. Classify image using resnet50"), 32 | # html.Div([ 33 | # "Select an Image:", 34 | # dcc.Dropdown(id="image-dropdown", 35 | # options=[{'label': i, 'value': os.path.join(IMAGE_DATASET_HOME,i)} for i in imagefiles_list]) 36 | # ]), 37 | # html.Div(id="output-image-upload") 38 | # ]) 39 | 40 | def layout(model_id=None): 41 | showcase_page_layout = "" 42 | if model_id == "resnet50": 43 | showcase_page_layout = html.Div(children=[ 44 | navigation.navbar, 45 | # html.H1(children="This is model showcase page"), 46 | # dcc.Link('Home',href="/"), 47 | html.Br(), 48 | html.Div(children=[ 49 | html.H3(children="1. Classify image using resnet50"), 50 | # html.Div([ 51 | # "Select an Image:", 52 | # dcc.Dropdown(id="image-dropdown", 53 | # options=[{'label': i, 'value': os.path.join(IMAGE_DATASET_HOME,i)} for i in imagefiles_list]) 54 | # ]), 55 | du.Upload( 56 | id='resnet50-image-uploader', 57 | text='Drag and Drop Here to upload!', 58 | text_completed='Uploaded: ', 59 | text_disabled='The uploader is disabled.', 60 | cancel_button=True, 61 | pause_button=True, 62 | disabled=False, 63 | filetypes=['jpg','mp4'], 64 | default_style = { 65 | 'width': '100%', 66 | 'height': '30px', 67 | 'lineHeight': '60px', 68 | 'borderWidth': '2px', 69 | 'borderStyle': 'dashed', 70 | 'borderRadius': '5px', 71 | 'textAlign': 'center', 72 | 'margin': '0px', 73 | 'margin-bottom' : '10px', 74 | 'color' : 'green' 75 | }, 76 | upload_id=upload_id, 77 | max_files=5 78 | ), 79 | dbc.Button("Classify", color="warning", className="me-1",id="resnet50-image-classify-btn"), 80 | html.Div(id="output-image-upload") 81 | ],style={"margin":"10px"}), 82 | ], 83 | ) 84 | elif model_id == "mnist": 85 | showcase_page_layout = html.Div(children=[ 86 | navigation.navbar, 87 | html.Br(), 88 | html.H3(children="This is mnist model page. Work in Progress..."), 89 | ]) 90 | elif model_id == "models": 91 | showcase_page_layout = html.Div(children=[ 92 | navigation.navbar, 93 | html.Br(), 94 | dcc.Link(children="resnet50",href="/showcase/resnet50"), 95 | html.Br(), 96 | dcc.Link(children="mnist",href="/showcase/mnist"), 97 | ]) 98 | return showcase_page_layout 99 | 100 | 101 | @dash.callback(Output("output-image-upload","children"), 102 | Input("resnet50-image-classify-btn","n_clicks")) 103 | def update_output(n): 104 | if n: 105 | image_root_path = os.path.join(os.path.dirname(__file__),"..","uploads",str(upload_id)) 106 | returned_div = [] 107 | for file in os.listdir(image_root_path): 108 | model = tf.keras.applications.resnet50.ResNet50() 109 | image_name = os.path.join(image_root_path,file) 110 | img = utils.load_img(image_name,target_size=(224,224)) 111 | img_array = utils.img_to_array(img) 112 | img_batch = np.expand_dims(img_array,axis=0) 113 | img_preprocessed = preprocess_input(img_batch) 114 | img_prediction = model.predict(img_preprocessed) 115 | decode_img_prediction = decode_predictions(img_prediction,top=3) 116 | print(decode_img_prediction) 117 | predicted_dict = {} 118 | for di in decode_img_prediction[0]: 119 | predicted_dict[di[1]] = di[2] 120 | returned_div.append(html.Div([#html.H5(image_name), 121 | html.Hr(), 122 | html.Img(src=img), 123 | html.Div([dash_table.DataTable([predicted_dict])]) 124 | ])) 125 | return returned_div 126 | 127 | -------------------------------------------------------------------------------- /plotly_deep_learning_app/requirements.txt: -------------------------------------------------------------------------------- 1 | dash 2 | dash-core-components 3 | dash-html-components 4 | dash-table 5 | tensorflow 6 | dash-bootstrap-components 7 | pandas 8 | pillow 9 | dash-uploader 10 | dash_mantine_components 11 | -------------------------------------------------------------------------------- /problem_solving_1/Question_1.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Aug 30 09:30:47 2019 4 | 5 | @author: siddh 6 | """ 7 | n=2 8 | while 2 ** n < n ** 8 : 9 | print(n) 10 | n += 1 -------------------------------------------------------------------------------- /problem_solving_1/Question_2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Aug 30 09:37:37 2019 4 | 5 | @author: siddh 6 | """ 7 | 8 | n=1 9 | 10 | while True: 11 | if 100 * (n ** 2) < 2 ** n: 12 | print(n) 13 | break 14 | n += 1 -------------------------------------------------------------------------------- /problem_solving_1/problem_solving_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/problem_solving_1/problem_solving_1.pdf -------------------------------------------------------------------------------- /prolog_intro/Prolog_Intro.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/prolog_intro/Prolog_Intro.jpg -------------------------------------------------------------------------------- /prolog_problem_solving_1/code.pl: -------------------------------------------------------------------------------- 1 | parent(pam,bob). 2 | parent(tom,bob). 3 | parent(tom,liz). 4 | parent(bob,ann). 5 | parent(bob,pat). 6 | parent(pat,jim). 7 | 8 | -------------------------------------------------------------------------------- /prolog_problem_solving_1/problems.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/prolog_problem_solving_1/problems.pdf -------------------------------------------------------------------------------- /splunk_nlp.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/splunk_nlp.tar.gz -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | # import dash_html_components as html 3 | # import dash_core_components as dcc 4 | # from dash.dependencies import Input, Output 5 | 6 | 7 | 8 | app = dash.Dash(__name__) 9 | server = app.server 10 | 11 | # url_content_layout = html.Div(children=[ 12 | # dcc.Location(id="url",refresh=False), 13 | # html.Div(id="output-div") 14 | # ]) 15 | 16 | # app.layout = url_content_layout 17 | 18 | # home_layout = html.Div(children=[ 19 | # html.H1(children="Welcome to the dash Polling app!"), 20 | # dcc.Link('Home',href="/"), 21 | # html.Br(), 22 | # dcc.Link('Polls',href="/polls"), 23 | # html.Br(), 24 | # dcc.Link('Poll Results',href="/poll-results") 25 | # ]) 26 | 27 | # polls_layout = html.Div(children=[ 28 | # html.H1(children="This is Polls page"), 29 | # dcc.Link('Home',href="/"), 30 | # html.Br(), 31 | # html.Br(), 32 | # html.Div([ 33 | # "Select a Poll:", 34 | # dcc.Dropdown(id="polls-name-dropdown", 35 | # options=[{'label': i, 'value': i} for i in ["Poll1","Poll2", "Poll3"]]) 36 | # ]), 37 | # html.Br(), 38 | # html.Br(), 39 | # html.Div(id="polls-question-div") 40 | 41 | # ]) 42 | 43 | # polls_results_layout = html.Div(children=[ 44 | # html.H1(children="This is Poll Results page"), 45 | # dcc.Link('Home',href="/") 46 | # ]) 47 | 48 | # app.validation_layout = html.Div([ 49 | # url_content_layout, 50 | # home_layout, 51 | # polls_layout, 52 | # polls_results_layout 53 | # ]) 54 | 55 | # @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 56 | # def update_output_div(pathname): 57 | # if pathname == "/polls": 58 | # return polls_layout 59 | # elif pathname == "/poll-results": 60 | # return polls_results_layout 61 | # else: 62 | # return home_layout 63 | 64 | 65 | # @app.callback(Output(component_id="polls-question-div",component_property="children"),Input(component_id="polls-name-dropdown",component_property="value")) 66 | # def display_poll_question(pollname): 67 | # poll_question_df = pd.read_csv(os.path.join(os.path.dirname(__file__),'datasets','polls.csv')) 68 | # #print(poll_question_df) 69 | # poll_question_filtered_df = poll_question_df.loc[poll_question_df["poll_name"] == str(pollname)] 70 | # question_input = None 71 | # if not poll_question_filtered_df.empty: 72 | # question_input = html.Div([ 73 | # dbc.Label(poll_question_filtered_df["question_text"]), 74 | # dbc.RadioItems( 75 | # options=[ 76 | # {"label": poll_question_filtered_df["option1"], "value": 1}, 77 | # {"label": poll_question_filtered_df["option2"], "value": 2}, 78 | # {"label": poll_question_filtered_df["option3"], "value": 3}, 79 | # {"label": poll_question_filtered_df["option4"], "value": 4} 80 | # ], 81 | # value=1, 82 | # id="radioitems-input", 83 | # ), 84 | # ]) 85 | # question_div = html.Div([ 86 | # dbc.Form([question_input]) 87 | # ]) 88 | 89 | # return question_div 90 | 91 | 92 | # if __name__ == "__main__": 93 | # app.run_server(debug=True) -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/apps/__pycache__/home.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/structuring_dash_apps_part1/polling_app/apps/__pycache__/home.cpython-39.pyc -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/apps/__pycache__/polls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/structuring_dash_apps_part1/polling_app/apps/__pycache__/polls.cpython-39.pyc -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/apps/__pycache__/polls_results.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthajuprod07/algorithms/7fb30152568baa020411688e0865c03a299243e2/structuring_dash_apps_part1/polling_app/apps/__pycache__/polls_results.cpython-39.pyc -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/apps/home.py: -------------------------------------------------------------------------------- 1 | 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | 6 | 7 | 8 | home_layout = html.Div(children=[ 9 | html.H1(children="Welcome to the dash Polling app!"), 10 | dcc.Link('Home',href="/"), 11 | html.Br(), 12 | dcc.Link('Polls',href="/polls"), 13 | html.Br(), 14 | dcc.Link('Poll Results',href="/poll-results") 15 | ]) -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/apps/polls.py: -------------------------------------------------------------------------------- 1 | import dash_html_components as html 2 | import dash_core_components as dcc 3 | from dash.dependencies import Input, Output 4 | import dash_bootstrap_components as dbc 5 | import pandas as pd 6 | import os 7 | 8 | from app import app 9 | 10 | 11 | 12 | polls_layout = html.Div(children=[ 13 | html.H1(children="This is Polls page"), 14 | dcc.Link('Home',href="/"), 15 | html.Br(), 16 | html.Br(), 17 | html.Div([ 18 | "Select a Poll:", 19 | dcc.Dropdown(id="polls-name-dropdown", 20 | options=[{'label': i, 'value': i} for i in ["Poll1","Poll2", "Poll3"]]) 21 | ]), 22 | html.Br(), 23 | html.Br(), 24 | html.Div(id="polls-question-div") 25 | 26 | ]) 27 | 28 | 29 | @app.callback(Output(component_id="polls-question-div",component_property="children"),Input(component_id="polls-name-dropdown",component_property="value")) 30 | def display_poll_question(pollname): 31 | poll_question_df = pd.read_csv(os.path.join(os.path.dirname(__file__),'..','datasets','polls.csv')) 32 | #print(poll_question_df) 33 | poll_question_filtered_df = poll_question_df.loc[poll_question_df["poll_name"] == str(pollname)] 34 | question_input = None 35 | if not poll_question_filtered_df.empty: 36 | question_input = html.Div([ 37 | dbc.Label(poll_question_filtered_df["question_text"]), 38 | dbc.RadioItems( 39 | options=[ 40 | {"label": poll_question_filtered_df["option1"], "value": 1}, 41 | {"label": poll_question_filtered_df["option2"], "value": 2}, 42 | {"label": poll_question_filtered_df["option3"], "value": 3}, 43 | {"label": poll_question_filtered_df["option4"], "value": 4} 44 | ], 45 | value=1, 46 | id="radioitems-input", 47 | ), 48 | ]) 49 | question_div = html.Div([ 50 | dbc.Form([question_input]) 51 | ]) 52 | 53 | return question_div -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/apps/polls_results.py: -------------------------------------------------------------------------------- 1 | import dash_html_components as html 2 | import dash_core_components as dcc 3 | from dash.dependencies import Input, Output 4 | 5 | 6 | polls_results_layout = html.Div(children=[ 7 | html.H1(children="This is Poll Results page"), 8 | dcc.Link('Home',href="/") 9 | ]) -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/datasets/polls.csv: -------------------------------------------------------------------------------- 1 | poll_name,question_text,option1,option2,option3,option4 2 | Poll1,What is your age?,Under 18,18-44,45-54,Above 54 3 | Poll2,What is your favourite movie?,Schindler's List,12 Angry Men,Pulp Fiction, Forrest Gump -------------------------------------------------------------------------------- /structuring_dash_apps_part1/polling_app/index.py: -------------------------------------------------------------------------------- 1 | 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | 6 | from app import app 7 | from apps import home,polls,polls_results 8 | 9 | url_content_layout = html.Div(children=[ 10 | dcc.Location(id="url",refresh=False), 11 | html.Div(id="output-div") 12 | ]) 13 | 14 | app.layout = url_content_layout 15 | 16 | app.validation_layout = html.Div([ 17 | url_content_layout, 18 | home.home_layout, 19 | polls.polls_layout, 20 | polls_results.polls_results_layout 21 | ]) 22 | 23 | 24 | @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 25 | def update_output_div(pathname): 26 | if pathname == "/polls": 27 | return polls.polls_layout 28 | elif pathname == "/poll-results": 29 | return polls_results.polls_results_layout 30 | else: 31 | return home.home_layout 32 | 33 | 34 | if __name__ == "__main__": 35 | app.run_server(debug=True) -------------------------------------------------------------------------------- /structuring_dash_apps_part2/polling_app/app.py: -------------------------------------------------------------------------------- 1 | import dash 2 | # import dash_html_components as html 3 | # import dash_core_components as dcc 4 | # from dash.dependencies import Input, Output 5 | # import dash_bootstrap_components as dbc 6 | # import pandas as pd 7 | # import os 8 | 9 | 10 | app = dash.Dash(__name__) 11 | server = app.server 12 | 13 | # url_content_layout = html.Div(children=[ 14 | # dcc.Location(id="url",refresh=False), 15 | # html.Div(id="output-div") 16 | # ]) 17 | 18 | # app.layout = url_content_layout 19 | 20 | # home_layout = html.Div(children=[ 21 | # html.H1(children="Welcome to the dash Polling app!"), 22 | # dcc.Link('Home',href="/"), 23 | # html.Br(), 24 | # dcc.Link('Polls',href="/polls"), 25 | # html.Br(), 26 | # dcc.Link('Poll Results',href="/poll-results") 27 | # ]) 28 | 29 | # polls_layout = html.Div(children=[ 30 | # html.H1(children="This is Polls page"), 31 | # dcc.Link('Home',href="/"), 32 | # html.Br(), 33 | # html.Br(), 34 | # html.Div([ 35 | # "Select a Poll:", 36 | # dcc.Dropdown(id="polls-name-dropdown", 37 | # options=[{'label': i, 'value': i} for i in ["Poll1","Poll2", "Poll3"]]) 38 | # ]), 39 | # html.Br(), 40 | # html.Br(), 41 | # html.Div(id="polls-question-div") 42 | 43 | # ]) 44 | 45 | # polls_results_layout = html.Div(children=[ 46 | # html.H1(children="This is Poll Results page"), 47 | # dcc.Link('Home',href="/") 48 | # ]) 49 | 50 | # app.validation_layout = html.Div([ 51 | # url_content_layout, 52 | # home_layout, 53 | # polls_layout, 54 | # polls_results_layout 55 | # ]) 56 | 57 | # @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 58 | # def update_output_div(pathname): 59 | # if pathname == "/polls": 60 | # return polls_layout 61 | # elif pathname == "/poll-results": 62 | # return polls_results_layout 63 | # else: 64 | # return home_layout 65 | 66 | 67 | # @app.callback(Output(component_id="polls-question-div",component_property="children"),Input(component_id="polls-name-dropdown",component_property="value")) 68 | # def display_poll_question(pollname): 69 | # poll_question_df = pd.read_csv(os.path.join(os.path.dirname(__file__),'datasets','polls.csv')) 70 | # #print(poll_question_df) 71 | # poll_question_filtered_df = poll_question_df.loc[poll_question_df["poll_name"] == str(pollname)] 72 | # question_input = None 73 | # if not poll_question_filtered_df.empty: 74 | # question_input = html.Div([ 75 | # dbc.Label(poll_question_filtered_df["question_text"]), 76 | # dbc.RadioItems( 77 | # options=[ 78 | # {"label": poll_question_filtered_df["option1"], "value": 1}, 79 | # {"label": poll_question_filtered_df["option2"], "value": 2}, 80 | # {"label": poll_question_filtered_df["option3"], "value": 3}, 81 | # {"label": poll_question_filtered_df["option4"], "value": 4} 82 | # ], 83 | # value=1, 84 | # id="radioitems-input", 85 | # ), 86 | # ]) 87 | # question_div = html.Div([ 88 | # dbc.Form([question_input]) 89 | # ]) 90 | 91 | # return question_div 92 | 93 | 94 | # if __name__ == "__main__": 95 | # app.run_server(debug=True) -------------------------------------------------------------------------------- /structuring_dash_apps_part2/polling_app/callbacks.py: -------------------------------------------------------------------------------- 1 | 2 | import dash_html_components as html 3 | import dash_core_components as dcc 4 | from dash.dependencies import Input, Output 5 | import dash_bootstrap_components as dbc 6 | import pandas as pd 7 | import os 8 | 9 | 10 | from app import app 11 | 12 | 13 | @app.callback(Output(component_id="polls-question-div",component_property="children"),Input(component_id="polls-name-dropdown",component_property="value")) 14 | def display_poll_question(pollname): 15 | poll_question_df = pd.read_csv(os.path.join(os.path.dirname(__file__),'datasets','polls.csv')) 16 | #print(poll_question_df) 17 | poll_question_filtered_df = poll_question_df.loc[poll_question_df["poll_name"] == str(pollname)] 18 | question_input = None 19 | if not poll_question_filtered_df.empty: 20 | question_input = html.Div([ 21 | dbc.Label(poll_question_filtered_df["question_text"]), 22 | dbc.RadioItems( 23 | options=[ 24 | {"label": poll_question_filtered_df["option1"], "value": 1}, 25 | {"label": poll_question_filtered_df["option2"], "value": 2}, 26 | {"label": poll_question_filtered_df["option3"], "value": 3}, 27 | {"label": poll_question_filtered_df["option4"], "value": 4} 28 | ], 29 | value=1, 30 | id="radioitems-input", 31 | ), 32 | ]) 33 | question_div = html.Div([ 34 | dbc.Form([question_input]) 35 | ]) 36 | 37 | return question_div -------------------------------------------------------------------------------- /structuring_dash_apps_part2/polling_app/datasets/polls.csv: -------------------------------------------------------------------------------- 1 | poll_name,question_text,option1,option2,option3,option4 2 | Poll1,What is your age?,Under 18,18-44,45-54,Above 54 3 | Poll2,What is your favourite movie?,Schindler's List,12 Angry Men,Pulp Fiction, Forrest Gump -------------------------------------------------------------------------------- /structuring_dash_apps_part2/polling_app/index.py: -------------------------------------------------------------------------------- 1 | import dash_html_components as html 2 | import dash_core_components as dcc 3 | from dash.dependencies import Input, Output 4 | 5 | from app import app 6 | from layouts import home_layout,polls_layout,polls_results_layout 7 | import callbacks 8 | 9 | url_content_layout = html.Div(children=[ 10 | dcc.Location(id="url",refresh=False), 11 | html.Div(id="output-div") 12 | ]) 13 | 14 | app.validation_layout = html.Div([ 15 | url_content_layout, 16 | home_layout, 17 | polls_layout, 18 | polls_results_layout 19 | ]) 20 | 21 | app.layout = url_content_layout 22 | 23 | @app.callback(Output(component_id="output-div",component_property="children"),Input(component_id="url",component_property="pathname")) 24 | def update_output_div(pathname): 25 | if pathname == "/polls": 26 | return polls_layout 27 | elif pathname == "/poll-results": 28 | return polls_results_layout 29 | else: 30 | return home_layout 31 | 32 | if __name__ == "__main__": 33 | app.run_server(debug=True) -------------------------------------------------------------------------------- /structuring_dash_apps_part2/polling_app/layouts.py: -------------------------------------------------------------------------------- 1 | import dash_html_components as html 2 | import dash_core_components as dcc 3 | 4 | 5 | 6 | home_layout = html.Div(children=[ 7 | html.H1(children="Welcome to the dash Polling app!"), 8 | dcc.Link('Home',href="/"), 9 | html.Br(), 10 | dcc.Link('Polls',href="/polls"), 11 | html.Br(), 12 | dcc.Link('Poll Results',href="/poll-results") 13 | ]) 14 | 15 | polls_layout = html.Div(children=[ 16 | html.H1(children="This is Polls page"), 17 | dcc.Link('Home',href="/"), 18 | html.Br(), 19 | html.Br(), 20 | html.Div([ 21 | "Select a Poll:", 22 | dcc.Dropdown(id="polls-name-dropdown", 23 | options=[{'label': i, 'value': i} for i in ["Poll1","Poll2", "Poll3"]]) 24 | ]), 25 | html.Br(), 26 | html.Br(), 27 | html.Div(id="polls-question-div") 28 | 29 | ]) 30 | 31 | polls_results_layout = html.Div(children=[ 32 | html.H1(children="This is Poll Results page"), 33 | dcc.Link('Home',href="/") 34 | ]) --------------------------------------------------------------------------------