Extract definition of function.

update_libs
junos 2023-04-12 15:58:43 +02:00
parent 27b90421bf
commit d678be0641
3 changed files with 16 additions and 10 deletions

View File

@ -27,4 +27,4 @@ dependencies:
- xgboost - xgboost
- pip: - pip:
- biosppy - biosppy
- cr_features - cr_features>=0.2

View File

@ -150,13 +150,15 @@ def straw_cleaning(sensor_data_files, provider):
return features return features
def impute(df, method='zero'):
def k_nearest(df): def k_nearest(df):
pd.set_option('display.max_columns', None) pd.set_option('display.max_columns', None)
imputer = KNNImputer(n_neighbors=3) imputer = KNNImputer(n_neighbors=3)
return pd.DataFrame(imputer.fit_transform(df), columns=df.columns) return pd.DataFrame(imputer.fit_transform(df), columns=df.columns)
def impute(df, method='zero'):
return { return {
'zero': df.fillna(0), 'zero': df.fillna(0),
'high_number': df.fillna(1500), 'high_number': df.fillna(1500),
@ -165,6 +167,7 @@ def impute(df, method='zero'):
'knn': k_nearest(df) 'knn': k_nearest(df)
}[method] }[method]
def graph_bf_af(features, phase_name, plt_flag=False): def graph_bf_af(features, phase_name, plt_flag=False):
if plt_flag: if plt_flag:
sns.set(rc={"figure.figsize":(16, 8)}) sns.set(rc={"figure.figsize":(16, 8)})

View File

@ -245,12 +245,14 @@ def straw_cleaning(sensor_data_files, provider, target):
return features return features
def impute(df, method='zero'):
def k_nearest(df): def k_nearest(df):
imputer = KNNImputer(n_neighbors=3) imputer = KNNImputer(n_neighbors=3)
return pd.DataFrame(imputer.fit_transform(df), columns=df.columns) return pd.DataFrame(imputer.fit_transform(df), columns=df.columns)
def impute(df, method='zero'):
return { return {
'zero': df.fillna(0), 'zero': df.fillna(0),
'high_number': df.fillna(1500), 'high_number': df.fillna(1500),
@ -259,6 +261,7 @@ def impute(df, method='zero'):
'knn': k_nearest(df) 'knn': k_nearest(df)
}[method] }[method]
def graph_bf_af(features, phase_name, plt_flag=False): def graph_bf_af(features, phase_name, plt_flag=False):
if plt_flag: if plt_flag:
sns.set(rc={"figure.figsize":(16, 8)}) sns.set(rc={"figure.figsize":(16, 8)})