PCA Plot Clustering Issue with Time Series Motion Capture Data

Details:

I am using PCA for dimensionality reduction on a time series dataset of hand motion capture data and am encountering unexpected clustering behaviour. Below are the details of my process and the issue I am facing.


Context:

I have a dataset of hand motion recordings captured using a smart glove with 4 sensors on each finger. Each sensor provides:

  • Positional values: X, Y, Z
  • Rotational values: X, Y, Z, W

The data was recorded in separate files, each containing 10 repetitions of a gesture. These repetitions were later segmented into individual files (1 repetition per file), labelled, and combined into a single large dataset.

After label encoding and scaling the data, I applied PCA for dimensionality reduction with the following code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># PCA for dimensionality reduction
pca_components = 3
pca = PCA(n_components=pca_components)
x_train_pca = pca.fit_transform(x_train_scaled)
</code>
<code># PCA for dimensionality reduction pca_components = 3 pca = PCA(n_components=pca_components) x_train_pca = pca.fit_transform(x_train_scaled) </code>
# PCA for dimensionality reduction
pca_components = 3
pca = PCA(n_components=pca_components)
x_train_pca = pca.fit_transform(x_train_scaled)

To visualise the results, I created a PCA summary plot where each segment of data is represented as a single point. The goal is to see clusters of 10 points for each gesture. Here’s the code to summarise the PCA results:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Convert PCA results into a DataFrame to associate labels
x_train_pca_df = pd.DataFrame(x_train_pca, columns=['PC1', 'PC2', 'PC3'])
x_train_pca_df['label'] = y_train_data
x_train_pca_df['segment'] = train_data['segment'].values.ravel()
# Calculate the mean of PC1 and PC2 for each dataset (to summarise each dataset as a point)
summary_train_points = x_train_pca_df.groupby(['label', 'segment']).mean().reset_index()
</code>
<code># Convert PCA results into a DataFrame to associate labels x_train_pca_df = pd.DataFrame(x_train_pca, columns=['PC1', 'PC2', 'PC3']) x_train_pca_df['label'] = y_train_data x_train_pca_df['segment'] = train_data['segment'].values.ravel() # Calculate the mean of PC1 and PC2 for each dataset (to summarise each dataset as a point) summary_train_points = x_train_pca_df.groupby(['label', 'segment']).mean().reset_index() </code>
# Convert PCA results into a DataFrame to associate labels
x_train_pca_df = pd.DataFrame(x_train_pca, columns=['PC1', 'PC2', 'PC3'])
x_train_pca_df['label'] = y_train_data
x_train_pca_df['segment'] = train_data['segment'].values.ravel()

# Calculate the mean of PC1 and PC2 for each dataset (to summarise each dataset as a point)
summary_train_points = x_train_pca_df.groupby(['label', 'segment']).mean().reset_index()

And here’s the method I use to plot the summarised PCA data:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>def plot_3d_pca_matplotlib(summary_points, title='3D PCA Plot'):
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
# For each unique dataset (label), scatter the points and assign a legend entry
unique_labels = summary_points['label'].unique()
for label in unique_labels:
# Filter the data for the current label
filtered_data = summary_points[summary_points['label'] == label]
# Scatter plot for the current label's points
ax.scatter(filtered_data['PC1'],
filtered_data['PC2'],
filtered_data['PC3'],
label=label)
ax.set_xlabel('PCA Component 1')
ax.set_ylabel('PCA Component 2')
ax.set_zlabel('PCA Component 3')
ax.set_title(title)
ax.legend(title="Labels", loc="center left", bbox_to_anchor=(1.05, 0.7))
plt.subplots_adjust(left=0.05, right=0.75)
plt.show()
</code>
<code>def plot_3d_pca_matplotlib(summary_points, title='3D PCA Plot'): fig = plt.figure(figsize=(10, 8)) ax = fig.add_subplot(111, projection='3d') # For each unique dataset (label), scatter the points and assign a legend entry unique_labels = summary_points['label'].unique() for label in unique_labels: # Filter the data for the current label filtered_data = summary_points[summary_points['label'] == label] # Scatter plot for the current label's points ax.scatter(filtered_data['PC1'], filtered_data['PC2'], filtered_data['PC3'], label=label) ax.set_xlabel('PCA Component 1') ax.set_ylabel('PCA Component 2') ax.set_zlabel('PCA Component 3') ax.set_title(title) ax.legend(title="Labels", loc="center left", bbox_to_anchor=(1.05, 0.7)) plt.subplots_adjust(left=0.05, right=0.75) plt.show() </code>
def plot_3d_pca_matplotlib(summary_points, title='3D PCA Plot'):
    fig = plt.figure(figsize=(10, 8))
    ax = fig.add_subplot(111, projection='3d')

    # For each unique dataset (label), scatter the points and assign a legend entry
    unique_labels = summary_points['label'].unique()

    for label in unique_labels:
        # Filter the data for the current label
        filtered_data = summary_points[summary_points['label'] == label]

        # Scatter plot for the current label's points
        ax.scatter(filtered_data['PC1'],
                   filtered_data['PC2'],
                   filtered_data['PC3'],
                   label=label)

    ax.set_xlabel('PCA Component 1')
    ax.set_ylabel('PCA Component 2')
    ax.set_zlabel('PCA Component 3')
    ax.set_title(title)
    ax.legend(title="Labels", loc="center left", bbox_to_anchor=(1.05, 0.7))

    plt.subplots_adjust(left=0.05, right=0.75)
    plt.show()

The Issue:

When I record a new set of data for the same gestures and plot the PCA results, I expect to see clusters of 20 points (10 points from the original data + 10 points from the new data) for each gesture.

Instead, the PCA plot shows two separate clusters of 10 points for each gesture. This suggests that the new data isn’t aligning with the original data in the PCA space, even though the gestures are the same.


Question:

What could be causing this separation into distinct clusters for the same gestures?

Could it be related to:

  1. The scaling process?
  2. Inconsistent sensor calibration?
  3. A need for alignment or additional preprocessing of the data before applying PCA?

Any guidance or suggestions for debugging this issue would be greatly appreciated. If you require more information please let me know.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật