Skip to content

Instantly share code, notes, and snippets.

@petrosDemetrakopoulos
Last active October 4, 2023 00:03
Show Gist options
  • Select an option

  • Save petrosDemetrakopoulos/8bcb0b649b7caaea34e4326c84b66ed4 to your computer and use it in GitHub Desktop.

Select an option

Save petrosDemetrakopoulos/8bcb0b649b7caaea34e4326c84b66ed4 to your computer and use it in GitHub Desktop.

Revisions

  1. petrosDemetrakopoulos revised this gist Oct 4, 2023. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions fall_detector_all.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,10 @@
    from matplotlib import pyplot as plt
    import numpy as np
    import pandas as pd
    from scipy.stats import skew, kurtosis
    from sklearn.decomposition import PCA
    from sklearn.cluster import KMeans

    def main():
    data = read_data()
    normalized_data = normalize(data)
  2. petrosDemetrakopoulos created this gist Oct 3, 2023.
    19 changes: 19 additions & 0 deletions fall_detector_all.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    def main():
    data = read_data()
    normalized_data = normalize(data)

    # time related columns are not needed after this point
    normalized_data = normalized_data.drop(['time','seconds_elapsed'],axis=1)
    extracted_features = feature_extraction(normalized_data)

    # dimensionality reduction using PCA
    plot_pca(extracted_features)

    # fit K-Means
    kmeans = KMeans(n_clusters=2)
    kmeans.fit(extracted_features)
    predictions = kmeans.predict(extracted_features)

    # plot the results
    plot_pca(extracted_features, predictions)
    plot_out_signal(predictions)