Robot grip position (Python PCA principal component analysis)

--When picking an object from a 3D point cloud with an arm, the recognition point cloud may be analyzed as the principal component and the second principal component may be the gripping direction.

pca.py


import numpy as np
import scipy as sp
from sklearn.datasets import make_classification
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt

#Generate sample data
X, y = make_classification(n_samples=200, n_features=2, n_redundant=0, n_informative=2,
                           n_classes=1, n_clusters_per_class=1, random_state=0)

#Principal component analysis
pca = PCA(n_components=2)
pca.fit(X)

#Visualization
plt.scatter(X[:, 0], X[:, 1], alpha=0.5)

l = pca.explained_variance_[1]
vector =  pca.components_[1]
v = vector * 3 * np.sqrt(l)
plt.annotate('',  pca.mean_ + v, pca.mean_ - v,
             arrowprops=dict(connectionstyle='arc3', width=2))



plt.axis('equal')
plt.show()

result

Figure_1.png

reference

https://hawk-tech-blog.com/python-machine-learning-basic-pca/

Recommended Posts

Robot grip position (Python PCA principal component analysis)
Principal component analysis (PCA) and independent component analysis (ICA) in python
Python: Unsupervised Learning: Principal Component Analysis
Principal component analysis
Principal component analysis with Power BI + Python
PRML Chapter 12 Bayesian Principal Component Analysis Python Implementation
[Python] Comparison of Principal Component Analysis Theory and Implementation by Python (PCA, Kernel PCA, 2DPCA)
2. Multivariate analysis spelled out in Python 3-2. Principal component analysis (algorithm)
Challenge principal component analysis of text data with Python
Principal component analysis Analyze handwritten numbers using PCA. Part 2
Principal component analysis using python from nim with nimpy
Principal component analysis Analyze handwritten numbers using PCA. Part 1
2. Multivariate analysis spelled out in Python 3-1. Principal component analysis (scikit-learn)
Face recognition using principal component analysis
Principal component analysis with Spark ML
Introduction to Python Basics of Machine Learning (Unsupervised Learning / Principal Component Analysis)
[GWAS] Plot the results of principal component analysis (PCA) by PLINK
Principal Component Analysis with Livedoor News Corpus-Practice-
Recognize the contour and direction of a shaped object with OpenCV3 and Python3 (Principal component analysis: PCA, eigenvectors)
<Course> Machine learning Chapter 4: Principal component analysis
Principal component analysis with Livedoor News Corpus --Preparation--
Dimensional compression with self-encoder and principal component analysis
I tried principal component analysis with Titanic data!
Data analysis python
Collaborative filtering with principal component analysis and K-means clustering
Clustering and principal component analysis by K-means method (beginner)