How to use the mlprimitives.MLBLOCKS_PRIMITIVES function in mlprimitives

To help you get started, we’ve selected a few mlprimitives examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDI-Project / MLPrimitives / tests / primitives / test_primitives.py View on Github external
def test_jsons():
    """Validate MLBlocks primitive jsons"""

    primitives = (f for f in os.listdir(MLBLOCKS_PRIMITIVES) if f.endswith('.json'))
    for primitive_filename in primitives:
        try:
            primitive_path = os.path.join(MLBLOCKS_PRIMITIVES, primitive_filename)
            with open(primitive_path, 'r') as f:
                primitive = json.load(f)

            primitive_name = primitive['name']
            fixed_hyperparameters = primitive.get('hyperparameters', dict()).get('fixed', dict())

            init_hyperparameters = dict()
            for name, hyperparameter in fixed_hyperparameters.items():
                if 'default' not in hyperparameter:
                    type_ = hyperparameter.get('type')
                    init_hyperparameters[name] = HYPERPARAMETER_DEFAULTS.get(type_)

            block_name = primitive_name + '#1'
github HDI-Project / MLPrimitives / tests / primitives / test_primitives.py View on Github external
def test_jsons():
    """Validate MLBlocks primitive jsons"""

    primitives = (f for f in os.listdir(MLBLOCKS_PRIMITIVES) if f.endswith('.json'))
    for primitive_filename in primitives:
        try:
            primitive_path = os.path.join(MLBLOCKS_PRIMITIVES, primitive_filename)
            with open(primitive_path, 'r') as f:
                primitive = json.load(f)

            primitive_name = primitive['name']
            fixed_hyperparameters = primitive.get('hyperparameters', dict()).get('fixed', dict())

            init_hyperparameters = dict()
            for name, hyperparameter in fixed_hyperparameters.items():
                if 'default' not in hyperparameter:
                    type_ = hyperparameter.get('type')
                    init_hyperparameters[name] = HYPERPARAMETER_DEFAULTS.get(type_)

            block_name = primitive_name + '#1'
            mlpipeline = MLPipeline(
                primitives=[primitive_name],
                init_params={block_name: init_hyperparameters}