Personal Notes / Reminders
- make venv
python3 -mvenv .venv
- to activate
source ./.venv/bin/activate
# install packages pip / pip3
pip install jupyter matplotlib numpy pandas scipy scikit-learn
# upgrade existing package
pip install --upgrade <package_name>
# make requirements.txt file
pip freeze > requirements.txt
# To exit venv
deactivate
# How to use the requirements.txt file
pip install -r requirements.txt
- To specify the interpreter you can use the
#!
on the first line of ascript.py
#!/Users/mikedeufel/code/python/HuggingFace/venv/bin/python
- Note you must run this as an executable in order for the
#!
to work
chmod +x filename.py
ls -la #to verify
./filename.py
import sqlite3
import pprint
''' Inspect '''
print(db.execute("select sqlite_version()").fetchall()) # sqlite version
db = sqlite3.connect("your_datebase.db")
db.execute("select name from sqlite_master where type='table'").fetchall() # tables
for row in db.execute("SELECT * FROM any_table LIMIT 10"): print(row) # rows (tuples)
db.row_factory = sqlite3.Row # will convert rows to dict (easier to work with)
for row in db.execute("SELECT * FROM any_table LIMIT 10"): print(dict(row)) # rows (dictionaries)
for row in db.execute("select name from sqlite_master where type='table'").fetchall(): pprint.pprint(dict(row)) # tables (pprint)
for row in db.execute("SELECT * FROM stats LIMIT 10"): pprint.pprint((dict(row))) # rows (pprint)
''' Create '''
db.execute("CREATE TABLE events(id integer primary key, name text, start_date text, end_date text, description text);")
import numpy as np
data = np.arange(10)
indicies_permutation = np.random.permutation(len(data))
shuffled_data = data[indicies_permutation]
print(f"data: \t\t{data}")
print(f"shuffled: \t{shuffled_data}")
'''
----- OUTPUT -----
data: [0 1 2 3 4 5 6 7 8 9]
shuffled: [2 9 8 1 5 7 3 0 4 6]
'''
- One Hot Encode
from tensorflow.keras.utils import to_categorical
y_train = to_categorical(train_labels)
- Simple stacked layers w/ relu activation can solve lots of problems
- Make last layer
layers.Dense(1,activation="sigmoid")
for binary classification - Make last layer
layers.Dense(#_categories, activation="softmax"
for single label multiclassification
- Set Optimizer to "rmsprop" for 95% of models
- if binary classificationWhen then
loss="binary_crossentropy"
- if single label multiclassification with OHE y then
loss="categorical_crossentropy"
- if single label multiclassification with int y then
loss="sparse_categorical_crossentropy"
- epochs is number of forward + backward pass the model makes attempting to reduce loss carefull not to overfit
nbdev_new
nbdev_preview
nbdev_prepare
# Verify installed
git --version
# Set up
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
# Confirm
git config --list
# navigate to location
git init
ls -la # to verify
rm -rf .git # to stop tracking project with .git
git status # to see current status
touch .gitignore # add file names to ignore (can also use wildcards ex *.txt)
git add "file_name" # add a single file to staging area
git add -A # add all files to Staging Area
git reset # Remove files from the Staging Area
git status # to verify
git add -A
git commit -m "Initial Commit" # try to make better Messages
git log # will show the History
git clone <url> <where to clone> # will also work for local files
git remote -v # Lists Repo information
git branch -a # List all of the Branches of the Repo
# ..make some changes to code...
git diff
git status
git add -A
git commit -m "message"
# When ready to commit changes do a git pull -> git push (to capture any other changes)
git pull origin master
git push origin master
git branch "new_feature" # Makes the branch
git checkout "new_feature" # Moves you over the the branch
git add -A
git commit -m "small_new_feature" # uploads teh change ONLY to the branch
git push -u origin "new_feature" # slightly complex command that associates the brance with main
git branch -a # To verify
git add -A && git commit -m "small new feature..."
git push
# Ready to merge with Master Branch
git checkout master
git pull origin master
git merge "new_feature" # Merges the changes
git push origin master # Uploads the changes to remote repo
#Delete the Branch
git branch -d "new_feature" # will delete localy
git push origin --delte "new_feature" # will delete from remote repo
git branch -s # to verify
# To go back to an old version and branch off
git log --graph --oneline --all --decorate # to see all committs #
git checkout -b new-branch-name 4f8d768 # Creating a new branch from an old commit
git init && git add -A && git commit -m "Initial commit"
git reset --hard origin/main # Roll back to last commit
git log --oneline --graph --decorate --all
show ssh keys: ls -al ~/.ssh
-
Start the Podman machine
podman machine start
-
Verify the Podman machine is running
podman machine list
-
Pull a Node.js image
podman pull node:latest
-
Create and run a container
podman run -it -p 8080:8080 --name node-dev-container -v $(pwd):/usr/src/app -w /usr/src/app node:latest /bin/bash
- 8080 access
- shared Volume
- Inside the container, install Node.js dependencies and start the development server
npm install;npm start
- create new ssh
ssh-keygen -t rsa -b 4096 -f ~/.ssh/my_server_key
- Send ssh to server
ssh-copy-id -i ~/.ssh/custom_key_name.pub user@server_ip
- Edit ~/.ssh/config
Host orange
HostName server_ip
User user # same as step 2
IdentityFile ~/.ssh/my_server_key
'''
>> ssh my_server_key # Will log you on
'''