本文整理汇总了Java中hex.pca.PCA类的典型用法代码示例。如果您正苦于以下问题:Java PCA类的具体用法?Java PCA怎么用?Java PCA使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PCA类属于hex.pca包,在下文中一共展示了PCA类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBasic
import hex.pca.PCA; //导入依赖的package包/类
@Test public void testBasic() throws InterruptedException, ExecutionException{
boolean standardize = true;
PCAModel model = null;
Frame fr = null;
try {
Key kraw = Key.make("basicdata.raw");
FVecTest.makeByteVec(kraw, "x1,x2,x3\n0,1.0,-120.4\n1,0.5,89.3\n2,0.3333333,291.0\n3,0.25,-2.5\n4,0.20,-2.5\n5,0.1666667,-123.4\n6,0.1428571,-0.1\n7,0.1250000,18.3");
fr = ParseDataset2.parse(Key.make("basicdata.hex"), new Key[]{kraw});
Key kpca = Key.make("basicdata.pca");
new PCA("PCA on basic small dataset", kpca, fr, 0.0, standardize).invoke();
model = DKV.get(kpca).get();
Job.JobState jstate = model.get_params().state;
Assert.assertTrue(jstate == Job.JobState.DONE); //HEX-1817
testHTML(model);
} finally {
if( fr != null ) fr .delete();
if( model != null ) model.delete();
}
}
示例2: testLinDep
import hex.pca.PCA; //导入依赖的package包/类
@Test public void testLinDep() throws InterruptedException, ExecutionException {
Key kdata = Key.make("depdata.hex");
PCAModel model = null;
Frame fr = null;
double[] sdev_R = {1.414214, 0};
try {
Key kraw = Key.make("depdata.raw");
FVecTest.makeByteVec(kraw, "x1,x2\n0,0\n1,2\n2,4\n3,6\n4,8\n5,10");
fr = ParseDataset2.parse(kdata, new Key[]{kraw});
Key kpca = Key.make("depdata.pca");
new PCA("PCA on data with dependent cols", kpca, fr, 0.0, true).invoke();
model = DKV.get(kpca).get();
testHTML(model);
for(int i = 0; i < model.sdev().length; i++)
Assert.assertEquals(sdev_R[i], model.sdev()[i], threshold);
} finally {
if( fr != null ) fr .delete();
if( model != null ) model.delete();
}
}
示例3: testArrests
import hex.pca.PCA; //导入依赖的package包/类
@Test public void testArrests() throws InterruptedException, ExecutionException {
double tol = 0.25;
boolean standardize = true;
PCAModel model = null;
Frame fr = null;
double[] sdev_R = {1.5748783, 0.9948694, 0.5971291, 0.4164494};
double[][] eigv_R = {{-0.5358995, 0.4181809, -0.3412327, 0.64922780},
{-0.5831836, 0.1879856, -0.2681484, -0.74340748},
{-0.2781909, -0.8728062, -0.3780158, 0.13387773},
{-0.5434321, -0.1673186, 0.8177779, 0.08902432}};
try {
Key ksrc = Key.make("arrests.hex");
fr = getFrameForFile(ksrc, "smalldata/pca_test/USArrests.csv", null);
// Build PCA model on all columns
Key kdst = Key.make("arrests.pca");
new PCA("PCA test on USArrests", kdst, fr, tol, standardize).invoke();
model = DKV.get(kdst).get();
testHTML(model);
// Compare standard deviation and eigenvectors to R results
checkSdev(sdev_R, model.sdev());
checkEigvec(eigv_R, model.eigVec());
// Score original data set using PCA model
// Key kscore = Key.make("arrests.score");
// Frame score = PCAScoreTask.score(df, model._eigVec, kscore);
} finally {
if( fr != null ) fr .delete();
if( model != null ) model.delete();
}
}
示例4: buildModel
import hex.pca.PCA; //导入依赖的package包/类
@Override
public ModelBuilder buildModel(PCAModel.PCAParameters params) {
return new PCA(params);
}
示例5: register
import hex.pca.PCA; //导入依赖的package包/类
@Override
public void register(String relativeResourcePath) {
/////////////////////////////////////////////////////////////////////////////////////////////
// Register the algorithms and their builder handlers:
ModelBuilder.registerModelBuilder("gbm", "Gradient Boosting Machine", GBM.class);
H2O.registerPOST("/3/ModelBuilders/gbm", GBMBuilderHandler.class, "train", "Train a GBM model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/gbm/parameters", GBMBuilderHandler.class, "validate_parameters", "Validate a set of GBM model builder parameters.");
ModelBuilder.registerModelBuilder("drf", "Distributed RF", DRF.class);
H2O.registerPOST("/3/ModelBuilders/drf", DRFBuilderHandler.class, "train", "Train a DRF model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/drf/parameters", DRFBuilderHandler.class, "validate_parameters", "Validate a set of DRF model builder parameters.");
ModelBuilder.registerModelBuilder("kmeans", "K-means", KMeans.class);
H2O.registerPOST("/3/ModelBuilders/kmeans", KMeansBuilderHandler.class, "train", "Train a KMeans model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/kmeans/parameters", KMeansBuilderHandler.class, "validate_parameters", "Validate a set of KMeans model builder parameters.");
ModelBuilder.registerModelBuilder("deeplearning", "Deep Learning", DeepLearning.class);
H2O.registerPOST("/3/ModelBuilders/deeplearning", DeepLearningBuilderHandler.class, "train", "Train a Deep Learning model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/deeplearning/parameters", DeepLearningBuilderHandler.class, "validate_parameters", "Validate a set of Deep Learning model builder parameters.");
ModelBuilder.registerModelBuilder("glm", "Generalized Linear Model", GLM.class);
H2O.registerPOST("/3/ModelBuilders/glm", GLMBuilderHandler.class, "train", "Train a GLM model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/glm/parameters", GLMBuilderHandler.class, "validate_parameters", "Validate a set of GLM model builder parameters.");
H2O.registerPOST("/3/MakeGLMModel", MakeGLMModelHandler.class, "make_model", "make a new GLM model based on existing one");
ModelBuilder.registerModelBuilder("naivebayes", "Naive Bayes", NaiveBayes.class);
H2O.registerPOST("/3/ModelBuilders/naivebayes", NaiveBayesBuilderHandler.class, "train", "Train a Naive Bayes model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/naivebayes/parameters", NaiveBayesBuilderHandler.class, "validate_parameters", "Validate a set of Naive Bayes model builder parameters.");
ModelBuilder.registerModelBuilder("pca", "Principal Component Analysis", PCA.class);
H2O.registerPOST("/3/ModelBuilders/pca", PCABuilderHandler.class, "train", "Train a PCA model on the specified Frame.");
H2O.registerPOST("/3/ModelBuilders/pca/parameters", PCABuilderHandler.class, "validate_parameters", "Validate a set of PCA model builder parameters.");
ModelBuilder.registerModelBuilder("glrm", "Beta - Generalized Low Rank Model", GLRM.class);
H2O.registerPOST("/99/ModelBuilders/glrm", GLRMBuilderHandler.class, "train", "Train a GLRM model on the specified Frame.");
H2O.registerPOST("/99/ModelBuilders/glrm/parameters", GLRMBuilderHandler.class, "validate_parameters", "Validate a set of GLRM model builder parameters.");
ModelBuilder.registerModelBuilder("svd", "Beta - Singular Value Decomposition", SVD.class);
H2O.registerPOST("/99/ModelBuilders/svd", SVDBuilderHandler.class, "train", "Train a SVD model on the specified Frame.");
H2O.registerPOST("/99/ModelBuilders/svd/parameters", SVDBuilderHandler.class, "validate_parameters", "Validate a set of SVD model builder parameters.");
// Grid search is experimental feature
H2O.registerPOST("/99/Grid/glm", GLMGridSearchHandler.class, "train", "Run grid search for GLRM model.");
H2O.registerPOST("/99/Grid/gbm", GBMGridSearchHandler.class, "train", "Run grid search for GBM model.");
H2O.registerPOST("/99/Grid/drf", DRFGridSearchHandler.class, "train", "Run grid search for DRF model.");
H2O.registerPOST("/99/Grid/kmeans", KMeansGridSearchHandler.class, "train", "Run grid search for KMeans model.");
H2O.registerPOST("/99/Grid/deeplearning", DeepLearningGridSearchHandler.class, "train", "Run grid search for DeepLearning model.");
H2O.registerPOST("/99/Grid/glrm", GLRMGridSearchHandler.class, "train", "Run grid search for GLRM model.");
H2O.registerPOST("/99/Grid/pca", PCAGridSearchHandler.class, "train", "Run grid search for PCA model.");
H2O.registerPOST("/99/Grid/svd", SVDGridSearchHandler.class, "train", "Run grid search for SVD model.");
H2O.registerPOST("/99/Grid/naivebayes", NaiveBayesGridSearchHandler.class, "train", "Run grid search for Naive Bayes model.");
// ModelBuilder.registerModelBuilder("word2vec", Word2Vec.class);
// H2O.registerPOST("/3/ModelBuilders/word2vec", Word2VecBuilderHandler.class, "train", "Train a Word2Vec model on the specified Frame.");
// H2O.registerPOST("/3/ModelBuilders/word2vec/parameters", Word2VecBuilderHandler.class, "validate_parameters", "Validate a set of Word2Vec model builder parameters.");
// ModelBuilder.registerModelBuilder("example", Example.class);
// H2O.registerPOST("/3/ModelBuilders/example", ExampleBuilderHandler.class, "train", "Train an Example model on the specified Frame.");
// H2O.registerPOST("/3/ModelBuilders/example/parameters", ExampleBuilderHandler.class, "validate_parameters", "Validate a set of Example model builder parameters.");
// ModelBuilder.registerModelBuilder("grep", Grep.class);
// H2O.registerPOST("/3/ModelBuilders/grep", GrepBuilderHandler.class, "train", "Search a raw text file for matches");
// H2O.registerPOST("/3/ModelBuilders/grep/parameters", GrepBuilderHandler.class, "validate_parameters", "Validate a set of Grep parameters.");
}