-
Notifications
You must be signed in to change notification settings - Fork 1
/
CNN_Classification.py
53 lines (40 loc) · 2.13 KB
/
CNN_Classification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 14 17:47:34 2020
@author: troullinou
"""
#------------------------------------------------------------------------------------------------
import pickle
from functions import CNN_classifier, predictions
# Load the Data
with open('data/calcium_signal_df_f_all.pkl', 'rb') as file:
df_f = pickle.load(file)
with open('data/velocity_all.pkl', 'rb') as file:
vel = pickle.load(file)
with open('data/depth_all.pkl', 'rb') as file:
dep = pickle.load(file)
with open('data/position_all.pkl', 'rb') as file:
pos = pickle.load(file)
with open('data/labels_all.pkl', 'rb') as file:
labels = pickle.load(file)
# DATASET PARAMETERS
sample = 'semi_balanced' # options: 'min_categ', 'semi_balanced', 'imbalanced'
balance = 'equal' # options: 'equal', 'stratified' (number of training examples for the merged categories)
categs = [['BC','AAC'], ['SOM', 'BISTR'], ['CCK']] # neuron cell-types selection
test_size = [[100, 100], [100, 100], [100]] # test set size
size = [1000, 1000, 0] # number of extra examples for each category when the category parameter is defined as 'semi-balanced'
# MODEL PARAMETERS
num_iters = 5 # number of random train-test splits
epochs = 100 # number of epochs
results, model = CNN_classifier(calcium_df_f=df_f, position=pos, labels=labels,
categories=categs, test_size=test_size,
sampling=sample, balance=balance, epochs=epochs,
number_of_iterations=num_iters, size_increased=size,
velocity=vel, depth=dep, plot=True)
# to make new predictions on new data
# preds = predictions(calcium_df_f=df_f, new_df_f=df_f, position=pos, labels=labels,
# categories=categs, test_size=test_size,
# sampling=sample, balance=balance, epochs=epochs,
# number_of_iterations=num_iters, size_increased=size,
# velocity=vel, depth=dep, plot=False,
# new_velocity=vel, new_depth=dep)