A small collection of Python experiments around neural networks (including an educational “single neuron” binary classifier) plus Tkinter-based GUIs and plotting utilities.
If you see ModuleNotFoundError: No module named 'numpy', install dependencies (Pixi or pip below). No module named 'data_visualization' is fixed in this repo by a small data_visualization/ package; run git pull or sync your copy if you still see the old error.
run_gui.py: entrypoint that launches the “Neural Network Data Visualization” GUI.data_visualization_gui.py: GUI implementation (Tkinter + Matplotlib; also wires in training/inference callbacks).
one_neuron_net.py: trains two independent single-neuron sigmoid classifiers (forwill_buy_friesandwill_buy_hamburger) and writes training artifacts to CSV/TXT.plot_one_neuron_results.py: reads those artifacts and generatesone_neuron_network_analysis.pngplus a printed summary.
duckdb_loader.py: helper functions for loading/selecting DuckDB files and extracting data (includes a GUI-based loader function).duckdb_to_csv_converter.py: extracts stock features/labels from DuckDB (e.g., TSLA OHLCV-style data) and saves them as CSV; also supports binary labels derived from the next-day move.
neuaral_clean.py: an end-to-end training script for a small feed-forward network using TSLA-like features; saves model parameters to:W1.csv,b1.csv,W2.csv,b2.csvX_mean.csv,X_std.csv
neuaral.py: another training/analysis script variant (also uses DuckDB helpers).
plot_csv_data.py: auto-detects CSV “shape” (loss curves, predictions, uni/multivariate) and generates PNGs for the data in the current directory.plot_neural_network.py: producesneural_network_comprehensive_analysis.pngandneural_network_detailed_analysis.pngfrom a set of expected CSV inputs:loss_history.csv,accuracy_history.csvfinal_predictions.csv,actual_labels.csvW1.csv,W2.csv,input_data.csv- Note: these extra files are not created by
neuaral_clean.py/neuaral.pyin this repo snapshot—you may need to adapt your training script to emit the expected filenames/format.
neural_neural.py: larger experimentation script that includes a Tkinter GUI and references additional plotting utilities (e.g.plot_stock_data.py).test_tk.py: minimal Tkinter smoke test.
This repo includes a pixi.toml that declares the core dependencies (python, numpy, pandas, matplotlib, seaborn, duckdb) plus optional features:
gui: addstkfor Tkinter-based GUIsml-extras: addsscikit-learnandscipy
You can use any Python environment manager you like, but Pixi is the most convenient here.
Create the base environment:
pixi installInclude optional features (GUI + ML extras):
pixi install --features gui,ml-extrasThen run scripts from the project root, for example:
pixi run python one_neuron_net.py
pixi run python plot_one_neuron_results.py
pixi run python run_gui.pyIf you use python3 directly, install dependencies first:
./install_deps.sh
# same as: python3 -m pip install -r requirements.txt
python3 one_neuron_net.py
python3 run_gui.pyModuleNotFoundError: No module named 'numpy'(or similar): your interpreter does not have the dependencies. Usepixi run python …afterpixi install, orpip install -r requirements.txtfor the same Python you run (python3 -m pip).- Tk abort on macOS (e.g.
macOS 26 required, have instead ...): your systempython3's bundled Tcl/Tk is not compatible. Run GUI scripts with Pixi:pixi run python run_gui.py
A Dockerfile is included to run the Tkinter-based GUI entrypoints and the plotting/training scripts with a minimal dependency set.
It installs Tkinter system packages plus xvfb for headless GUI runs.
docker build -t neural-net .From the repo root:
docker run --rm -it -v "$PWD":/app -w /app neural-net python one_neuron_net.py
docker run --rm -it -v "$PWD":/app -w /app neural-net python plot_one_neuron_results.pyTo verify Tkinter inside the container:
docker run --rm -it -v "$PWD":/app -w /app neural-net python test_tk.py- This image installs lightweight dependencies only (e.g.
numpy,pandas,matplotlib,seaborn,duckdb). - Tkinter support (
python3-tk) is installed sorun_gui.py/test_tk.pycan start if your project’s Python modules/imports are correctly available. - Heavier ML stacks like
tensorflow,scikit-learn, andscipyare not installed.
If you have an X server running on your host, you can try:
docker run --rm -it \
-e DISPLAY="$DISPLAY" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-w /app neural-net \
python run_gui.pyFor headless CI/servers:
docker run --rm -it -w /app neural-net \
xvfb-run -a python run_gui.pyIf the GUI fails to start, check the “GUI notes” section below (display / X11) and confirm dependencies are installed.
- Create
data.csvin the repo root with these columns:sex(encoded as 0/1 where0is treated as “male”,1as “female”)agewill_buy_frieswill_buy_hamburger
- Train:
python one_neuron_net.py
- Plot results:
python plot_one_neuron_results.py
Expected outputs include:
weights_fries.txt,weights_hamburger.txtloss_curve_will_buy_fries.csv,loss_curve_will_buy_hamburger.csvpredictions_will_buy_fries.csv,predictions_will_buy_hamburger.csvone_neuron_network_analysis.png
neuaral_clean.pycontains a hard-codedDUCKDB_PATHpointing to a user-specific location.- Update
DUCKDB_PATHto your own TSLA DuckDB file, then run:python neuaral_clean.py
It will save model parameters (W1.csv, W2.csv, etc.) into the current directory.
python plot_csv_data.py
run_gui.pyimportsDataVisualizationGUIfromdata_visualization_gui.pyat the repo root.- Supporting modules live in
data_loader.py(data tab) andneural_network/(trainer + inference). - On macOS/Linux you need a working display for Tkinter (local desktop, or X11 forwarding / XQuartz when using Docker).