Skip to content

Instantly share code, notes, and snippets.

View victor-iyi's full-sized avatar
🎯
Focusing

Victor I. Afolabi victor-iyi

🎯
Focusing
View GitHub Profile
@victor-iyi
victor-iyi / sentence.py
Created March 27, 2019 17:12
A simple iterable sentence class.
class Sentence(str):
"""A simple iterable sentence class.
Methods:
def __init__(self, text): ...
def __repr__(self): ...
def __str__(self): ...
@victor-iyi
victor-iyi / lines-of-code.py
Last active June 5, 2019 20:30
Improved estimation of how many lines of codes are in a project (using recursion)
"""Improved estimation of how many lines of codes are in a project (using recursion)
@author
Victor I. Afolabi
Director of AI, NioCraft, 115Garage.
Email: javafolabi@gmail.com
GitHub: https://github.com/victor-iyiola
@project
File: lines-of-code.py
@victor-iyi
victor-iyi / tree-traversal.py
Created April 10, 2018 11:04
Traversing a nested list to estimate it's shape or dimension
# Shape = 2x3
a = [
[1, 2, 3],
[4, 5, 6]
]
# Shape = 2x3x2
b = [
[[1, 1], [2, 2], [3, 3]],
[[4, 4], [5, 5], [6, 6]]
@victor-iyi
victor-iyi / word2vec.py
Created November 4, 2017 00:45
Preprocessing class for textual dataset. Converts words to vector representations
"""
@author Victor I. Afolabi
A.I. Engineer & Software developer
javafolabi@gmail.com
Created on 28 October, 2017 @ 9:55 PM.
Copyright © 2017. Victor. All rights reserved.
"""
@victor-iyi
victor-iyi / dataset.py
Last active December 14, 2017 14:13
Dataset class for pre-processing images, text, word vectorization dataset
"""
@author Victor I. Afolabi
A.I. Engineer & Software developer
javafolabi@gmail.com
Created on 02 November, 2017 @ 11:24 PM.
Copyright © 2017. Victor. All rights reserved.
"""
import datetime as dt
@victor-iyi
victor-iyi / linear_model.py
Created September 13, 2017 12:57
LinearRegression with Gradient Descent Algorithm.
"""
@author Victor I. Afolabi
A.I. Engineer & Software developer
javafolabi@gmail.com
Created on 25 August, 2017 @ 8:15 PM.
Copyright © 2017. victor. All rights reserved.
"""
import numpy as np
@victor-iyi
victor-iyi / fibonacci.py
Created August 27, 2017 14:19
Explore 4 different implementations of Fibonacci algorithm
### PROGRAMMING FIBONACCI NUMBERS FROM BEGINNER TO EXPERT
### Method: 1
print('Method: 1')
def fibonacci(no):
series = [1,1]
for _ in range(1, no-1):
series.append(series[-1] + series[-2])
return series
@victor-iyi
victor-iyi / cart_pole.py
Created August 27, 2017 14:14
A trained deep neural net capable of playing the OpenAI's cart pole game 😎
import gym
import random
import numpy as np
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
from statistics import mean, median
from collections import Counter
LR = 1e-3
@victor-iyi
victor-iyi / curse-of-dimensionality.py
Created August 27, 2017 14:10
Estimate how long to brute force 1000 possible weights to train a Neural network
import numpy as np
time_taken_for_one_weight = 0.04
weights_to_try = 1000
weights_in_net = 8 # for 1 layer
one_year = 3600*24*365
years_to_train = time_taken_for_one_weight*(weights_to_try**weights_in_net)/one_year
print('{:,}'.format(years_to_train))
@victor-iyi
victor-iyi / permutation.py
Created July 7, 2017 12:00
Search list of reasonable words in a scrambled collection of letter
from nltk.corpus import wordnet
import threading
from queue import Queue
from datetime import datetime
import time
class WordSearch:
def __init__(self):
self.combo = set()