-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from antoinecarme/missing_data
Missing data
- Loading branch information
Showing
434 changed files
with
51,624 additions
and
32,148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
|
||
|
||
|
||
def gen_all_air_passengers(): | ||
lDir = "tests/missing_data" | ||
for iTimeImp in [None , "DiscardRow", "Interpolate"]: | ||
for iSigImp in [None , "DiscardRow", "Interpolate", "Mean", "Median" , "Constant" , "PreviousValue"]: | ||
filename = lDir + "/test_missing_data_air_passengers_" + str(iTimeImp) + "_" + str(iSigImp) + ".py"; | ||
with open(filename, "w") as outfile: | ||
print("WRTITING_FILE" , filename) | ||
outfile.write("import tests.missing_data.test_missing_data_air_passengers_generic as gen\n\n") | ||
outfile.write("gen.test_air_passengers_missing_data" + str((iTimeImp , iSigImp)) + "\n") | ||
|
||
# gen_all_air_passengers() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
|
||
|
||
|
||
def gen_all_ozone(): | ||
lDir = "tests/missing_data" | ||
for iTimeImp in [None , "DiscardRow", "Interpolate"]: | ||
for iSigImp in [None , "DiscardRow", "Interpolate", "Mean", "Median" , "Constant" , "PreviousValue"]: | ||
filename = lDir + "/test_missing_data_ozone_" + str(iTimeImp) + "_" + str(iSigImp) + ".py"; | ||
with open(filename, "w") as outfile: | ||
print("WRTITING_FILE" , filename) | ||
outfile.write("import tests.missing_data.test_missing_data_ozone_generic as gen\n\n") | ||
outfile.write("gen.test_ozone_missing_data" + str((iTimeImp , iSigImp)) + "\n") | ||
|
||
# gen_all_ozone() |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_Constant.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', 'Constant') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_DiscardRow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', 'DiscardRow') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_Interpolate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', 'Interpolate') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_Mean.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', 'Mean') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_Median.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', 'Median') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_None.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', None) |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_DiscardRow_PreviousValue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('DiscardRow', 'PreviousValue') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_Constant.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', 'Constant') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_DiscardRow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', 'DiscardRow') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_Interpolate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', 'Interpolate') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_Mean.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', 'Mean') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_Median.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', 'Median') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_None.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', None) |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_Interpolate_PreviousValue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data('Interpolate', 'PreviousValue') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_Constant.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, 'Constant') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_DiscardRow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, 'DiscardRow') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_Interpolate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, 'Interpolate') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_Mean.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, 'Mean') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_Median.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, 'Median') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_None.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, None) |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_air_passengers_None_PreviousValue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_air_passengers_generic as gen | ||
|
||
gen.test_air_passengers_missing_data(None, 'PreviousValue') |
54 changes: 54 additions & 0 deletions
54
tests/missing_data/test_missing_data_air_passengers_generic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
import pandas as pd | ||
import numpy as np | ||
|
||
|
||
import pyaf.ForecastEngine as autof | ||
import pyaf.Bench.TS_datasets as tsds | ||
|
||
def add_some_missing_data_in_signal(df, col): | ||
lRate = 0.2 | ||
df.loc[df.sample(frac=lRate, random_state=1960).index, col] = np.nan | ||
return df | ||
|
||
def add_some_missing_data_in_time(df, col): | ||
lRate = 0.2 | ||
df.loc[df.sample(frac=lRate, random_state=1960).index, col] = np.nan | ||
return df | ||
|
||
|
||
def test_air_passengers_missing_data(iTimeMissingDataImputation, iSignalMissingDataImputation): | ||
|
||
b1 = tsds.load_airline_passengers() | ||
df = b1.mPastData | ||
|
||
if(iTimeMissingDataImputation is not None): | ||
df = add_some_missing_data_in_time(df, b1.mTimeVar) | ||
if(iSignalMissingDataImputation is not None): | ||
df = add_some_missing_data_in_signal(df, b1.mSignalVar) | ||
|
||
lEngine = autof.cForecastEngine() | ||
H = b1.mHorizon; | ||
lEngine.mOptions.mMissingDataOptions.mTimeMissingDataImputation = iTimeMissingDataImputation | ||
lEngine.mOptions.mMissingDataOptions.mSignalMissingDataImputation = iSignalMissingDataImputation | ||
lEngine.train(df , b1.mTimeVar , b1.mSignalVar, H); | ||
lEngine.getModelInfo(); | ||
print(lEngine.mSignalDecomposition.mTrPerfDetails.head()); | ||
|
||
dfapp_in = df.copy(); | ||
dfapp_in.tail() | ||
dfapp_out = lEngine.forecast(dfapp_in, H); | ||
#dfapp_out.to_csv("outputs/ozone_apply_out.csv") | ||
dfapp_out.tail(2 * H) | ||
print("Forecast Columns " , dfapp_out.columns); | ||
Forecast_DF = dfapp_out[[b1.mTimeVar , b1.mSignalVar, b1.mSignalVar + '_Forecast']] | ||
print(Forecast_DF.info()) | ||
print("Forecasts\n" , Forecast_DF.tail(H)); | ||
|
||
print("\n\n<ModelInfo>") | ||
print(lEngine.to_json()); | ||
print("</ModelInfo>\n\n") | ||
print("\n\n<Forecast>") | ||
print(Forecast_DF.tail(2*H).to_json(date_format='iso')) | ||
print("</Forecast>\n\n") | ||
|
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_Constant.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', 'Constant') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_DiscardRow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', 'DiscardRow') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_Interpolate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', 'Interpolate') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_Mean.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', 'Mean') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_Median.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', 'Median') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_None.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', None) |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_DiscardRow_PreviousValue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('DiscardRow', 'PreviousValue') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_Constant.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', 'Constant') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_DiscardRow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', 'DiscardRow') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_Interpolate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', 'Interpolate') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_Mean.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', 'Mean') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_Median.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', 'Median') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_None.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', None) |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_Interpolate_PreviousValue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data('Interpolate', 'PreviousValue') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, 'Constant') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_None_DiscardRow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, 'DiscardRow') |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_None_Interpolate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, 'Interpolate') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, 'Mean') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, 'Median') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, None) |
3 changes: 3 additions & 0 deletions
3
tests/missing_data/test_missing_data_ozone_None_PreviousValue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import tests.missing_data.test_missing_data_ozone_generic as gen | ||
|
||
gen.test_ozone_missing_data(None, 'PreviousValue') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
import pandas as pd | ||
import numpy as np | ||
|
||
|
||
import pyaf.ForecastEngine as autof | ||
import pyaf.Bench.TS_datasets as tsds | ||
|
||
def add_some_missing_data_in_signal(df, col): | ||
lRate = 0.2 | ||
df.loc[df.sample(frac=lRate, random_state=1960).index, col] = np.nan | ||
return df | ||
|
||
def add_some_missing_data_in_time(df, col): | ||
lRate = 0.2 | ||
df.loc[df.sample(frac=lRate, random_state=1960).index, col] = np.nan | ||
return df | ||
|
||
|
||
def test_ozone_missing_data(iTimeMissingDataImputation, iSignalMissingDataImputation): | ||
|
||
b1 = tsds.load_ozone() | ||
df = b1.mPastData | ||
|
||
if(iTimeMissingDataImputation is not None): | ||
df = add_some_missing_data_in_time(df, b1.mTimeVar) | ||
if(iSignalMissingDataImputation is not None): | ||
df = add_some_missing_data_in_signal(df, b1.mSignalVar) | ||
|
||
lEngine = autof.cForecastEngine() | ||
H = b1.mHorizon; | ||
lEngine.mOptions.mMissingDataOptions.mTimeMissingDataImputation = iTimeMissingDataImputation | ||
lEngine.mOptions.mMissingDataOptions.mSignalMissingDataImputation = iSignalMissingDataImputation | ||
lEngine.train(df , b1.mTimeVar , b1.mSignalVar, H); | ||
lEngine.getModelInfo(); | ||
print(lEngine.mSignalDecomposition.mTrPerfDetails.head()); | ||
|
||
dfapp_in = df.copy(); | ||
dfapp_in.tail() | ||
dfapp_out = lEngine.forecast(dfapp_in, H); | ||
#dfapp_out.to_csv("outputs/ozone_apply_out.csv") | ||
dfapp_out.tail(2 * H) | ||
print("Forecast Columns " , dfapp_out.columns); | ||
Forecast_DF = dfapp_out[[b1.mTimeVar , b1.mSignalVar, b1.mSignalVar + '_Forecast']] | ||
print(Forecast_DF.info()) | ||
print("Forecasts\n" , Forecast_DF.tail(H)); | ||
|
||
print("\n\n<ModelInfo>") | ||
print(lEngine.to_json()); | ||
print("</ModelInfo>\n\n") | ||
print("\n\n<Forecast>") | ||
print(Forecast_DF.tail(2*H).to_json(date_format='iso')) | ||
print("</Forecast>\n\n") | ||
|
Oops, something went wrong.