Coder Social home page Coder Social logo

pipegraph's People

Contributors

amianto avatar loguete avatar mcasl avatar philipmay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pipegraph's Issues

AttributeError: 'DiGraph' object has no attribute 'node'

Traceback (most recent call last):
File "scripts/train_regressor.py", line 199, in
main(args)
File "scripts/train_regressor.py", line 106, in main
model.fit(features_train, scores_train)
File "/Users/orestis/.local/share/virtualenvs/-HnoKq6z_/lib/python3.7/site-packages/pipegraph/base.py", line 184, in fit
self.fit_graph = build_graph(self.fit_connections)
File "/Users/orestis/.local/share/virtualenvs/-HnoKq6z
/lib/python3.7/site-packages/pipegraph/base.py", line 497, in build_graph
current_node = graph.node[name]
AttributeError: 'DiGraph' object has no attribute 'node'

AttributeError: 'DiGraph' object has no attribute 'node'

Minimal Example:

from pipegraph.base import PipeGraph

X_ = np.arange(30).reshape(15,2)
y_ = np.arange(15)
print(f'X, y shape: {X_.shape}, {y_.shape}')

svr_rbf = SVR(kernel='rbf', C=100, gamma=0.1, epsilon=.1)

steps = [('svr', svr_rbf)]
pgraph = PipeGraph(steps=steps)
pgraph.fit(X_, y_)
print(f'predicted shape: {pgraph.predict(X_).shape}')

Results in


X, y shape: (15, 2), (15,)
---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-98-dcba51e79001> in <module>
     18 steps = [('svr', svr_rbf)]
     19 pgraph = PipeGraph(steps=steps)
---> 20 pgraph.fit(X_, y_)
     21 print(f'predicted shape: {pgraph.predict(X_).shape}')
     22 

~/Projects/korean-ml/venv/lib/python3.9/site-packages/pipegraph/base.py in fit(self, X, y, **kwargs)
    182             self.fit_connections = make_connections_when_not_provided_to_init(steps=self.steps)
    183             self.predict_connections = self.fit_connections
--> 184             self._fit_graph = build_graph(self.fit_connections)
    185             self._predict_graph = self._fit_graph
    186 

~/Projects/korean-ml/venv/lib/python3.9/site-packages/pipegraph/base.py in build_graph(connections)
    495     graph.add_nodes_from(connections)
    496     for name in connections:
--> 497         current_node = graph.node[name]
    498         current_node['name'] = name
    499         ascendants_set = set()

AttributeError: 'DiGraph' object has no attribute 'node'

Note: It works as expected if PipeGraph is replaced with sklearn's Pipeline

Issue with LightGBM

Hi there,

I'm using the scikit-API of lightgbm.

  1. I have been trying to fit:
  2. a GBT classifier on X and y
  3. concatenate X and prediction of GBT
  4. re-label y with function meta()
  5. a RF on X=concat and y=meta

64472972-8da7d780-d165-11e9-838a-0789a5214518

from pipegraph.base import PipeGraph, Concatenator
from sklearn.preprocessing import FunctionTransformer
import lightgbm as lgb
import pandas as pd



gbt = lgb.LGBMClassifier(verbose=-1)
rf = lgb.LGBMClassifier(verbose=-1, boosting_type='rf',
                        subsample=0.7,
                        colsample_bytree=0.7,
                        subsample_freq=2)
def meta(X):
    
    X[X<0]=1
    return X

meta_sk = FunctionTransformer(meta, validate=False)

concatenator = Concatenator()

steps = [('GBT', gbt),
         ('concat', concatenator),
         ('meta', meta_sk),
         ('RF', rf),
         ]

connections = { 'GBT': {'X': 'X',
                          'y': 'y'},
                'concat': {'X1': 'GBT',
                           'X2': 'X'},
                'meta': {'X': 'y'},
                'RF': {'X': 'concat',
                         'y': 'meta'},
                }

pgraph = PipeGraph(steps=steps, fit_connections=connections)

pgraph.fit(X=df_cv[xvars].to_numpy(),y=df_cv[y_gbt].to_numpy().reshape(-1))

However I got the following error. I assume y is wrongly passed to GBT. Please let me know :)

[LightGBM] [Warning] Unknown parameter: y
ERROR: step.fit call ValueError!
ERROR: _fit.predict call ValueError!
Out[85]: 
PipeGraph(fit_connections={'GBT': {'X': 'X', 'y': 'y'},
                           'RF': {'X': 'concat', 'y': 'meta'},
                           'concat': {'X1': 'GBT', 'X2': 'X'},
                           'meta': {'X': 'y'}},
          log_level=None,
          predict_connections={'GBT': {'X': 'X', 'y': 'y'},
                               'RF': {'X': 'concat', 'y': 'meta'},
                               'concat': {'X1': 'GBT', 'X2': 'X'},
                               'meta': {'X': 'y'}},
          steps=[('GBT',
                  LGBMClassifier(boosting_type='gbdt', class_weight=None,
                                 colsample_b...
                  LGBMClassifier(boosting_type='rf', class_weight=None,
                                 colsample_bytree=0.7, importance_type='split',
                                 learning_rate=0.1, max_depth=-1,
                                 min_child_samples=20, min_child_weight=0.001,
                                 min_split_gain=0.0, n_estimators=100,
                                 n_jobs=-1, num_leaves=31, objective=None,
                                 random_state=None, reg_alpha=0.0,
                                 reg_lambda=0.0, silent=True, subsample=0.7,
                                 subsample_for_bin=200000, subsample_freq=2,
                                 verbose=-1))])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.