当前位置: 首页>>代码示例>>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;未经允许,请勿转载。