예제 #1
0
파일: context.py 프로젝트: shangrz/ramp
    def __init__(self,
                 store=None,
                 data=None,
                 train_index=None,
                 prep_index=None):
        """
        **Args**

        store: An instance of `store.Store` or a path. If a path
                Ramp will default to an `HDFPickleStore` at that path
                if PyTables is installed, a `PickleStore` otherwise.
                Defaults to MemoryStore.
        data: a pandas DataFrame. If all data has been precomputed this
                may not be required.
        train_index: a pandas Index specifying the data instances to be
                used in training. Stored results will be cached against this.
                If not provided, the entire index of `data` will be used.
        prep_index: a pandas Index specifying the data instances to be
                used in prepping ("x" values). Stored results will be cached against this.
                If not provided, the entire index of `data` will be used.
        """
        if store is None:
            self.store = MemoryStore()
        else:
            self.store = store if isinstance(store,
                                             Store) else default_store(store)
        self.data = data
        self.train_index = train_index if train_index is not None else self.data.index if self.data is not None else None
        self.prep_index = prep_index if prep_index is not None else self.data.index if self.data is not None else None
예제 #2
0
파일: context.py 프로젝트: mengfan/ramp
    def __init__(self,
                 store=None,
                 data=None,
                 train_index=None,
                 prep_index=None,
                 train_once=False):
        """
        Parameters:
        -----------

        store: string or ramp.store.Store object, default None
            An instance of `ramp.store.Store` or a path. If a path, Ramp will
            default to an `HDFPickleStore` at that path if PyTables is
            installed, a `PickleStore` otherwise. Defaults to MemoryStore.
        data: Pandas DataFrame, default None
            Dataframe of data. If all data has been precomputed this
            may not be required.
        train_index: Pandas DataFrame Index, default None
            Pandas Index specifying the data instances to be used in training.
            Stored results will be cached against this.If not provided, the
            entire index of the 'data' parameter will be used.
        prep_index: Pandas DataFrame Index, default None
            Pandas Index specifying the data instances to be
            used in prepping ("x" values). Stored results will be cached
            against this. If not provided, the entire index of `data`
            keyword arg will be used.
        train_once: boolean
            If True, train and predict indexes will not be used as part of key
            hashes, meaning the values from the first run with this context
            will be stored permanently.
        """
        if store is None:
            self.store = MemoryStore()
        else:
            self.store = (store if isinstance(store, Store) else
                          default_store(store))
        self.data = data
        if train_index is not None:
            self.train_index = train_index
        elif self.data is not None:
            self.train_index = self.data.index
        else:
            self.train_index = None

        if prep_index is not None:
            self.prep_index = prep_index
        elif self.data is not None:
            self.prep_index = self.data.index
        else:
            self.prep_index = None
        self.train_once = train_once
예제 #3
0
파일: context.py 프로젝트: mengfan/ramp
    def __init__(self, store=None, data=None, train_index=None,
                 prep_index=None, train_once=False):
        """
        Parameters:
        -----------

        store: string or ramp.store.Store object, default None
            An instance of `ramp.store.Store` or a path. If a path, Ramp will
            default to an `HDFPickleStore` at that path if PyTables is
            installed, a `PickleStore` otherwise. Defaults to MemoryStore.
        data: Pandas DataFrame, default None
            Dataframe of data. If all data has been precomputed this
            may not be required.
        train_index: Pandas DataFrame Index, default None
            Pandas Index specifying the data instances to be used in training.
            Stored results will be cached against this.If not provided, the
            entire index of the 'data' parameter will be used.
        prep_index: Pandas DataFrame Index, default None
            Pandas Index specifying the data instances to be
            used in prepping ("x" values). Stored results will be cached
            against this. If not provided, the entire index of `data`
            keyword arg will be used.
        train_once: boolean
            If True, train and predict indexes will not be used as part of key
            hashes, meaning the values from the first run with this context
            will be stored permanently.
        """
        if store is None:
            self.store = MemoryStore()
        else:
            self.store = (store if isinstance(store, Store)
                          else default_store(store))
        self.data = data
        if train_index is not None:
            self.train_index = train_index
        elif self.data is not None:
            self.train_index = self.data.index
        else:
            self.train_index = None

        if prep_index is not None:
            self.prep_index = prep_index
        elif self.data is not None:
            self.prep_index = self.data.index
        else:
            self.prep_index = None
        self.train_once = train_once
예제 #4
0
파일: context.py 프로젝트: ageek/ramp
    def __init__(self, store, data=None, train_index=None, prep_index=None):
        """
        **Args**

        store: An instance of `store.Store` or a path. If a path
                Ramp will default to an `HDFPickleStore` at that path
                if PyTables is installed, a `PickleStore` otherwise.
        data: a pandas DataFrame. If all data has been precomputed this
                may not be required.
        train_index: a pandas Index specifying the data instances to be
                used in training. Stored results will be cached against this.
                If not provided, the entire index of `data` will be used.
        prep_index: a pandas Index specifying the data instances to be
                used in prepping ("x" values). Stored results will be cached against this.
                If not provided, the entire index of `data` will be used.
        """
        self.store = store if isinstance(store, Store) else default_store(store)
        self.data = data
        self.train_index = train_index if train_index is not None else self.data.index if self.data is not None else None
        self.prep_index = prep_index if prep_index is not None else self.data.index if self.data is not None else None