Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural_net

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.

What’s in this repo

GUIs

  • 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).

Single-neuron (educational) demo

  • one_neuron_net.py: trains two independent single-neuron sigmoid classifiers (for will_buy_fries and will_buy_hamburger) and writes training artifacts to CSV/TXT.
  • plot_one_neuron_results.py: reads those artifacts and generates one_neuron_network_analysis.png plus a printed summary.

DuckDB -> CSV utilities (TSLA pipeline)

  • 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.

Neural network training (workspace-specific scripts)

  • 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.csv
    • X_mean.csv, X_std.csv
  • neuaral.py: another training/analysis script variant (also uses DuckDB helpers).

Plotting 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: produces neural_network_comprehensive_analysis.png and neural_network_detailed_analysis.png from a set of expected CSV inputs:
    • loss_history.csv, accuracy_history.csv
    • final_predictions.csv, actual_labels.csv
    • W1.csv, W2.csv, input_data.csv
    • Note: these extra files are not created by neuaral_clean.py / neuaral.py in this repo snapshot—you may need to adapt your training script to emit the expected filenames/format.

Misc

  • 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.

Setup

This repo includes a pixi.toml that declares the core dependencies (python, numpy, pandas, matplotlib, seaborn, duckdb) plus optional features:

  • gui: adds tk for Tkinter-based GUIs
  • ml-extras: adds scikit-learn and scipy

You can use any Python environment manager you like, but Pixi is the most convenient here.

Using Pixi

Create the base environment:

pixi install

Include optional features (GUI + ML extras):

pixi install --features gui,ml-extras

Then 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.py

Using pip (system Python)

If 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.py

Troubleshooting

  • ModuleNotFoundError: No module named 'numpy' (or similar): your interpreter does not have the dependencies. Use pixi run python … after pixi install, or pip install -r requirements.txt for the same Python you run (python3 -m pip).
  • Tk abort on macOS (e.g. macOS 26 required, have instead ...): your system python3's bundled Tcl/Tk is not compatible. Run GUI scripts with Pixi:
    • pixi run python run_gui.py

Docker (GUI-capable)

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.

Build

docker build -t neural-net .

Run (quick examples)

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.py

To verify Tkinter inside the container:

docker run --rm -it -v "$PWD":/app -w /app neural-net python test_tk.py

Notes

  • This image installs lightweight dependencies only (e.g. numpy, pandas, matplotlib, seaborn, duckdb).
  • Tkinter support (python3-tk) is installed so run_gui.py/test_tk.py can start if your project’s Python modules/imports are correctly available.
  • Heavier ML stacks like tensorflow, scikit-learn, and scipy are not installed.

Docker: Run GUI

Local display (X11)

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.py

Headless (Xvfb)

For headless CI/servers:

docker run --rm -it -w /app neural-net \
  xvfb-run -a python run_gui.py

If the GUI fails to start, check the “GUI notes” section below (display / X11) and confirm dependencies are installed.

Quickstart

1) Train + plot the single-neuron demo

  1. Create data.csv in the repo root with these columns:
    • sex (encoded as 0/1 where 0 is treated as “male”, 1 as “female”)
    • age
    • will_buy_fries
    • will_buy_hamburger
  2. Train:
    • python one_neuron_net.py
  3. Plot results:
    • python plot_one_neuron_results.py

Expected outputs include:

  • weights_fries.txt, weights_hamburger.txt
  • loss_curve_will_buy_fries.csv, loss_curve_will_buy_hamburger.csv
  • predictions_will_buy_fries.csv, predictions_will_buy_hamburger.csv
  • one_neuron_network_analysis.png

2) Train the DuckDB-feature neural network script

  • neuaral_clean.py contains a hard-coded DUCKDB_PATH pointing to a user-specific location.
  • Update DUCKDB_PATH to 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.

3) Plot arbitrary CSVs in the current directory

  • python plot_csv_data.py

GUI notes

  • run_gui.py imports DataVisualizationGUI from data_visualization_gui.py at the repo root.
  • Supporting modules live in data_loader.py (data tab) and neural_network/ (trainer + inference).
  • On macOS/Linux you need a working display for Tkinter (local desktop, or X11 forwarding / XQuartz when using Docker).

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages