Instantly share code, notes, and snippets.

# Marcelmarcelcaraciolo

• Sort options
Last active Aug 7, 2019
Logistic prediction
View log_regression.py
 def sigmoid(X): '''Compute the sigmoid function ''' #d = zeros(shape=(X.shape)) den = 1.0 + e ** (-1.0 * X) d = 1.0 / den return d
Created Oct 29, 2012
Atepassar Simple Algorithm for Friends Recommendation
View atepassar_recommender.py
 #-*-coding: utf-8 -*- ''' This module represents the FriendsRecommender system for recommending new friends based on friendship similarity and state similarity. ''' __author__ = 'Marcel Caraciolo '
Created Mar 16, 2013
View megasena.py
 import requests from BeautifulSoup import BeautifulSoup def megasena_api(): URL_ULTIMOS_RESULTADOS = 'http://www1.caixa.gov.br/loterias/loterias/megasena/megasena_pesquisa_new.asp' page = requests.get(URL_ULTIMOS_RESULTADOS) bs = BeautifulSoup(page.content) numeros_sena = [ n.contents[0] for n in bs.findAll('li')[:6]] results = page.content.split('|')
Created Oct 28, 2011
multivariate linear regression
View multlin.py
 from numpy import loadtxt, zeros, ones, array, linspace, logspace, mean, std, arange from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from pylab import plot, show, xlabel, ylabel #Evaluate the linear regression def feature_normalize(X): ''' Returns a normalized version of X where
Created Mar 16, 2013
View municipios_brasil.py
 from urllib2 import urlopen from BeautifulSoup import BeautifulSoup from time import sleep BASE_URL = "http://www.cidades.com.br/" def make_soup(url): html = urlopen(url).read() return BeautifulSoup(html)
Created Sep 15, 2011
bm25f
View bmf25.py
 # BM25F Model def bm25(idf, tf, fl, avgfl, B, K1): # idf - inverse document frequency # tf - term frequency in the current document # fl - field length in the current document # avgfl - average field length across documents in collection # B, K1 - free paramters return idf * ((tf * (K1 + 1)) / (tf + K1 * (1 - B + B * (fl / avgfl))))
Created Oct 28, 2011
linear regression
View linregr.py
 from numpy import loadtxt, zeros, ones, array, linspace, logspace from pylab import scatter, show, title, xlabel, ylabel, plot, contour #Evaluate the linear regression def compute_cost(X, y, theta): ''' Comput cost for linear regression ''' #Number of training samples
Created Dec 4, 2011
apriori_rules.py
View Apriori_rules.py
 def generateRules(L, support_data, min_confidence=0.7): """Create the association rules L: list of frequent item sets support_data: support data for those itemsets min_confidence: minimum confidence threshold """ rules = [] for i in range(1, len(L)): for freqSet in L[i]:
Created Jan 13, 2012
tf-idf example
View tf_idf_final.py
 #-*- coding: utf-8 -*- import re import nltk from nltk.tokenize import RegexpTokenizer from nltk import bigrams, trigrams import math stopwords = nltk.corpus.stopwords.words('portuguese')
Created Oct 28, 2011
linear regression
View linregr.py
 #Evaluate the linear regression def compute_cost(X, y, theta): ''' Comput cost for linear regression ''' #Number of training samples m = y.size predictions = X.dot(theta).flatten()
You can’t perform that action at this time.