Skip to content

khteh/pAIthon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pAIthon

Python AI, ML, DL, NLP and GAN exploration playground.

Run

  • pipenv run python -m <module>
  • Some keras models are saved and loaded from models/ folder.

Model Diagnostics

Tensorboard

  • pipenv run tensorboard --logdir <path>

Signs Language Digits Multiclass Classification

  • Use ResNet152V2 pretrained model.
  • Test dataset accuracy:
    16/16 ━━━━━━━━━━━━━━━━━━━━ 11s 366ms/step - accuracy: 0.9020 - loss: 0.7031
    
  • Example predictions:
    1/1 ━━━━━━━━━━━━━━━━━━━━ 6s 6s/step
    Class prediction vector [p(0), p(1), p(2), p(3), p(4), p(5)] = [[-2.0099866  -0.56881446  4.5948634  -2.6432185   2.2302372   1.7344184
      0.23657088  0.4649722   1.4646876  -0.11805859]]
    Truth: 2, Class: 2
    1/1 ━━━━━━━━━━━━━━━━━━━━ 0s 42ms/step
    Class prediction vector [p(0), p(1), p(2), p(3), p(4), p(5)] = [[ 1.1785551  -1.3516254   0.6351655  -2.5380015  -1.3923934  -0.04097138
      0.8621799  -0.7493809   1.1925981  -0.79342335]]
    Truth: 1, Class: 8
    1/1 ━━━━━━━━━━━━━━━━━━━━ 0s 41ms/step
    Class prediction vector [p(0), p(1), p(2), p(3), p(4), p(5)] = [[ 1.0378284  -3.540225   -1.0644982  -4.938359   -1.5945294   1.5830379
      -0.3573578  -2.0449076   1.9372692  -0.02878545]]
    Truth: 3, Class: 8
    1/1 ━━━━━━━━━━━━━━━━━━━━ 0s 41ms/step
    Class prediction vector [p(0), p(1), p(2), p(3), p(4), p(5)] = [[ 0.39373627 -3.8968973  -0.22976398 -4.179752   -0.29858652  3.7758834
      0.9506325  -1.949536    1.0997412   0.07072492]]
    Truth: 5, Class: 5
    1/1 ━━━━━━━━━━━━━━━━━━━━ 0s 45ms/step
    Class prediction vector [p(0), p(1), p(2), p(3), p(4), p(5)] = [[-1.0685589  -2.327231   -0.17754719 -3.8118033   3.1382742   3.5833392
      0.10239653 -0.71539956  1.3708843  -0.6684125 ]]
    Truth: 5, Class: 5
    

Machine Translation

  • Bidirection LSTM
  • Translate from human-readable date locale string to ISO-format date string.
  • Architecture: Machine Translation
  • Attention Map: Attention Map

LSTM Name Entity Recognition

  • Unidirection LSTM
  • Identify name entities in input seqeunce LSTM Name Entity Recognition
  • Example:
    • Inpuut: "Peter Parker , the White House director of trade and manufacturing policy of U.S , said in an interview on Sunday morning that the White House was working to prepare for the possibility of a second wave of the coronavirus in the fall , though he said it wouldn ’t necessarily come"
    • Output:
      Peter: B-per
      Parker: I-per
      White: B-org
      House: I-org
      Sunday: B-tim
      morning: I-tim
      White: B-org
      House: I-org
      coronavirus: B-org
      ’t: I-per
      necessarily: I-per
      

LSTM Emojifier

  • Sentiment analysis of input sentence with an emoji output using GloVe vectors. LSTM Emojifier
  • Examples (Some of them are mislabelled):
    The meal was great!:  🍴
    I had a tough day!:  ❤️
    The job looks interesting!:  😄
    I had a great trip!:  🍴
    I learnt something new today!:  ❤️
    

Siamese Neural Network

  • Text similarity classifier Siamese NN
  • Examples:
    1. "When will I see you?", "When can I see you again?" Prediction: True
    2. "Do they enjoy eating the desert?", "Do they like hiking in the desert?" Prediction: False

Transformer Text Summarization

  • Encoder-Decoder Transformer architecture

Semantic Image Segmentation UNet

Architecture:

Image Segmentation UNet

Predictions:

Image Segmentation Predictions

Heart Disease Decision Tree Model

  • Features: 'Age', 'RestingBP', 'Cholesterol', 'FastingBS', 'MaxHR', 'Oldpeak', 'Sex_F', 'Sex_M', 'ChestPainType_ASY', 'ChestPainType_ATA', 'ChestPainType_NAP', 'ChestPainType_TA', 'RestingECG_LVH', 'RestingECG_Normal', 'RestingECG_ST', 'ExerciseAngina_N', 'ExerciseAngina_Y', 'ST_Slope_Down', 'ST_Slope_Flat', 'ST_Slope_Up' Heart Disease Decision Tree Model
  • Model explaination of contributing factors to heart disease:
    • The red sections on the left are features which push the model towards the final prediction in the positive direction (i.e. a higher Age increases the predicted risk).
    • The blue sections on the right are features that push the model towards the final prediction in the negative direction (if an increase in a feature leads to a lower risk, it will be shown in blue). Heart Disease force plot Heart Disease summary plot

NHANES | epidemiology risk analysis

  • Predicting the 10-year risk of death of individuals from the NHANES | epidemiology dataset.
  • Model: Random Forest
  • Features: 'Age', 'Diastolic BP', 'Poverty index', 'Race', 'Red blood cells', 'Sedimentation rate', 'Serum Albumin', 'Serum Cholesterol', 'Serum Iron', 'Serum Magnesium', 'Serum Protein', 'Sex', S'ystolic BP', 'TIBC', 'TS', 'White blood cells', 'BMI', 'Pulse pressure'
  • Model explaination of contributing factors to 10-year risk of death:
    • The red sections on the left are features which push the model towards the final prediction in the positive direction (i.e. a higher Age increases the predicted risk).
    • The blue sections on the right are features that push the model towards the final prediction in the negative direction (if an increase in a feature leads to a lower risk, it will be shown in blue). NHANES / epidemiology risk force plot NHANES / epidemiology risk summary plot NHANES / epidemiology risk age-sex dependence plot

GradCAM (Gradient-weighted Class Activation Mapping)

  • Visualize the impact of each region of an image on a specific output for a Convolutional Neural Network model, DenseNet121 in this case with a pretrained model.

  • Generate a heatmap by computing gradients of the specific class scores we are interested in visualizing.

  • Features: 'Age', 'RestingBP', 'Cholesterol', 'FastingBS', 'MaxHR', 'Oldpeak', 'Sex_F', 'Sex_M', 'ChestPainType_ASY', 'ChestPainType_ATA', 'ChestPainType_NAP', 'ChestPainType_TA', 'RestingECG_LVH', 'RestingECG_Normal', 'RestingECG_ST', 'ExerciseAngina_N', 'ExerciseAngina_Y', 'ST_Slope_Down', 'ST_Slope_Flat', 'ST_Slope_Up'

    Image: 00016650_000.png Ground Truth: 0, Cardiomegaly
    Generating heatmap for class Cardiomegaly, prediction: Cardiomegaly (p=0.9047)
    Generating heatmap for class Mass, prediction: Cardiomegaly (p=0.2098)
    Generating heatmap for class Edema, prediction: Cardiomegaly (p=0.0489)
    

    Cardiomegaly

    Image: 00005410_000.png Ground Truth: 5, Mass
    Generating heatmap for class Cardiomegaly, prediction: Mass (p=0.0091)
    Generating heatmap for class Mass, prediction: Mass (p=0.9355)
    Generating heatmap for class Edema, prediction: Mass (p=0.0848)
    

    Mass

    Image: 00004090_002.png Ground Truth: 12, Edema
    Generating heatmap for class Cardiomegaly, prediction: Edema (p=0.3357)
    Generating heatmap for class Mass, prediction: Edema (p=0.1737)
    Generating heatmap for class Edema, prediction: Edema (p=0.8023)
    

    Edema

MNIST GAN

MNIST GAN

Sine Wave GAN

Harvard Extended CS50 course works

https://cs50.harvard.edu/ai/2024/