def test_run(): "Make sure run runs" d = testing.play_data() models = [nx.logistic(), fifty()] splitters = [nx.TournamentSplitter(d), nx.ValidationSplitter(d), nx.CheatSplitter(d), nx.CVSplitter(d, kfold=2), nx.SplitSplitter(d, fit_fraction=0.5)] for model in models: for splitter in splitters: nx.run(model, splitter, verbosity=0)
def test_splitter_overlap(): "prediction data should not overlap" d = nx.play_data() splitters = [ nx.TournamentSplitter(d), nx.ValidationSplitter(d), nx.CheatSplitter(d), nx.CVSplitter(d), nx.IgnoreEraCVSplitter(d), nx.SplitSplitter(d, fit_fraction=0.5) ] for splitter in splitters: predict_ids = [] for dfit, dpredict in splitter: predict_ids.extend(dpredict.ids.tolist()) ok_(len(predict_ids) == len(set(predict_ids)), "ids overlap")
def test_run(): "Make sure run runs" d = testing.play_data() models = [nx.linear(), nx.fifty()] splitters = [nx.TournamentSplitter(d), nx.ValidationSplitter(d), nx.CheatSplitter(d), nx.CVSplitter(d, kfold=2), nx.SplitSplitter(d, fit_fraction=0.5)] for model in models: for splitter in splitters: p = nx.run(model, splitter, tournament=None, verbosity=0) ok_(p.shape[1] == 1, 'wrong number of tournaments') ok_(p.tournaments() == nx.tournament_all(), 'wrong tournaments') assert_raises(ValueError, nx.run, None, nx.TournamentSplitter(d)) assert_raises(ValueError, nx.run, nx.fifty(), nx.TournamentSplitter(d), {})
def test_splitter_reset(): "splitter reset should not change results" d = nx.play_data() splitters = [ nx.TournamentSplitter(d), nx.ValidationSplitter(d), nx.CheatSplitter(d), nx.CVSplitter(d), nx.IgnoreEraCVSplitter(d), nx.SplitSplitter(d, fit_fraction=0.5) ] for splitter in splitters: ftups = [[], []] ptups = [[], []] for i in range(2): for dfit, dpredict in splitter: ftups[i].append(dfit) ptups[i].append(dpredict) splitter.reset() ok_(ftups[0] == ftups[1], "splitter reset changed fit split") ok_(ptups[0] == ptups[1], "splitter reset changed predict split")