当前位置: 首页>>代码示例>>Java>>正文


Java Prediction类代码示例

本文整理汇总了Java中com.google.api.services.prediction.Prediction的典型用法代码示例。如果您正苦于以下问题:Java Prediction类的具体用法?Java Prediction怎么用?Java Prediction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Prediction类属于com.google.api.services.prediction包,在下文中一共展示了Prediction类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MpcaGooglePredictionAPIClassifier

import com.google.api.services.prediction.Prediction; //导入依赖的package包/类
public MpcaGooglePredictionAPIClassifier() throws GeneralSecurityException, IOException, Exception {

        // initialize the transport
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        // initialize the data store factory
        dataDir = new FileDataStoreFactory(DATA_DIR);
        storeDir = new FileDataStoreFactory(STORE_DIR);


        // authorization
        Credential credential = authorize();
        // set up global Prediction instance
        client = new Prediction.Builder(httpTransport, JSON_FACTORY, credential)
                .setApplicationName(APPLICATION_NAME).build();

    }
 
开发者ID:simon0191,项目名称:MinerPCAdviser,代码行数:18,代码来源:MpcaGooglePredictionAPIClassifier.java

示例2: authenticate

import com.google.api.services.prediction.Prediction; //导入依赖的package包/类
public Prediction authenticate() {
	JsonFactory JSON_FACTORY = new JacksonFactory();

	Set<String> scopes = new HashSet<String>();
	scopes.add(PredictionScopes.DEVSTORAGE_FULL_CONTROL);
	scopes.add(PredictionScopes.DEVSTORAGE_READ_ONLY);
	scopes.add(PredictionScopes.DEVSTORAGE_READ_WRITE);
	scopes.add(PredictionScopes.PREDICTION);

	GoogleCredential credential = null;
	try {
		// initialize the transport
		httpTransport = GoogleNetHttpTransport.newTrustedTransport();

		credential = new GoogleCredential.Builder()
				.setTransport(httpTransport)
				.setJsonFactory(JSON_FACTORY)
				.setServiceAccountId(Constants.GCP_ACCOUNT_ID)
				.setServiceAccountScopes(scopes)
				.setServiceAccountPrivateKeyFromP12File(new File(Constants.GCP_ACCOUNT_KEY))
				.build();
		// set up global Prediction instance
		client = new Prediction.Builder(httpTransport, JSON_FACTORY, credential)
				.setApplicationName(Constants.APPLICATION_NAME).build();
	} catch (Exception x) {
		x.printStackTrace();
	}
	return client;
}
 
开发者ID:saurabhkaushik,项目名称:googpredictapp,代码行数:30,代码来源:PredictionEngine.java

示例3: main

import com.google.api.services.prediction.Prediction; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        // initialize the transport
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();

        // initialize the data store factory
        //dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR);

        // authorization
        MpcaGooglePredictionAPIClassifier bla = new MpcaGooglePredictionAPIClassifier();
        Credential credential = bla.authorize();
        // set up global Prediction instance
        client = new Prediction.Builder(httpTransport, JSON_FACTORY, credential)
                .setApplicationName(APPLICATION_NAME).build();

        Output output = bla.getGoogleOutput("I'm very happy");
        //client.trainedmodels().predict("109973074802", "sentiment", input).execute();
        System.out.println(output.toPrettyString());
        List<Output.OutputMulti> multi = output.getOutputMulti();
        System.out.println("--------------------------");
        for (Output.OutputMulti oo : multi) {
            //System.out.println(oo.toPrettyString());
            System.out.println(oo.getScore());
        }


    } catch (IOException e) {
        System.err.println(e.getMessage());
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
 
开发者ID:simon0191,项目名称:MinerPCAdviser,代码行数:33,代码来源:MpcaGooglePredictionAPIClassifier.java


注:本文中的com.google.api.services.prediction.Prediction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。