Skip to content

Instantly share code, notes, and snippets.

@DavidSanf0rd
DavidSanf0rd / tictactoe.kt
Last active December 14, 2017 15:10
ic: Tic tac toe in kotlin
package br.ind.sanford.tictactoe
/**
* Created by sanf0rd on 14/09/17.
*/
import java.util.ArrayList
internal class TicTacToe {
//singleton methods
var board: String
@DavidSanf0rd
DavidSanf0rd / DMC.py
Created December 14, 2017 15:03
ic: KNN e DMC
import sklearn
import plotly.plotly as py
import plotly.graph_objs as go
from plotly import tools
import numpy as np
from sklearn import datasets
from sklearn.neighbors import NearestCentroid
n_neighbors = 15
@DavidSanf0rd
DavidSanf0rd / decision_tree.py
Created December 14, 2017 14:56
ic: decision tree
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import confusion_matrix
from copy import deepcopy
import numpy as npy
import pandas as pd
from matplotlib import pyplot as plt
class KMeans:
def __init__(self, k, file_name):
self.k = k
@DavidSanf0rd
DavidSanf0rd / apriori.py
Created December 14, 2017 14:44
IC: A priori
from collections import namedtuple
from itertools import combinations
import pandas as pd
def apriori(transactions, **kwargs):
min_support = kwargs.get('min_support', 0.1)
min_confidence = kwargs.get('min_confidence', 0.0)
min_lift = kwargs.get('min_lift', 0.0)
@DavidSanf0rd
DavidSanf0rd / Main.java
Last active June 21, 2017 13:22
Java completion handler
/**
* Created by sanf0rd on 21/06/17.
*/
public class Main {
public static void main(String[] args) {
Wrapper wrapper = new Wrapper();
wrapper.doStuff(result -> System.out.println(result));
}
@DavidSanf0rd
DavidSanf0rd / KotlinReflection.kt
Created June 20, 2017 00:39
Using kotlin reflection to get the name, type and values of any class properties
import kotlin.reflect.full.declaredMemberProperties
/**
* Created by sanf0rd on 19/06/17.
*/
fun readProperties(instance: Any) {
val clazz = instance.javaClass.kotlin
clazz.declaredMemberProperties.forEach {
println("${it.name} --[${it.returnType}]---> ${it.get(instance)}")