Skip to main content

iNeuron Model Factory helps us to generate model training and grid search code automatically based

Project description

image

neuro-ml is a open source library designed to avoid writing duplicate code.

You can use new model of scikit learn without writing any cod. Model training can be control by configuration file

How to generate configuration file

It is very simple.

We will export sample model config file in config directory

You can use below command to export sample configuration

from neuro_mf.config import get_sample_model_config_yaml_file

if __name__ == "__main__":
    export_file_path=get_sample_model_config_yaml_file(export_dir="config")

Check your config folder You will find a file name as "model.yaml"

content of model.yaml

grid_search:
  class: GridSearchCV
  module: sklearn.model_selection
  params:
    cv: 3
    verbose: 1
model_selection:
  module_0:
    class: ModelClassName
    module: module_of_model
    params:
      param_name1: value1
      param_name2: value2
    search_param_grid:
      param_name:
      - param_value_1
      - param_value_2

Now update the content of model.yaml file with below content for testing

grid_search:
  class: GridSearchCV
  module: sklearn.model_selection
  params:
    cv: 3
    verbose: 1
model_selection:
  module_0:
    class: RandomForestRegressor
    module: sklearn.ensemble
    params:
      n_estimators: 200
      criterion: squared_error
    search_param_grid:
      n_estimators:
      - 150
      - 200
      - 250
      max_depth:
      - 2
      - 5
      - 6
      

Now Let's try to train a RandomForestRegressor

import os

from neuro_mf.config import get_sample_model_config_yaml_file
from neuro_mf import ModelFactory

if __name__ == "__main__":
    # export_dir=get_sample_model_config_yaml_file(export_dir="config")
    export_file_path = os.path.join("config", "model.yaml")
    model_factory = ModelFactory(model_config_path=export_file_path)
    x = None  # input feature
    y = None  # target feature
    best_model = model_factory.get_best_model(x, y, base_accuracy=0.9)
    print(best_model.best_model)
    print(f"best score:{best_model.best_score}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neuro_mf-0.0.2.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

neuro_mf-0.0.2-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page