Import PANDAS AS PD from sklearn.decomposition Import the PCA # Data Address: HTTPS: //www.kaggle.com/c/instacart-market-basket-analysis/data # reading table Prior = pd.read_csv (R & lt " E: \ 360Downloads \ Software \ dimensionality reduction column text data \ order_products__prior.csv " ) Products = pd.read_csv (R & lt " E: \ 360Downloads \ Software \ dimensionality reduction column text data \ products.csv " ) Order = pd.read_csv (R & lt " E : \ 360Downloads \ Software \ dimensionality reduction column text data \ order.csv " ) Aisles = pd.read_csv (R & lt " E: \ 360Downloads \ Software \ dimensionality reduction column text data \ aisles.csv " ) # Merge table, prodyct_id by that column were combined _MG = pd.merge (Prior, Products, ON = [ ' prodyct_id ' , ' the product_id ' ]) _MG = pd.merge (_MG, Order, ON = [ ' order_id ' , ' order_id ' ]) MT = pd.merge (_MG, Aisles, ON = [ ' aisle_id ' , ' aisle_id ' ]) # using cross table, construct the user - for later product category table cross = pd.crosstab (MT [ ' user_id ' ], MT [ ' Aisle ' ]) #Principal component analysis, to filter out redundant categories of goods, or almost no one is about to buy a small amount of merchandise categories to filter out the PCA = the PCA (n_components = 0.9 ) the Data = pca.fit_transform (Cross)