• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python param.Params类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyspark.ml.param.Params的典型用法代码示例。如果您正苦于以下问题:Python Params类的具体用法?Python Params怎么用?Python Params使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Params类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, sklearnEstimator=None, keyCols=None, xCol=None, outputCol=None, yCol=None,
                 estimatorType=None, keyedSklearnEstimators=None, outputType=None):
        """The constructor is used by :class:`KeyedEstimator` to generate a :class:`KeyedModel`; it
        is not intended for external use."""

        assert (estimatorType == "predictor") == (yCol is not None), \
            "yCol is {}, but it should {}be None for a {} estimatorType".format(
                yCol, "not " if isLabelled else "", estimatorType)
        assert estimatorType in ["transformer", "clusterer", "predictor"], estimatorType

        def implies(a, b):
            return not a or b
        assert implies(estimatorType == "transformer", outputType == Vector.__UDT__), outputType
        assert implies(estimatorType == "clusterer", outputType == LongType()), outputType
        assert len(keyCols) > 0, len(keyCols)
        assert set(keyedSklearnEstimators.columns) == (set(keyCols) | {"estimator"}), \
            "keyedSklearnEstimator columns {} should have both key columns {} and " + \
            "an estimator column".format(keyedSklearnEstimators.columns, keyCols)

        # The superclass expects Param attributes to already be set, so we only init it after
        # doing so.
        for paramName, paramSpec in KeyedModel._paramSpecs.items():
            setattr(self, paramName, Param(Params._dummy(), paramName, paramSpec["doc"]))
        super(KeyedModel, self).__init__()
        if yCol and type(outputType) not in KeyedModel._sql_types:
            raise TypeError("Output type {} is not an AtomicType (expected for {} estimator)"
                            .format(outputType, estimatorType))
        self._set(**self._input_kwargs)
开发者ID:dominguezus,项目名称:spark-sklearn,代码行数:28,代码来源:keyed_models.py


示例2: copy

 def copy(self, extra={}):
     newCV = Params.copy(self, extra)
     if self.isSet(self.estimator):
         newCV.setEstimator(self.getEstimator().copy(extra))
     # estimatorParamMaps remain the same
     if self.isSet(self.evaluator):
         newCV.setEvaluator(self.getEvaluator().copy(extra))
     return newCV
开发者ID:308306362,项目名称:spark,代码行数:8,代码来源:tuning.py


示例3: copy

 def copy(self, extra=None):
     if extra is None:
         extra = dict()
     newCV = Params.copy(self, extra)
     if self.isSet(self.estimator):
         newCV.setEstimator(self.getEstimator().copy(extra))
     # estimatorParamMaps remain the same
     if self.isSet(self.evaluator):
         newCV.setEvaluator(self.getEvaluator().copy(extra))
     return newCV
开发者ID:EntilZha,项目名称:spark,代码行数:10,代码来源:tuning.py


示例4: copy

    def copy(self, extra=None):
        """
        Creates a copy of this instance.

        :param extra: extra parameters
        :returns: new instance
        """
        if extra is None:
            extra = dict()
        that = Params.copy(self, extra)
        stages = [stage.copy(extra) for stage in that.getStages()]
        return that.setStages(stages)
开发者ID:SatyaNarayan1,项目名称:spark,代码行数:12,代码来源:pipeline.py


示例5: copy

 def copy(self, extra=None):
     """
     Creates a copy of this instance with a randomly generated uid
     and some extra params. This copies creates a deep copy of
     the embedded paramMap, and copies the embedded and extra parameters over.
     :param extra: Extra parameters to copy to the new instance
     :return: Copy of this instance
     """
     if extra is None:
         extra = dict()
     newCV = Params.copy(self, extra)
     if self.isSet(self.estimator):
         newCV.setEstimator(self.getEstimator().copy(extra))
     # estimatorParamMaps remain the same
     if self.isSet(self.evaluator):
         newCV.setEvaluator(self.getEvaluator().copy(extra))
     return newCV
开发者ID:ksakellis,项目名称:spark,代码行数:17,代码来源:tuning.py


示例6: test_params

    def test_params(self):
        testParams = TestParams()
        maxIter = testParams.maxIter
        inputCol = testParams.inputCol
        seed = testParams.seed

        params = testParams.params
        self.assertEqual(params, [inputCol, maxIter, seed])

        self.assertTrue(testParams.hasParam(maxIter.name))
        self.assertTrue(testParams.hasDefault(maxIter))
        self.assertFalse(testParams.isSet(maxIter))
        self.assertTrue(testParams.isDefined(maxIter))
        self.assertEqual(testParams.getMaxIter(), 10)
        testParams.setMaxIter(100)
        self.assertTrue(testParams.isSet(maxIter))
        self.assertEqual(testParams.getMaxIter(), 100)

        self.assertTrue(testParams.hasParam(inputCol.name))
        self.assertFalse(testParams.hasDefault(inputCol))
        self.assertFalse(testParams.isSet(inputCol))
        self.assertFalse(testParams.isDefined(inputCol))
        with self.assertRaises(KeyError):
            testParams.getInputCol()

        otherParam = Param(Params._dummy(), "otherParam", "Parameter used to test that " +
                           "set raises an error for a non-member parameter.",
                           typeConverter=TypeConverters.toString)
        with self.assertRaises(ValueError):
            testParams.set(otherParam, "value")

        # Since the default is normally random, set it to a known number for debug str
        testParams._setDefault(seed=41)
        testParams.setSeed(43)

        self.assertEqual(
            testParams.explainParams(),
            "\n".join(["inputCol: input column name. (undefined)",
                       "maxIter: max number of iterations (>= 0). (default: 10, current: 100)",
                       "seed: random seed. (default: 41, current: 43)"]))
开发者ID:Brett-A,项目名称:spark,代码行数:40,代码来源:test_param.py


示例7: copy

 def copy(self, extra=None):
     if extra is None:
         extra = dict()
     that = Params.copy(self, extra)
     stages = [stage.copy(extra) for stage in that.getStages()]
     return that.setStages(stages)
开发者ID:dalonso82,项目名称:spark,代码行数:6,代码来源:pipeline.py


示例8: copy

 def copy(self, extra={}):
     that = Params.copy(self, extra)
     stages = [stage.copy(extra) for stage in that.getStages()]
     return that.setStages(stages)
开发者ID:308306362,项目名称:spark,代码行数:4,代码来源:pipeline.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python regression.LinearRegression类代码示例发布时间:2022-05-26
下一篇:
Python linalg.Vectors类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap