Skip to content

omoreira/Old-Python-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Old Python Examples – Statistical Modelling & ML Snippets

This repository collects a set of Python examples I originally wrote while developing material for the GM-RKB (Gabor Melli Research Knowledge Base). The code is intentionally small and focused. Each script demonstrates one idea in regression, statistical testing, or neural networks.

Note: These are examples, not production libraries. They are meant to be read, modified, and reused as starting points for analysis.


Repository Structure

NN_examples/

Neural-network regression examples (scikit-learn MLPRegressor) on the Boston housing dataset:

  • MLP_regression_10foldcv_boston.py – multi-layer perceptron regression with 10-fold cross-validation.
  • SVM_regression_10foldcv_boston.py – support-vector regression on the same dataset, for comparison.
  • MLP_1.png, MLP_2.png, MLP_3.png – example learning-curve / prediction plots generated by the scripts.

statistical_test/

Classical statistical and regression examples, mostly built around small, well-known datasets:

  • One- and two-sample t-tests (1samp_ttest_1.py, 2samplepaired_braindata.py).
  • Linear regression with cross-validation (Linear_regression_10fold.py).
  • Regularized regression:
    • RidgeRegression_boston10foldcv.py
    • Lasso_Boston_cv_predict.py
    • ENRegression_boston10foldcv.py
    • ARDRegression_boston10foldcv.py
    • BRRegression_boston10foldcv.py
  • Tree-based and SVM regression:
    • regressiontrees_10foldcv.py
    • SVM_regression_boston10foldcv.py
  • Simple worked examples such as simpleleastsquare.py, welchtestexample.py, etc.

Most scripts print basic diagnostics (scores, coefficients) and can easily be extended with additional plots or metrics.

decision_tree_emv_evpi_example.py (new)

A small, self-contained example of decision analysis:

  • Models a batch-size decision under uncertain demand.
  • Computes EMV (expected monetary value) for each option.
  • Computes the expected value with perfect information (EV with PI) and the resulting EVPI.
  • Generates a simple decision-tree diagram:
  python statistical_test/decision_tree_emv_evpi_example.py

which writes emv_evpi_decision_tree.png to the current directory.

miscellaneous/

Miscellaneous helper scripts, experiments, and scratch work that don’t fit neatly into the folders above. These are left here for completeness and may be useful as lightweight references for syntax or quick experiments.


Requirements

These examples assume:

  • Python 3.x
  • numpy
  • scipy
  • scikit-learn
  • matplotlib

You can install them with:

pip install numpy scipy scikit-learn matplotlib

How to Use This Repository

  • Treat each script as a worked example.

  • Run them from the command line, read the code, and adapt to your own datasets.

  • For Upwork / portfolio purposes, this repo shows:

    • Familiarity with classical statistical tests.
    • Hands-on practice with regression models (linear, regularized, tree-based, SVM, neural nets).
    • A concrete EMV / EVPI decision-tree example.

License

These examples are provided for educational and portfolio purposes. You are welcome to read, adapt, and reuse them with appropriate attribution.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages