-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimplePipeline.py
95 lines (85 loc) · 3.86 KB
/
simplePipeline.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
89
90
91
92
93
94
95
import time
import mlutilities.utilities as mlutils
import thesisFunctions
import constants
startSecond = time.time()
startTime = time.strftime('%a, %d %b %Y %X')
# Parameters
runScaleDatasets = True
runFeatureEngineering = False
runEnsembleModels = False
multiThreadApplyModels = True
randomSeed = constants.randomSeed
month = 'jul'
region = 'IntMnt'
basePath = 'Data/'
universalTestSetFileName = month + '_' + region + '_test.csv'
universalTestSetDescription = month.capitalize() + ' ' + region + ' Test'
scoreOutputFilePath = 'Output/testResults.csv'
myFeaturesIndex = 6
myLabelIndex = 5
selectedFeatureList = ['p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'p10', 'p11', 'p12',
't0', 't1', 't2', 't3', 't4', 't5', 't6', 't7', 't8', 't9', 't10', 't11', 't12',
'p2sum', 'p3sum', 'p6sum', 'PERMAVE', 'RFACT', 'DRAIN_SQKM', 'ELEV_MEAN_M_BASIN_30M',
'WD_BASIN']
# Run the pipeline
flowModelResult = thesisFunctions.flowModelPipeline(universalTestSetFileName,
universalTestSetDescription,
basePath,
scoreOutputFilePath,
myFeaturesIndex,
myLabelIndex,
selectedFeatureList=selectedFeatureList,
randomSeed=randomSeed,
runScaleDatasets=runScaleDatasets,
runFeatureEngineering=runFeatureEngineering,
runEnsembleModels=runEnsembleModels,
multiThreadApplyModels=multiThreadApplyModels)
endSecond = time.time()
endTime = time.strftime('%a, %d %b %Y %X')
totalSeconds = endSecond - startSecond
print()
print('Start time:', startTime)
print('End time:', endTime)
print('Total: {} minutes and {} seconds'.format(int(totalSeconds // 60), round(totalSeconds % 60)))
# Visualization
dryYearScoreModelResultsDF = flowModelResult[flowModelResult['Base DataSet'].str.contains('Dry')]
mlutils.scatterPlot(flowModelResult,
'Mean Squared Error',
'R Squared',
'MSE by R Squared for Each Model',
'Output/mseByR2AllModels.png',
'#2d974d')
mlutils.scatterPlot(dryYearScoreModelResultsDF,
'Mean Squared Error',
'R Squared',
'MSE by R Squared for Each Model (Dry Year Models Only)',
'Output/mseByR2DryModels.png',
'#2d974d')
mlutils.scatterPlot(flowModelResult,
'RMSE (cfs)',
'R Squared',
'RMSE by R Squared for Each Model',
'Output/rmseByR2AllModels.png',
'#2d974d')
mlutils.scatterPlot(dryYearScoreModelResultsDF,
'RMSE (cfs)',
'R Squared',
'RMSE by R Squared for Each Model (Dry Year Models Only)',
'Output/rmseByR2DryModels.png',
'#2d974d')
mlutils.barChart(flowModelResult,
'Mean Squared Error',
'MSE for Each Model',
'Output/meanSquaredError.png',
'#2d974d')
mlutils.barChart(flowModelResult,
'RMSE (cfs)',
'Root Mean Squared Error for Each Model',
'Output/rootMeanSquaredError.png',
'#2d974d')
mlutils.barChart(flowModelResult,
'R Squared',
'R Squared for Each Model',
'Output/rSquared.png',
'#2d974d')