8000 GitHub - jeffcole/ml-ai-material: Support material for the Mojotech ML/AI talks
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jeffcole/ml-ai-material

 
 

Repository files navigation

Installation instructions

Create and activate the virtual environment for Python

python -m venv venv
source venv/bin/activate

This should activate a private version of python 3.11. You can check it with

which python

That should show the path to venv/bin/python.

Using the virtual environment

By using an virtual environment you isolate this installation from the python installation on your machine and stuff you might have installed as a --user.

Every time you want to run this code you need to activate it with:

source venv/bin/activate

And when you want to use your regular python setup, just run:

source venv/bin/deactivate

Install Jupyter Notebook in the virtual environment

pip install jupyterlab
pip install notebook
python -m ipykernel install --user --name=venv

Install other libraries

pip install psycopg2
pip install scikit-learn
pip install numpy
pip install matplotlib
pip install pandas
pip install torch
pip install torchvision

Beware that the torch package is several GBytes!

Install a Dockerized PostgreSQL with a vector extension

cd postgresql
docker-compose start
./do_load.sh
Password: postgres
...
Password: postgres

The script will prompt you twice for the password and just enter postgres.

Prepare the MNIST data set

tar -xzf MNIST.tgz

Run the Jupyter Notebook samples

jupyter notebook

In the main tab just double-click on any of the .ipynb files on the list to open a new tab with that notebook. A tutorial on Jupyter Notebook can be found at Jupiter Notebook Tutorial

Natural Language Processing

Remember to activate your virtual environment with source venv/bin/deactivate if not already activated.

pip install spacy
python -m spacy download en_core_web_trf

The download is about 500 MB. A much smaller model is en_core_web_sm.

Parts of speech

If Jupyter Notebook is not already running, start it again and work on the SpaCy.ipynb.

Decision trees

Install graphviz and scikit-learn-tree packages into the virtual environment and run python decision_tree.py to create a decision tree for the Titanic dataset. In the input file titanic_2.csv Sex=1 means male and 0 female.

The python script creates Titanic.pdf. In the values vector, the first element is how many died and the second how many survived. The graph has True condition to the left and False to the right. The root node is a decision on sex, so women are on the left side (Sex <= 0.5) and men on the right.

About

Support material for the Mojotech ML/AI talks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 96.7%
  • Python 2.4%
  • Shell 0.9%
0