INNER CODE UNIT · Python

test_set

dmarienko/QuantTradingResearch · models/helpers.py:81

    def test_set(self, mode='prices'):
        return self.get_data(mode, 'test')
    
    def estimate(self, tracker: Model, on='prices', **kwargs):
        xn, yn = self.train_set(mode=on)
        m = tracker.fit(xn, yn)
        yn_h = m.predict(xn, y=yn, **kwargs) if isinstance(m, Model) else m.predict(xn, **kwargs)
        yn_h = pd.Series(yn_h, index=xn.index) if isinstance(yn_h, np.ndarray) else yn_h
        
        xt, yt = self.test_set(mode=on)
        yt_h = m.predict(xt, y=yt, **kwargs) if isinstance(m, Model) else m.predict(xt, **kwargs)
        yt_h = pd.Series(yt_h, index=xt.index) if isinstance(yt_h, np.ndarray) else yt_h
        
        return mstruct(
            model=m,
            description=tracker.description,
            mode=on,
            train = mstruct(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…