當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。