gdalessi / openmore Goto Github PK
View Code? Open in Web Editor NEWPython libraries (NumPy-based) to perform model order reduction, clustering and data analysis for combustion and aerothermochemistry data
License: Other
Python libraries (NumPy-based) to perform model order reduction, clustering and data analysis for combustion and aerothermochemistry data
License: Other
hank you for your code, it's very useful to perform local PCA and easy to use ๐ However, I have a problem in the code below and I don't know how to fix it.
My code is simply finding the best clusters for each number of eigenvectors (from 1 to the initial space). Then, I perform local pca on my different clusters and finally evaluate the reconstruction of my initial dataset. Here is my code :
import OpenMORe.clustering as clustering
n_clusters = 4
r2final=[]
r2clusters=[]
for q in range(1,test.shape[1]+1): #number of pc
settings_clustering = {
#centering and scaling options
"center" : True,
"centering_method" : "mean",
"scale" : True,
"scaling_method" : "auto",
#set the initialization method (random, observations, kmeans, pkcia, uniform)
"initialization_method" : "random",
#set the number of clusters and PCs in each cluster
"number_of_clusters" : n_clusters,
"number_of_eigenvectors" : q,
#enable additional options:
"correction_factor" : "off", # --> enable eventual corrective coefficients for the LPCA algorithm:
# 'off', 'c_range', 'uncorrelation', 'local_variance', 'phc_multi', 'local_skewness' are available
"classify" : False, # --> call the method to classify a new matrix Y on the basis of the lpca clustering
"write_on_txt" : False, # --> write the idx vector containing the label for each observation
"evaluate_clustering" : True, # --> enable the calculation of indeces to evaluate the goodness of the clustering
"neighbors_number" : 0,
}
# First we create the model and then we fit it to the dataset
model = clustering.lpca(test, settings_clustering)
labels_vqpca = model.fit()
r2final=[]
for k in range(n_clusters):
mask = (labels_vqpca == k)
X_k = test[mask] # the mask is used to select the clusters with a specific label
cnt_k = np.mean(X_k, axis=0)
scl_k = np.std(X_k, axis=0)
X0_k = (X_k - cnt_k)/scl_k # we need to center the data in each cluster
pca.fit(X0_k)
A_k = pca.components_.T
Z_k = X0_k @ A_k
X0_k_rec = Z_k[:,:q] @ A_k[:,:q].T
X_k_rec = scl_k * X0_k_rec + cnt_k
r2list = []
for i in range(X_k.shape[1]): #reconstruction for each elements
r2 = r2_score(X_k[:,i], X_k_rec[:,i])
r2list.append(r2)
r2final.append(r2list)
averages = [sum(elements) / len(elements) for elements in zip(*r2final)]
r2clusters.append(averages)
However, I get this error which i don't really understand when calling model.fit():
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Clustering LPCA - 2023_05_05-144151'
Thank you for your help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.