Skip to content

Instantly share code, notes, and snippets.

View jhumigas's full-sized avatar
🌳
Free

D. jhumigas

🌳
Free
  • Milky Way
View GitHub Profile
@jhumigas
jhumigas / validator-decorator-with-panderas.py
Last active May 11, 2023 11:49
Filtering out failure cases with Panderas
"""
Existing builtin decorators in panderas are ok, but they will raise an exception once a check fails.
If that is not the expected behavior, we can create our own decorators, to filter out corrupted rows to analyse them later without
creating a failure on the whole dataset.
In the following, we will create our own decorator which will filter out rows that did not pass our checks.
"""
import inspect
@jhumigas
jhumigas / trust_score.py
Last active August 21, 2018 21:48
Trust scores
"""
The MIT License (MIT)
Copyright (c) 2018 David Mugisha
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jhumigas
jhumigas / LSTMAug.ipynb
Last active June 30, 2020 01:28
Augmenting the LSTM PoS tagger with Character-level features (PyTorch)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhumigas
jhumigas / cbow.py
Last active November 24, 2022 14:26
Pytorch about Continuous Bag Of Words Representation
"""
My proposal to the exercise in the tutorial about Deep Learning for NLP with Pytorch
This is one is about Word Embeddings that encodes Lexical Semantics.
Continuous Bag-of-Words model (CBOW) is model that tries to predict a word given the context
of a few words before and after the target.
.. _Source:
http://pytorch.org/tutorials/beginner/nlp/word_embeddings_tutorial.html#exercise-computing-word-embeddings-continuous-bag-of-words
"""
"""
The MIT License (MIT)
Copyright (c) 2017 David Mugisha
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
"""
Small example of function to reorder a data set.
"""
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
def extract_k(labels, k):
"""Extract k percent of the dataset.
@jhumigas
jhumigas / Sinus.java
Last active October 13, 2016 19:18
Sine in Java between three points
import java.awt.geom.Point2D;
public class Sinus{
/**
* Computes the sine of the angle between three points.
* Use the properties of the cross product between two vectors in a 2D euclidean space.
* The positive angles are counter-clockwise.
* @param pt1 Point defined by a location in a coordinate space
* @param pt2 Point defined by a location in a coordinate space
* @param pt3 Point defined by a location in a coordinate space
@jhumigas
jhumigas / lagfib.py
Last active April 15, 2024 20:49
First try for a Lagged, Fibonacci (pseudo) Random Number Generators
#!usr/bin/python
from random import randint
from math import pow
_lag1 = 55
_lag2 = 24
_modulus = 31
#_firstterms = [randint(0,pow(2,_modulus)) for x in range(0,_lag1)]
_firstterms = [773, 744, 844, 228, 13, 1011, 691, 1, 1106, 730, 438, 102, 498, 1004, 111, 1230, 217, 1133, 703, 686, 78, 551, 60, 1009, 772, 922, 1223, 1205, 511, 876, 992, 162, 85, 296, 837, 755, 579, 268, 64, 194, 811, 645, 626, 140, 395, 1162, 322, 64, 97, 477, 117, 803, 1233, 288, 117, 594]