Skip to content

Instantly share code, notes, and snippets.

View giuse's full-sized avatar

Giuseppe Cuccu giuse

View GitHub Profile
@giuse
giuse / words.rb
Created July 29, 2017 12:29
Word processing for a bayesian spam filter
def process_words
# Lowercase
words.each &:downcase!
# Remove punctuation
words.map! { |word| word.gsub(/[^a-z0-9\s]/i, '') }
# Remove numbers
words.map! { |word| word.gsub(/[0-9]/i, '') }
# Remove empty and single-letter words
words.reject! { |word| word.length < 2 }
# Remove stopwords
@giuse
giuse / play_bipedal.py
Created July 3, 2019 14:25
Play bipedal walker
import numpy as np
from tinynet import RNN1L
import gym
pre_trained_weights = np.array(
[[-6.42131474e-02, 1.18558117e+00, -8.65697398e-02,
-7.25508614e-01, -1.64208890e+00, 2.36031412e-01,
-2.30686547e-01, 1.01184284e-02, 9.14193609e-02,
4.09360317e-01, 5.28414810e-01, 3.01208252e+00,
-9.78603700e-02, 3.53038690e-02, 8.94094020e-01,