Skip to content

Instantly share code, notes, and snippets.

View VictorGarritano's full-sized avatar

Victor Garritano VictorGarritano

  • Rio de Janeiro, Brazil
View GitHub Profile
0 963 429 1949 2979 1504 206 2976 3095
963 0 671 996 2054 1329 802 2013 2142
429 671 0 1616 2631 1075 233 2684 2799
1949 996 1616 0 1059 2037 1771 1307 1235
2979 2054 2631 1059 0 2687 2786 1131 379
1504 1329 1075 2037 2687 0 1308 3273 3053
206 802 233 1771 2786 1308 0 2815 2934
2976 2013 2684 1307 1131 3273 2815 0 808
3095 2142 2799 1235 379 3053 2934 808 0
@VictorGarritano
VictorGarritano / fourier_coeff.py
Last active August 13, 2017 14:05
coeficientes de fourier
import numpy as np
def trapezio(k, n, x0, xn, func, f_aux):
h = float((xn - x0)) / (n-1)
xs = np.linspace(x0, xn, n)
summation = func(f_aux, k, x0) + func(f_aux, k, xn)
for idx in range(1, n-1):
summation += 2*func(f_aux, k, xs[idx])
import pandas as pd
import numpy as np
from sklearn.model_selection import GridSearchCV
from sklearn import metrics
import matplotlib.pyplot as plt
import xgboost as xgb
from xgboost.sklearn import XGBClassifier
df = pd.read_csv('new_train.csv')
print 'number of features', df.shape[1]
@VictorGarritano
VictorGarritano / mergesort.py
Last active May 8, 2017 21:39
algoritmos de ordenação no Python 2
def merge_sort(alist):
'''
###########
DIVISAO
###########
'''
print 'Splitting ', alist
#Se a lista tiver mais do que um elemento...
if len(alist) > 1:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
import sys
import copy
from math import cos, sin
from plyfile import PlyData, PlyElement
@VictorGarritano
VictorGarritano / cn.py
Created April 21, 2017 15:49
Código da queda livre com y(0) = 2000 e y(1) = 0 via diferenças finitas (Atualmente sem usar o Gauss-Jacobi ou Gauss-Seidel para resolver...)
# -*- coding: utf-8 -*-
"""
Queda livre via Diferenças Finitas
a = -g
x'' = - g
.
.
.
@VictorGarritano
VictorGarritano / nn_from_scratch.py
Last active March 26, 2017 21:46
Implementação de uma deep neural network, com forward e backward pass (Gradient Descent) implementados from scratch. A função de ativição é a função logística (sigmoid curve) e a função de erro é MSE.
import numpy as np
def sigmoid(x):
return 1.0/(1.0+np.exp(-x))
def sigmoid_prime(x):
return sigmoid(x)*(1-sigmoid(x))
class neural_net:
def __init__(self, eta, numrounds, hidden_nodes):
@VictorGarritano
VictorGarritano / ngram.py
Created March 8, 2017 02:35
n-grams generator
import nltk
def ngram(sentence, n):
input_list = nltk.word_tokenize(sentence)
return zip(*[input_list[i:] for i in xrange(n)])
"""
x = 'Hi, my name is Eric. I work at Syncano and deeply believe all people have the right to freedom'
ngram(x,3)
clear()
function[C] = calculaCosseno(a,b)
C = (a'*b)/(norm(a)*norm(b));
endfunction
function[] = plota(v_i)
t = 0:0.1:5
v_i = v_i/norm(v_i)
plot(t*v_i(1),t*v_i(2))
endfunction
function[C] = calculaCosseno(a,b)
C = (a'*b)/ (norm(a)*norm(b));
endfunction
function[] = plota(v_i)
t = 0:0.1:5
v_i = v_i/norm(v_i)
plot(t*v_i(1),t*v_i(2))
endfunction