-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.py
executable file
·88 lines (67 loc) · 3.25 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import random
from machine_learning.classification import compare_classification_parameters
from machine_learning.neural_network_prediction import neural_network_prediction
from machine_learning.regression import compute_regression_results
from preprocessing.analysis import apply_pca, apply_kernel_pca, apply_anova_f_value_test, \
apply_variance_threshold_selection, plot_progress_measure
from preprocessing.features import extract_features
random.seed(0) # keep seed fixed for reproducibility
def use_classification(data, config, target_name='success'):
compare_classification_parameters(data['categorical_features'], data[target_name], config)
def use_regression(data, config, target_name='progress'):
compute_regression_results(data['categorical_features'], data[target_name], target_name, config)
#features, labels, yards, progress = get_team_features("NO", features, labels, "team")
#compute_regression_results(features, yards, "./regression_results_team_NO_yards")
#compute_regression_results(features, progress, "./regression_results_team_NO_progress")
def use_neural_networks(data, config, measure='progress', layer_type='tanh'):
neural_network_prediction(data=data,
config=config,
team='all',
measure=measure,
load_previous=True,
layer_type=layer_type)
def __main__():
config = {
'start_year': 2009,
'end_year': 2014,
'predict_yards': True,
'predict_progress': True,
'predict_success': True,
'prediction_method_success': 'classification',
'prediction_method_yards': 'regression',
'prediction_method_progress': 'regression',
'use_neural_networks': True,
'neural_net_config': {
'k_fold': 5,
'epochs': [1],
'hidden_layers': [1],
'hidden_units': [1],
'load_previous': True,
'tanh': True,
'sigmoid': True,
'linear': True
},
'grid_search': False
}
print config
print 'getting data'
data = extract_features(start_year=config['start_year'], end_year=config['end_year'])
print 'finished getting data'
print 'starting prediction'
for measure in ['success', 'yards', 'progress']:
if config['predict_%s' % measure]:
print 'predicting %s measure' % measure
if config['prediction_method_%s' % measure] == 'regression':
use_regression(data, config, measure)
else:
use_classification(data, config, measure)
if config['use_neural_networks']:
for layer_type in ['tanh', 'sigmoid', 'linear']:
if config['neural_net_config'][layer_type]:
use_neural_networks(data, config, measure=measure, layer_type=layer_type)
apply_pca(data['categorical_features'])
apply_kernel_pca(data['categorical_features'], data['success'])
apply_anova_f_value_test(data['categorical_features'], data['success'], data['encoder'])
apply_variance_threshold_selection(data['categorical_features'], data['success'], data['encoder'])
plot_progress_measure()
__main__()