Skip to content

Instantly share code, notes, and snippets.

View gleydson404's full-sized avatar

Gleydson Cavalcante gleydson404

  • @ALDI-SOUTH-IT
  • Mülhein an der Rhur, Germany
View GitHub Profile
@gleydson404
gleydson404 / Nama.py
Last active May 9, 2016 20:17
Gist created just to show a litle exercise code in a startup test.
# The given problem was basicly make a count from 1 to 100, and where has a multiple of three, should to have 'Na',
# where has a multiple of 5 should to have 'ma' and
# where has a multiple of 15 should to have 'nama'.
# I made the task by 4 diferent ways
# At the end of the file, there is a simple print with a call to each function, just to print the result on the screen
# Follow the code
# creating a dictionary just to not use magic numbers
@gleydson404
gleydson404 / dtree.py
Created October 19, 2015 19:05
Implementação de árvore de decisão com o algoritmo ID3
# coding: utf-8
import collections
def majority_value(data, target_attr):
"""
Cria uma lista com todos os valores do atributo passado para cada registro
e retorna os valores que aparecem com maior frequencia para este atributo
"""
data = data[:]
return most_frequent([record[target_attr] for record in data])