def all_features_li_2019_classifier_ffnn_rul_prediction():
    training_set = read_dfs(LEARNING_SET, ALL_FEATURES)
    # Two-Stage: lei et al 2019
    training_set, first_prediction_times = cut_fpts(training_set)
    training_set = procentual_rul(training_set, first_prediction_times)

    # Visualize FPTs
    plot_fpts(first_prediction_times, training_set, 'fourier_entropy')

    # Concatenate trainings data
    concatenated_training_set = pd.concat(
        training_set,
        ignore_index=True,
        keys=['Bearing' + str(x) for x in range(0, len(training_set))])
    labels = concatenated_training_set.pop('RUL')

    # Train FFNN
    trainings_history, ffnn = fit_ffnn(X=concatenated_training_set,
                                       y=labels,
                                       dropout=True,
                                       epochs=50)

    # Visualize training history and later validation history
    plot_trainings_history(trainings_history)
    # Visualize predicted RUL in comparison to real RUL of learning set
    plot_rul_comparisons(training_set, prediction_model=ffnn)

    # TESTING ESTIMATIONS #
    testing_set = read_dfs(FULL_TEST_SET, ALL_FEATURES)
    testing_set, fpts = cut_fpts(testing_set)
    testing_set = procentual_rul(testing_set, fpts)
    plot_rul_comparisons(testing_set, prediction_model=ffnn)
Esempio n. 2
0
def isomap_features_no_classifier_ffnn_rul_prediction(training_data,
                                                      comparison_set):
    # Read Training data
    isomap_training_data = training_data

    # Remove labels
    isomap_training_data = concat_dfs(isomap_training_data)
    labels = isomap_training_data.pop('RUL')
    model_training_data, isomap = isomap_embedded_data_frame(
        isomap_training_data, verbose=False)

    ffnn, training_history = fit_ffnn(model_training_data, labels, epochs=100)

    plot_trainings_history(training_history)
    # Visualize predicted RUL in comparison to real RUL
    #   comparison_set = read_raw_dfs(FULL_TEST_SET)
    # Remove label
    label_data = pop_labels(comparison_set)
    # Apply autoencoder
    comparison_set = [
        pd.DataFrame(isomap.transform(X=df)) for df in comparison_set
    ]

    plot_rul_comparisons(comparison_set,
                         label_data=label_data,
                         prediction_model=ffnn)
Esempio n. 3
0
def ahmad_health_indicator_ahmad_classifier_ffnn_rul_prediction():
    training_set = read_feature_dfs(LEARNING_SET)
    training_labels = pop_labels(training_set)
    training_set = construct_ahmad_health_indicator(training_set)
    training_set = [
        pd.merge(training_set[i],
                 training_labels[i],
                 left_index=True,
                 right_index=True) for i in range(len(training_labels))
    ]
    cut_dfs, fpts = cut_fpts(training_set,
                             fpt_method=ahmad_et_al_2019,
                             signal_key='ahmad_health_indicator')
    plot_fpts(fpts,
              df_list=training_set,
              classification_indicator='ahmad_health_indicator')

    training_set = concat_dfs(training_set)
    training_labels = training_set.pop('RUL')
    ffnn, trainin_history = fit_ffnn(training_set,
                                     training_labels,
                                     dropout=True,
                                     epochs=30,
                                     hidden_layers=3,
                                     hidden_units=128)

    comparison_set = read_feature_dfs(FULL_TEST_SET)
    comparison_set, first_prediction_times = cut_fpts(comparison_set)

    # Remove label
    label_data = pop_labels(comparison_set)
    plot_rul_comparisons(comparison_set,
                         label_data=label_data,
                         prediction_model=ffnn)
def all_features_pca_combination_no_classifier_ffnn_rul_prediction():
    # Read Training data
    feature_list = ALL_FEATURES
    training_data = read_feature_dfs(data_set_sub_set=LEARNING_SET, features=feature_list)
    learning_set = concat_dfs(training_data)
    training_labes = learning_set.pop('RUL')

    # Remove labels
    model_training_data, pca = pca_embedded_data_frame(learning_set, verbose=False)

    model_training_data = pd.DataFrame(model_training_data)
    ffnn, training_history = fit_ffnn(model_training_data, training_labes, epochs=60)  # TODO dropout=True

    plot_trainings_history(training_history)

    # Visualize predicted RUL in comparison to real RUL of training set
    # Remove label
    training_label_data = pop_labels(training_data)
    # Apply PCA
    transformed_training_set = []
    for df in tqdm(training_data, desc="Transforming validation set.", position=0, leave=True):
        transformed_training_set += [pd.DataFrame(pca.transform(X=df))]
    plot_rul_comparisons(transformed_training_set, label_data=training_label_data, prediction_model=ffnn)

    # Visualize predicted RUL in comparison to real RUL of validation set
    comparison_set = read_feature_dfs(data_set_sub_set=FULL_TEST_SET, features=feature_list)
    # Remove label
    label_data = pop_labels(comparison_set)
    # Apply PCA
    transformed_comparison_set = []
    for df in tqdm(comparison_set, desc="Transforming validation set.", position=0, leave=True):
        transformed_comparison_set += [pd.DataFrame(pca.transform(X=df))]

    plot_rul_comparisons(transformed_comparison_set, label_data=label_data, prediction_model=ffnn)
def tba_features_ahmad_et_al_2019_ffnn():
    feature_list = BASIC_STATISTICAL_FEATURES

    fpt_method = ahmad_et_al_2019
    signal_key = "root_mean_square"
    learning_set = read_feature_dfs(data_set_sub_set=LEARNING_SET, features=feature_list)

    # Calculate FPTs and cut dataframes
    cut_learning_set, first_prediction_times = cut_fpts(learning_set, fpt_method=fpt_method,
                                                        signal_key=signal_key)

    plot_fpts(first_prediction_times=first_prediction_times, df_list=learning_set,
              classification_indicator="root_mean_square")

    cut_learning_set = concat_dfs(cut_learning_set)
    training_labes = cut_learning_set.pop('RUL')
    ffnn, trainings_history = fit_ffnn(X=cut_learning_set, y=training_labes, epochs=100)
    # Plot trainings history
    plot_trainings_history(trainings_history=trainings_history, error_type='RMSE')

    # Read test set
    testing_set = read_feature_dfs(data_set_sub_set=FULL_TEST_SET, features=feature_list)
    cut_testing_set, _ = cut_fpts(testing_set, fpt_method=fpt_method, signal_key=signal_key)
    testing_labels = pop_labels(cut_testing_set)

    plot_rul_comparisons(cut_testing_set, testing_labels, ffnn)
Esempio n. 6
0
def all_features_and_autoencoder_li_2019_classifier_ffnn_rul_prediction():
    # Input features: statistical features
    learning_feature_df_list = read_feature_dfs(LEARNING_SET,
                                                FEATURES_CSV_NAME)

    # Two-Stage: lei et al 2019
    cut_dfs, first_prediction_times = cut_fpts(learning_feature_df_list)
    # Visualize FPTs
    # plot_fpts(first_prediction_times, learning_feature_df_list, 'root_mean_square')

    # Concatenate trainings data
    all_bearings = concat_dfs(cut_dfs)
    labels = all_bearings.pop('RUL')
    all_bearings, pca = pca_embedded_data_frame(all_bearings)

    # RUL prediction: FFNN
    trainings_history, ffnn = fit_ffnn(X=all_bearings,
                                       y=labels,
                                       dropout=True,
                                       epochs=150)

    # Visualize training history and later validation history
    plot_trainings_history(trainings_history)
    # Visualize predicted RUL in comparison to real RUL
    comparison_set = read_feature_dfs(FULL_TEST_SET, FEATURES_CSV_NAME)
    comparison_set, first_prediction_times = cut_fpts(comparison_set)
    # Remove label
    label_data = pop_labels(comparison_set)
    # Apply PCA
    comparison_set = [pd.DataFrame(pca.transform(df)) for df in comparison_set]

    plot_rul_comparisons(comparison_set,
                         label_data=label_data,
                         prediction_model=ffnn)
 def train(self, training_data: pd.DataFrame, training_labels: pd.Series,
           validation_data: pd.DataFrame,
           validation_labels: pd.Series) -> History:
     training_data = training_data[self.feature_list]
     validation_data = validation_data[self.feature_list]
     self.prediction_model, self.trainings_history = fit_ffnn(
         X=training_data,
         y=training_labels,
         dropout=True,
         validation_data=(validation_data, validation_labels))
     return self.trainings_history
 def train(self, training_data: pd.DataFrame, training_labels: pd.Series,
           validation_data: pd.DataFrame,
           validation_labels: pd.Series) -> History:
     training_data = self._fit_and_embed_training_data(training_data)
     scaler = MinMaxScaler()
     training_data = pd.DataFrame(scaler.fit_transform(training_data),
                                  columns=training_data.columns)
     if validation_data is not None:
         validation_data = self._embed_data(validation_data)
     if validation_data is not None:
         self.prediction_model, self.trainings_history = fit_ffnn(
             X=training_data,
             y=training_labels,
             dropout=True,
             validation_data=(validation_data, validation_labels))
     else:
         self.prediction_model, self.trainings_history = fit_ffnn(
             X=training_data,
             y=training_labels,
             dropout=True,
             validation_data=None)
     return self.trainings_history
def statistical_frequency_features_no_classifier_ffnn_rul_prediction():
    trainings_data = read_feature_dfs(LEARNING_SET)
    trainings_data = concat_dfs(trainings_data)
    trainings_labels = trainings_data.pop('RUL')
    filtered_cols: list = [
        column for column in trainings_data if column.startswith('frequency_')
    ]
    trainings_data = trainings_data[filtered_cols]
    ffnn, trainings_history = fit_ffnn(trainings_data,
                                       trainings_labels,
                                       dropout=True,
                                       epochs=100,
                                       hidden_units=1024,
                                       hidden_layers=4)
    # Visualize trainings history
    plot_trainings_history(trainings_history)
def pca_features_no_classifier_ffnn_rul_prediction(training_data,
                                                   comparison_set):
    hi = __name__
    # Read Training data
    # Remove labels
    pca_training_data = concat_dfs(training_data)
    labels = pca_training_data.pop('RUL')
    model_training_data, pca = pca_embedded_data_frame(pca_training_data,
                                                       n_components=300,
                                                       verbose=False)

    model_training_data = pd.DataFrame(model_training_data)
    ffnn, training_history = fit_ffnn(model_training_data,
                                      labels,
                                      epochs=60,
                                      dropout=True)

    plot_trainings_history(training_history)

    # Visualize predicted RUL in comparison to real RUL of training set
    # Remove label
    training_label_data = pop_labels(training_data)
    # Apply PCA
    transformed_training_set = []
    for df in tqdm(training_data,
                   desc="Transforming training set.",
                   position=0,
                   leave=True):
        transformed_training_set += [pd.DataFrame(pca.transform(X=df))]
    plot_rul_comparisons(transformed_training_set,
                         label_data=training_label_data,
                         prediction_model=ffnn)

    # Visualize predicted RUL in comparison to real RUL of validation set
    # Remove label
    label_data = pop_labels(comparison_set)
    # Apply PCA
    transformed_comparison_set = []
    for df in tqdm(comparison_set,
                   desc="Transforming validation set.",
                   position=0,
                   leave=True):
        transformed_comparison_set += [pd.DataFrame(pca.transform(X=df))]

    plot_rul_comparisons(transformed_comparison_set,
                         label_data=label_data,
                         prediction_model=ffnn)
def entropy_features_no_classifier_ffnn():
    feature_list = ENTROPY_FEATURES
    learning_set = read_feature_dfs(data_set_sub_set=LEARNING_SET,
                                    features=feature_list)
    learning_set = concat_dfs(learning_set)
    training_labes = learning_set.pop('RUL')

    ffnn, trainings_history = fit_ffnn(X=learning_set,
                                       y=training_labes,
                                       epochs=100)

    plot_trainings_history(trainings_history=trainings_history,
                           error_type='RMSE')

    testing_set = read_feature_dfs(data_set_sub_set=FULL_TEST_SET,
                                   features=feature_list)
    testing_labels = pop_labels(testing_set)

    plot_rul_comparisons(testing_set, testing_labels, ffnn)
Esempio n. 12
0
def statistical_features_li_2019_classifier_ffnn_rul_prediction():
    # Input features: statistical features
    learning_feature_df_list = read_dfs(LEARNING_SET,
                                        FEATURES_CSV_NAME,
                                        features=BASIC_STATISTICAL_FEATURES)

    # Two-Stage: lei et al 2019
    cut_dfs, first_prediction_times = cut_fpts(learning_feature_df_list)
    # Visualize FPTs
    # plot_fpts(first_prediction_times, learning_feature_df_list, 'root_mean_square')

    # Concatenate trainings data
    all_bearings = concat_dfs(cut_dfs)
    labels = all_bearings.pop('RUL')

    # RUL prediction: FFNN
    trainings_history, ffnn = fit_ffnn(X=all_bearings,
                                       y=labels,
                                       dropout=True,
                                       epochs=100,
                                       hidden_layers=3,
                                       hidden_units=1024)
    # Visualize training history and later validation history
    plot_trainings_history(trainings_history)

    # Visualize predicted RUL in comparison to real RUL on trainings set
    label_data = pop_labels(cut_dfs)
    plot_rul_comparisons(cut_dfs, label_data=label_data, prediction_model=ffnn)

    # Visualize predicted RUL in comparison to real RUL on test set
    comparison_set = read_dfs(FULL_TEST_SET,
                              FEATURES_CSV_NAME,
                              features=BASIC_STATISTICAL_FEATURES)
    comparison_set, first_prediction_times = cut_fpts(comparison_set)

    # Remove label
    label_data = pop_labels(comparison_set)
    plot_rul_comparisons(comparison_set,
                         label_data=label_data,
                         prediction_model=ffnn)