Skip to content

Instantly share code, notes, and snippets.

Avatar

Giuseppe Cuccu giuse

View GitHub Profile
@giuse
giuse / play_bipedal.py
Created Jul 3, 2019
Play bipedal walker
View play_bipedal.py
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,
@giuse
giuse / words.rb
Created Jul 29, 2017
Word processing for a bayesian spam filter
View words.rb
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