Commit 9f90b40a authored by Your Name's avatar Your Name
Browse files

adjusted regression model

parent 7fcf1d76
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -77,6 +77,19 @@ def calculate_empties(df, threshold): ...@@ -77,6 +77,19 @@ def calculate_empties(df, threshold):
empties_indices.pop(idx) empties_indices.pop(idx)
return empties_indices return empties_indices
def calculate_empties_adaptive(df, threshold):
top_thresh = df.inter_pol.mean() + (df.inter_pol.std() * 0.75)
empties_indices = []
for idx,val in enumerate(df['inter_pol']):
if idx != 0 and (df['inter_pol'][idx-1]*threshold < (df['inter_pol'][idx])) and (df['inter_pol'][idx] > top_thresh):
empties_indices.append(idx)
# filter out double values
for idx,val in enumerate(empties_indices):
if idx !=0 and (empties_indices[idx] - empties_indices[idx-1]) < 3:
empties_indices.pop(idx)
return empties_indices
# function calculation empties of container for cluster 0 # function calculation empties of container for cluster 0
def calculate_empties_0(df, threshold): def calculate_empties_0(df, threshold):
empties_indices = [] empties_indices = []
......
...@@ -81,7 +81,7 @@ def predictValues_clust0(input): ...@@ -81,7 +81,7 @@ def predictValues_clust0(input):
pred_list = list() pred_list = list()
temp_list = input['inter_pol'].tolist() temp_list = input['inter_pol'].tolist()
emptie_checkpoints = preprocessing.calculate_empties_0(input, 1.01) emptie_checkpoints = preprocessing.calculate_empties_adaptive(input, 1.015)
for k in range(emptie_checkpoints[0]): for k in range(emptie_checkpoints[0]):
y = -3.62261628 * k + temp_list[0] y = -3.62261628 * k + temp_list[0]
...@@ -114,7 +114,7 @@ def predictValues_clust1(input): ...@@ -114,7 +114,7 @@ def predictValues_clust1(input):
pred_list = list() pred_list = list()
temp_list = input['inter_pol'].tolist() temp_list = input['inter_pol'].tolist()
emptie_checkpoints = preprocessing.calculate_empties_1(input, 1.17) emptie_checkpoints = preprocessing.calculate_empties_adaptive(input, 1.015)
for k in range(emptie_checkpoints[0]): for k in range(emptie_checkpoints[0]):
y = -3.63041747 * k + temp_list[0] y = -3.63041747 * k + temp_list[0]
...@@ -146,7 +146,7 @@ def predictValues_clust2(input): ...@@ -146,7 +146,7 @@ def predictValues_clust2(input):
pred_list = list() pred_list = list()
temp_list = input['inter_pol'].tolist() temp_list = input['inter_pol'].tolist()
emptie_checkpoints = preprocessing.calculate_empties_2(input, 1.16) emptie_checkpoints = preprocessing.calculate_empties_adaptive(input, 1.015)
for k in range(emptie_checkpoints[0]): for k in range(emptie_checkpoints[0]):
y = -3.62261628 * k + temp_list[0] y = -3.62261628 * k + temp_list[0]
...@@ -204,13 +204,13 @@ def linearRegressionPlot_pred(input, cluster): ...@@ -204,13 +204,13 @@ def linearRegressionPlot_pred(input, cluster):
if cluster == 0: if cluster == 0:
predicted = predictValues_clust0(input) predicted = predictValues_clust0(input)
empties = preprocessing.calculate_empties_0(input, 1.10) empties = preprocessing.calculate_empties_adaptive(input, 1.015)
elif cluster == 1: elif cluster == 1:
predicted = predictValues_clust1(input) predicted = predictValues_clust1(input)
empties = preprocessing.calculate_empties_1(input, 1.17) empties = preprocessing.calculate_empties_adaptive(input, 1.015)
else: else:
predicted = predictValues_clust2(input) predicted = predictValues_clust2(input)
empties = preprocessing.calculate_empties_2(input, 1.16) empties = preprocessing.calculate_empties_adaptive(input, 1.015)
plt.plot(predicted) plt.plot(predicted)
plt.legend(['Preprocessed', 'Predictions'], loc='upper left') plt.legend(['Preprocessed', 'Predictions'], loc='upper left')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment