Skip to content

Instantly share code, notes, and snippets.

View jaume-ferrarons's full-sized avatar

Jaume Ferrarons jaume-ferrarons

  • New Work SE (XING)
  • Barcelona, Spain
View GitHub Profile
@jaume-ferrarons
jaume-ferrarons / elm.py
Created October 1, 2021 12:28
Extreme Learning Machine implementation
import numpy as np
import math
from pathlib import Path
import shutil
import json
class ELM:
def __init__(self, n_hidden_units: int) -> None:
self._n_hidden_units = n_hidden_units
self._weights_hidden = None
@jaume-ferrarons
jaume-ferrarons / python_solid.py
Last active November 19, 2020 16:49
Demonstrate the usage of SOLID principles with basic examples
# Using SOLID principles in Python
##
# Single-responsibility principle (from wikipedia): states that every module, class or function in a computer program should have responsibility over a single part of that program's functionality, which it should encapsulate. All of that module, class or function's services should be narrowly aligned with that responsibility.
##
from typing import Any, List
from abc import ABC, abstractmethod
def data_generator(rows: int = 10) -> List[int]:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jaume-ferrarons
jaume-ferrarons / colab_gym_recording.py
Last active April 20, 2020 09:24
colab-gym-recording
import gym
from gym import logger as gymlogger
from gym.wrappers import Monitor
import glob
import io
import base64
from IPython.display import HTML, clear_output
from IPython import display as ipythondisplay
@jaume-ferrarons
jaume-ferrarons / output_tutorial1.json
Last active January 30, 2019 10:18
Tutorial: How to optimize routes with SmartMonkey on Python
{
"status": "success",
"processing_time": 4647,
"job_id": "5c4b0e523ee5ba00168795f6",
"solution": {
"routes": [
{
"geometry": "qor{FatfLH\\JXPl@XhADJPv@XbAPl@XhA\rAHVJ`@Xe@fBoC`@q@DS@i@^iIIgAK...",
"vehicle_id": "Car",
"steps": [
@jaume-ferrarons
jaume-ferrarons / indeed_keras_mlp.py
Created April 7, 2017 20:01
HackerRank - Indeed Machine Learning CodeSprint - Basic Keras solution using a MLP (https://www.hackerrank.com/contests/indeed-ml-codesprint-2017)
# https://github.com/datalogai/recurrentshop
# https://github.com/farizrahman4u/seq2seq
import pandas as pd
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.layers import LSTM
from keras.preprocessing.text import Tokenizer
import gym
from gym import wrappers
import numpy as np
from sklearn import svm
env = gym.make('CartPole-v0')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-1', force=True)
observations = []