• Stars
    star
    167
  • Rank 221,980 (Top 5 %)
  • Language
    Jupyter Notebook
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Data science and Machine Learning GUI programs/ desktop apps with PySimpleGUI package

DS-with-PySimpleGUI

Dr. Tirthajyoti Sarkar, Fremont, CA

Data science GUI programs with awesome PySimpleGUI package.


What is PySimpleGUI and what is this repo?

As per their website, "Python GUI For Humans - Transforms tkinter, Qt, Remi, WxPython into portable people-friendly Pythonic interfaces". In this repo, I specifically focus on creating simple demo programs related to data science (simple analytics, statistical modeling and visualizations, basic machine learning) using this powerful GUI building tool.

Requirements

Install PySimpleGUI by,

pip install pysimplegui

You will also need,

  • Numpy
  • Pandas
  • Matplotlib
  • Scikit-learn
  • Seaborn

etc. to run the demo codes.

A very simple random integer generator app

Here is the code to program this app,

import PySimpleGUI as sg
import numpy as np

# Update function
def update():
    r = np.random.randint(1,100)
    text_elem = window['-text-']
    text_elem.update("This is a random integer: {}".format(r))

# Define the window's contents i.e. layout
layout = [[sg.Button('Generate',enable_events=True, key='-FUNCTION-', font='Helvetica 16')],
         [sg.Text('This is a random integer:', size=(25, 1), key='-text-', font='Helvetica 16')]]

# Create the window
window = sg.Window('Generate random integer', layout, size=(350,100))

# Event loop
while True:
    event, values = window.read()
    if event in (sg.WIN_CLOSED, 'Exit'):
        break
    if event == '-FUNCTION-':
        update()

# Close the window i.e. release resource
window.close()

When you save this code in a Python script and run it, you will see a simple window pop up where you can click on a button to call the update function as many times as you want (note the while True loop in the code for this infinite loop action) and generate a random integer between 1 and 99.

genrandom

Although this is a very simple code, it features,

  • layout (with styling arguments e.g. size and font) and a window
  • a button element which calls an external function (event)
  • the function updating a text element of the window object

We can essentially follow the same path and add more layers of layout, events, logic, and widgets to make powerful data science apps.


App to show other widgets (FontUpdate.py)

Just run with python FontUpdate.py command and you will see this window pop up where you can dynamically update the font of the text. Here is the demo video,

fontupdate

This app gets you familiar with other widgets available,

  • slider
  • checkboxes

A quadratic equation solver

Just run with python QuadraticEquation.py command and you will see this window pop up where you can enter coefficients of a quadratic equation and get the solution (even if the roots turn out to be complex numbers!)

quadratic


Demo of SimpleDataFrame.py (Pandas DataFrame app)

There are both Jupyter notebooks and .PY scripts. The simplest way to run a GUI is to execute the .PY scripts, e.g.

python SimpleDataFrame.py

Input file

At the start, it will ask you for a dataset file (a CSV)

input

File browser

When you click on the 'Browse' button, it will show a file browser dialog first. Make sure you select the correct dataset for this demo from under the data directory.

browser

Prompts

After you select the cars.csv, you will see other prompts popping up,

prompts

Dataset

If you click 'Yes' on that last prompt, you will see the dataset that was read in a new window,

data

Descriptive stats

After you close that window, a new popup will ask if you want to see the descriptive statistics about this dataset. If you click 'Yes', then you will see something like this,

stat

A plot

After you close that window, another popup will ask if you want to see a sample plot. If you click 'Yes', then you will see something like this,

plot

Play with the notebooks if you like

If you want to experiment with the code, you can look at the Notebooks and play with them.


Random scatter plots

Generate as many random scatter plots as you wish.

drawrandom


Polynomial fitting

A simple 2nd degree polynomial fitting app wher you can adjust the noise level of the randomly generated data.

polyfit


A Scikit-learn model fitting example

We build a simple app which lets you load the Pima Indians diabetes dataset and fit a Random Forest model to this data using Scikit-learn in the background.

pima


PySimpleGUI website

Read the docs here

Github repo

Cool demos

Use Qt Designer to build complex forms

Qt Desginer is a popular visual aid for building complex forms for Python GUI programming. You can build PySimpleGUI comppatible code with Qt Designer by using an intermediary - PySimpleGUIDesigner.

Here is the Github for that program.

And, here is an YouTube tutorial on how to use it.

More Repositories

1

Machine-Learning-with-Python

Practice and tutorial-style notebooks covering wide variety of machine learning techniques
Jupyter Notebook
3,016
star
2

Data-science-best-resources

Carefully curated resource links for data science in one place
2,798
star
3

Papers-Literature-ML-DL-RL-AI

Highly cited and useful papers related to machine learning, deep learning, AI, game theory, reinforcement learning
2,224
star
4

Stats-Maths-with-Python

General statistics, mathematical programming, and numerical/scientific computing scripts and notebooks in Python
Jupyter Notebook
793
star
5

Deep-learning-with-Python

Deep learning codes and projects using Python
Jupyter Notebook
343
star
6

Spark-with-Python

Fundamentals of Spark with Python (using PySpark), code examples
Jupyter Notebook
324
star
7

pydbgen

Random dataframe and database table generator
Python
297
star
8

Web-Database-Analytics

Web scrapping and related analytics using Python tools
Jupyter Notebook
263
star
9

UCI-ML-API

Simple API for UCI Machine Learning Dataset Repository (search, download, analyze)
Python
241
star
10

Design-of-experiment-Python

Design-of-experiment (DOE) generator for science, engineering, and statistics
Jupyter Notebook
236
star
11

Optimization-Python

General optimization (LP, MIP, QP, continuous and discrete optimization etc.) using Python
Jupyter Notebook
222
star
12

Interactive_Machine_Learning

IPython widgets, interactive plots, interactive machine learning
Jupyter Notebook
151
star
13

doepy

Design of Experiment Generator. Read the docs at: https://doepy.readthedocs.io/en/latest/
Python
141
star
14

PyTorch_Machine_Learning

Machine learning, Deep Learning, CNN with PyTorch
Jupyter Notebook
80
star
15

Finance-with-Python

Financial data analytics with Python
Jupyter Notebook
73
star
16

Synthetic-data-gen

Various methods for generating synthetic data for data science and ML
Jupyter Notebook
73
star
17

Covid-19-analysis

Analysis with Covid-19 data
Jupyter Notebook
60
star
18

Julia-data-science

Data science and numerical computing with Julia
Jupyter Notebook
57
star
19

R-stats-machine-learning

Misc Statistics and Machine Learning codes in R
R
40
star
20

Algorithm-Data-Structures-Python

Various useful data structures in Python
Jupyter Notebook
37
star
21

TensorFlow_Basics

Basic TensorFlow mechanics, operations, class definitions, and neural networks building. Examples from deeplearning.ai Tensorflow course using Google Colab platform.
Jupyter Notebook
35
star
22

Scikit-image-processing

Image processing examples with Numpy, Scipy, and Scikit-image
Jupyter Notebook
32
star
23

mlr

Multiple linear regression with statistical inference, residual analysis, direct CSV loading, and other features
Python
31
star
24

Packt-Data_Wrangling

Code repo for Packt course I developed, "Beginning Data Wrangling with Python"
Jupyter Notebook
28
star
25

Digital-Twin

Digital twin with Python
Jupyter Notebook
28
star
26

ML-apps-with-Streamlit

Building simple ML apps with Streamlit
Python
24
star
27

PyScript-examples

Examples of web pages developed with PyScript framework
23
star
28

tirthajyoti.github.io

Tirthajyoti's Home Page about machine learning, statistics, analytics
HTML
22
star
29

Algorithm_Maths_Python

General math scripts and important algorithms' implementation in Python 3
Jupyter Notebook
21
star
30

Symbolic-computation-Python

Symbolic computation using SymPy and various applications
Jupyter Notebook
20
star
31

RL_basics

Basic Reinforcement Learning algorithms
Jupyter Notebook
17
star
32

GradDescent

MATLAB implementation of Gradient Descent algorithm for Multivariate Linear Regression
MATLAB
16
star
33

Convolutional-Networks

Various conv nets using TensorFlow, Keras, or other tools
Jupyter Notebook
14
star
34

Dask-analytics-ML

Data science and ML with Dask
Jupyter Notebook
13
star
35

Magnimind-Stats-Bootcamp-Jan-2020

Magnimind Bootcamp Stats for Data Science
Jupyter Notebook
12
star
36

PyWebIO

Web apps generated by pure Python script using PyWebIO
Python
11
star
37

Scikit-image-book

Scikit-image-book-built-with-Jupyter-book
Jupyter Notebook
11
star
38

Stats_data_science_ValleyML

Notebooks for the ValleyML Bootcamp (Aug 2019) "Statistical methods for data science"
Jupyter Notebook
10
star
39

Randomized_Optimization

Randomized optimization techniques for NN and other problems
HTML
8
star
40

HyperparameterLearningTF

Learning the impact of Hyperparameters in a deep learning model
Jupyter Notebook
7
star
41

D3.js-examples

Simple D3.js code examples
JavaScript
6
star
42

MNIST_digit_recognition

MNIST hand-written digit recognition by fully-connected and convolutional neural networks - boiler plate code for easy reproduction and tutorial purpose.
Jupyter Notebook
6
star
43

tirthajyoti

5
star
44

Random_Function_Generator

Random function generator, with generation by symbolic input
Jupyter Notebook
4
star
45

Stanford-SCI-52

Jupyter Notebook
4
star
46

DeepNetworksR

Multi-layer neural networks code examples in R
R
4
star
47

Gradio-apps

Python web apps built with Gradio
3
star
48

mldsutils

My own ml and ds utils package
Jupyter Notebook
3
star
49

ghPage-test

test for gh pages
2
star
50

FunnyWordGen

Funny word (random) generator using Python 3
Python
2
star
51

Saturn-cloud

Write-ups for Saturn-cloud
1
star