#!/usr/bin/env python # encoding: utf-8 import datetime import numpy as np import matplotlib.pyplot as pl from sklearn.linear_model import LogisticRegression from mpl_toolkits.mplot3d import Axes3D from example.hallem.data import Hallem import toydata from _core import validation hallem = Hallem() data = np.transpose(hallem.response) print data.shape big_matrix, labels = toydata.generate_noise_samples(data) c_range = np.arange(0.001, 0.008, 0.00001) f = [] a = [] b1 = True b2 = True print "### regularizationaraitining" ## Probing over C for c in c_range: lr = LogisticRegression(penalty='l1', C=c)
#!/usr/bin/env python # encoding: utf-8 """ Compute the correlation one-to-all of a specified odorant. """ import scipy as sp import pylab as pl import numpy as np from scipy import stats from example.hallem.data import Hallem hallem = Hallem() data = hallem.response o1 = hallem.get_odorant_index("E2 Hexenol") o1_name = hallem.odorant_list[o1] o1_spec = data[o1] correlations = [] for i, spec in enumerate(data): o2 = i o2_name = hallem.odorant_list[o2] o2_spec = spec c = sp.stats.pearsonr(o1_spec, o2_spec)[0] correlations.append(c) print o2_name, c correlations = np.round(np.asarray(correlations), 3)
""" Analysis of stability of backward prediction. Since we have no test set, like in many machine learning tasks, we generate one from the original data. For each glomerulus we create 100 samples and classify them according to the glomerulus they are based on. For different levels of noise, the accuracy of prediction is measured, e.g. how many labels could be predicted correctly. """ import numpy as np import matplotlib.pyplot as pl from example.hallem.data import Hallem from _core import featureselection, validation data = np.transpose(Hallem().response) # compute features feature_list, scores = featureselection.backward_elimination(data) # creating a list of feature lists with increasing size top = [] for i in range(15): top.append((feature_list[:i + 1])[::-1]) # # levels of noise which will be added sd_range = range(0, 50, 10) results = validation.validate(data, top, noise=sd_range) np.set_printoptions(suppress=True, precision=3)
#!/usr/bin/env python # encoding: utf-8 ''' Compute the euclidean distance of the reference set (deBruyne) on Hallem and DoOR. ''' import numpy as np from scipy.spatial import distance from example.hallem.data import Hallem from example.dorsal_door import DoOR hallem = Hallem() data, or_list, odorants = hallem.get_reference_set() title = "Diagnostic set from DeBruyne 2001 on Hallem" path = "figures/debruyne_hallem.png" #plotting.plot_fingerprints(title, odorants, data, or_list, path) print "Euclidean distance Hallem:", np.min(distance.pdist(data, 'euclidean')) door = DoOR() door_data, door_ors, door_odorants = door.get_dorsal_reference_data() print "Euclidean distance DoOR:", np.min( distance.pdist(door_data, 'euclidean')) title = "Diagnostic set from DeBruyne 2001 on dorsal DoOR" path = "figures/debruyne_door.png" #plotting.plot_fingerprints(title, door_odorants, door_data, door_ors, path)