當前位置: 首頁>>代碼示例>>Java>>正文


Java Learner類代碼示例

本文整理匯總了Java中org.jpmml.xgboost.Learner的典型用法代碼示例。如果您正苦於以下問題:Java Learner類的具體用法?Java Learner怎麽用?Java Learner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Learner類屬於org.jpmml.xgboost包,在下文中一共展示了Learner類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: encodeBooster

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
static
public MiningModel encodeBooster(Booster booster, Schema schema){
	byte[] bytes = booster.toByteArray();

	Learner learner;

	try(InputStream is = new ByteArrayInputStream(bytes)){
		learner = XGBoostUtil.loadLearner(is);
	} catch(IOException ioe){
		throw new RuntimeException(ioe);
	}

	Function<Feature, Feature> function = new Function<Feature, Feature>(){

		@Override
		public Feature apply(Feature feature){

			if(feature instanceof BinaryFeature){
				BinaryFeature binaryFeature = (BinaryFeature)feature;

				return binaryFeature;
			} else

			{
				ContinuousFeature continuousFeature = feature.toContinuousFeature(DataType.FLOAT);

				return continuousFeature;
			}
		}
	};

	Schema xgbSchema = schema.toTransformedSchema(function);

	return learner.encodeMiningModel(null, false, xgbSchema);
}
 
開發者ID:jpmml,項目名稱:jpmml-sparkml-xgboost,代碼行數:36,代碼來源:BoosterUtil.java

示例2: getLearner

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
public Learner getLearner(){

		if(this.learner == null){
			this.learner = loadLearner();
		}

		return this.learner;
	}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:9,代碼來源:Booster.java

示例3: loadLearner

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
private Learner loadLearner(){
	byte[] handle = getHandle();

	try(InputStream is = new ByteArrayInputStream(handle)){
		return XGBoostUtil.loadLearner(is);
	} catch(IOException ioe){
		throw new RuntimeException(ioe);
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:10,代碼來源:Booster.java

示例4: ensureLearner

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
private Learner ensureLearner(){

		if(this.learner == null){
			this.learner = loadLearner();
		}

		return this.learner;
	}
 
開發者ID:jpmml,項目名稱:jpmml-r,代碼行數:9,代碼來源:XGBoostConverter.java

示例5: loadLearner

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
private Learner loadLearner(){
	RGenericVector booster = getObject();

	RRaw raw = (RRaw)booster.getValue("raw");

	try {
		return loadLearner(raw);
	} catch(IOException ioe){
		throw new IllegalArgumentException(ioe);
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-r,代碼行數:12,代碼來源:XGBoostConverter.java

示例6: getNumberOfFeatures

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
static
public <E extends Estimator & HasBooster> int getNumberOfFeatures(E estimator){
	Learner learner = getLearner(estimator);

	return learner.getNumFeatures();
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:7,代碼來源:BoosterUtil.java

示例7: getLearner

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
static
private Learner getLearner(HasBooster hasBooster){
	Booster booster = hasBooster.getBooster();

	return booster.getLearner();
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:7,代碼來源:BoosterUtil.java

示例8: encodeSchema

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
@Override
public void encodeSchema(RExpEncoder encoder){
	RGenericVector booster = getObject();

	RGenericVector schema = (RGenericVector)booster.getValue("schema", true);

	RVector<?> fmap;

	try {
		fmap = (RVector<?>)booster.getValue("fmap");
	} catch(IllegalArgumentException iae){
		throw new IllegalArgumentException("No feature map information. Please initialize the \'fmap\' element");
	}

	FeatureMap featureMap;

	try {
		featureMap = loadFeatureMap(fmap);
	} catch(IOException ioe){
		throw new IllegalArgumentException(ioe);
	}

	if(schema != null){
		RVector<?> missing = (RVector<?>)schema.getValue("missing", true);

		if(missing != null){
			featureMap.addMissingValue(ValueUtil.formatValue(missing.asScalar()));
		}
	}

	Learner learner = ensureLearner();

	// Dependent variable
	{
		ObjFunction obj = learner.getObj();

		FieldName targetField = FieldName.create("_target");
		List<String> targetCategories = null;

		if(schema != null){
			RStringVector responseName = (RStringVector)schema.getValue("response_name", true);
			RStringVector responseLevels = (RStringVector)schema.getValue("response_levels", true);

			if(responseName != null){
				targetField = FieldName.create(responseName.asScalar());
			} // End if

			if(responseLevels != null){
				targetCategories = responseLevels.getValues();
			}
		}

		Label label = obj.encodeLabel(targetField, targetCategories, encoder);

		encoder.setLabel(label);
	}

	// Independent variables
	{
		List<Feature> features = featureMap.encodeFeatures(encoder);

		for(Feature feature : features){
			encoder.addFeature(feature);
		}
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-r,代碼行數:67,代碼來源:XGBoostConverter.java

示例9: encodeBooster

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
static
public <E extends Estimator & HasBooster & HasXGBoostOptions> MiningModel encodeBooster(E estimator, Schema schema){
	Learner learner = getLearner(estimator);

	Integer ntreeLimit = (Integer)estimator.getOption(HasXGBoostOptions.OPTION_NTREE_LIMIT, null);
	Boolean compact = (Boolean)estimator.getOption(HasXGBoostOptions.OPTION_COMPACT, Boolean.TRUE);

	Schema xgbSchema = XGBoostUtil.toXGBoostSchema(schema);

	MiningModel miningModel = learner.encodeMiningModel(ntreeLimit, compact, xgbSchema);

	return miningModel;
}
 
開發者ID:jpmml,項目名稱:jpmml-sklearn,代碼行數:14,代碼來源:BoosterUtil.java

示例10: encodeModel

import org.jpmml.xgboost.Learner; //導入依賴的package包/類
@Override
public MiningModel encodeModel(Schema schema){
	RGenericVector booster = getObject();

	RNumberVector<?> ntreeLimit = (RNumberVector<?>)booster.getValue("ntreelimit", true);
	RBooleanVector compact = (RBooleanVector)booster.getValue("compact", true);

	Learner learner = ensureLearner();

	MiningModel miningModel = learner.encodeMiningModel((ntreeLimit != null ? ValueUtil.asInteger(ntreeLimit.asScalar()) : null), (compact != null ? compact.asScalar() : false), schema);

	return miningModel;
}
 
開發者ID:jpmml,項目名稱:jpmml-r,代碼行數:14,代碼來源:XGBoostConverter.java


注:本文中的org.jpmml.xgboost.Learner類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。