Skip to content

Instantly share code, notes, and snippets.

View compmonks's full-sized avatar
💭
Busy Monkey

Pierre Cutellic compmonks

💭
Busy Monkey
View GitHub Profile
@compmonks
compmonks / Blob.mtl
Created July 20, 2018 14:32
Blob files
newmtl polkadots
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0 0 0
Kd 0 0 0
Ks 0.0000 0.0000 0.0000
def onlinePredictBy(self, newdata, k=5, wt='distance'):
"""Return online predicted values of a target array"""
self.newdata = newdata
# build an index array except the ones containing the target
self.dim = newdata.shape[1]
self.ind = np.arange(0, self.dim)
self.ind = np.setdiff1d(self.ind,self.target)
self.x = self.SOM.codebook.matrix[:,self.ind]
self.y = self.SOM.codebook.matrix[:,self.target]
self.n_neighbors = k
@compmonks
compmonks / train_test.py
Last active January 16, 2018 18:10
appending previous codebook matrix in the dataset
#ie: allData.shape = (587, 165)
# old_codebook_matrix.shape = (2500, 165)
from sklearn.metrics import accuracy_score
#...
if the_codebook != None:
the_codebook = h5py.File(str(the_codebook),'r')
old_codebook_matrix = the_codebook['codebook/matrix']
split_point = math.floor(allData.shape[0]/2)
train_set = allData[:split_point] # splitting allData for train/test
@compmonks
compmonks / sompy.py
Last active January 15, 2018 09:33
SOM init with a previous codebook
class SOM(object):
def __init__(self,
data,
neighborhood,
prev_codebook_matrix=None, # initialization with previous codebook matrix
normalizer=None,
mapsize=None,
mask=None,
mapshape='planar',
lattice='rect',
@compmonks
compmonks / plotBmusOnSignal.py
Created January 15, 2018 09:03
plotting bmus on signal
# ex: data.spahe -> (603, 165)
# bmus shape - > (603,)
def plotOnSignal(self,s=10,cmap="viridis",data):
"""Plot Bmus on top of the rawData. Plotting in Context."""
bmus = self.SOM.project_data(data)
rows = data.shape[0]
#
plt.title('BMUS on FEEDBACK DATA')
@compmonks
compmonks / form.js
Last active July 30, 2017 18:21
node-mandrill tests
// directory
//
// public(folder)
// --app.js
// --js(folder)
// ----form.js
var contactForm = document.getElementById( 'contactForm' );
new stepsForm( contactForm, {
@compmonks
compmonks / app.js
Last active July 30, 2017 18:20
node-mandrill tests
// directory
//
// public(folder)
// --app.js
// --js(folder)
// ----form.js
// app.js