def tsf_benchmarking(): for i in range(0, len(benchmark_datasets)): dataset = benchmark_datasets[i] print(str(i) + " problem = " + dataset) tsf = ib.TimeSeriesForest(n_estimators=100) exp.run_experiment( overwrite=False, problem_path=data_dir, results_path=results_dir, cls_name="PythonTSF", classifier=tsf, dataset=dataset, train_file=False, ) steps = [ ("segment", RandomIntervalSegmenter(n_intervals="sqrt")), ( "transform", FeatureUnion( [ ( "mean", make_row_transformer( FunctionTransformer(func=np.mean, validate=False) ), ), ( "std", make_row_transformer( FunctionTransformer(func=np.std, validate=False) ), ), ( "slope", make_row_transformer( FunctionTransformer( func=time_series_slope, validate=False ) ), ), ] ), ), ("clf", DecisionTreeClassifier()), ] base_estimator = Pipeline(steps) tsf = TimeSeriesForestClassifier(estimator=base_estimator, n_estimators=100) exp.run_experiment( overwrite=False, problem_path=data_dir, results_path=results_dir, cls_name="PythonTSFComposite", classifier=tsf, dataset=dataset, train_file=False, )
def set_classifier(cls, resampleId): """ Basic way of determining the classifier to build. To differentiate settings just and another elif. So, for example, if you wanted tuned TSF, you just pass TuneTSF and set up the tuning mechanism in the elif. This may well get superceded, it is just how e have always done it :param cls: String indicating which classifier you want :return: A classifier. """ if cls.lower() == 'pf': return pf.ProximityForest(random_state=resampleId) elif cls.lower() == 'pt': return pf.ProximityTree(random_state=resampleId) elif cls.lower() == 'ps': return pf.ProximityStump(random_state=resampleId) elif cls.lower() == 'rise': return fb.RandomIntervalSpectralForest(random_state=resampleId) elif cls.lower() == 'tsf': return ib.TimeSeriesForest(random_state=resampleId) elif cls.lower() == 'boss': return db.BOSSEnsemble(random_state=resampleId) elif cls.lower() == 'cboss': return db.BOSSEnsemble(random_state=resampleId, randomised_ensemble=True, max_ensemble_size=50) elif cls.lower() == 'tde': return tde.TemporalDictionaryEnsemble(random_state=resampleId) elif cls.lower() == 'st': return st.ShapeletTransformClassifier(time_contract_in_mins=1500) elif cls.lower() == 'dtwcv': return nn.KNeighborsTimeSeriesClassifier(metric="dtwcv") elif cls.lower() == 'ee' or cls.lower() == 'elasticensemble': return dist.ElasticEnsemble() elif cls.lower() == 'tsfcomposite': #It defaults to TSF return ensemble.TimeSeriesForestClassifier() elif cls.lower() == 'risecomposite': steps = [('segment', RandomIntervalSegmenter(n_intervals=1, min_length=5)), ('transform', FeatureUnion([('acf', RowTransformer( FunctionTransformer(func=acf_coefs, validate=False))), ('ps', RowTransformer( FunctionTransformer(func=powerspectrum, validate=False)))])), ('tabularise', Tabularizer()), ('clf', DecisionTreeClassifier())] base_estimator = Pipeline(steps) return ensemble.TimeSeriesForestClassifier(estimator=base_estimator, n_estimators=100) else: raise Exception('UNKNOWN CLASSIFIER')
def tsf_benchmarking(): for i in range(len(benchmark_datasets)): dataset = benchmark_datasets[i] print(str(i) + " problem = " + dataset) tsf = ib.TimeSeriesForest(n_estimators=100) exp.run_experiment(overwrite=False, problem_path=data_dir, results_path=results_dir, cls_name="PythonTSF", classifier=tsf, dataset=dataset, train_file=False) steps = [ ('segment', RandomIntervalSegmenter(n_intervals='sqrt')), ('transform', FeatureUnion([('mean', RowTransformer( FunctionTransformer(func=np.mean, validate=False))), ('std', RowTransformer( FunctionTransformer(func=np.std, validate=False))), ('slope', RowTransformer( FunctionTransformer(func=time_series_slope, validate=False)))])), ('clf', DecisionTreeClassifier()) ] base_estimator = Pipeline(steps) tsf = TimeSeriesForestClassifier(estimator=base_estimator, n_estimators=100) exp.run_experiment(overwrite=False, problem_path=data_dir, results_path=results_dir, cls_name="PythonTSFComposite", classifier=tsf, dataset=dataset, train_file=False)
def set_classifier(cls, resampleId): """ Basic way of determining the classifier to build. To differentiate settings just and another elif. So, for example, if you wanted tuned TSF, you just pass TuneTSF and set up the tuning mechanism in the elif. This may well get superceded, it is just how e have always done it :param cls: String indicating which classifier you want :return: A classifier. """ if cls.lower() == "pf": return pf.ProximityForest(random_state=resampleId) elif cls.lower() == "pt": return pf.ProximityTree(random_state=resampleId) elif cls.lower() == "ps": return pf.ProximityStump(random_state=resampleId) elif cls.lower() == "rise": return fb.RandomIntervalSpectralForest(random_state=resampleId) elif cls.lower() == "tsf": return ib.TimeSeriesForest(random_state=resampleId) elif cls.lower() == "boss": return db.BOSSEnsemble() elif cls.lower() == "st": return st.ShapeletTransformClassifier(time_contract_in_mins=1500) elif cls.lower() == "dtw": return nn.KNeighborsTimeSeriesClassifier(metric="dtw") elif cls.lower() == "ee" or cls.lower() == "elasticensemble": return dist.ElasticEnsemble() elif cls.lower() == "shapedtw_raw": return ShapeDTW(subsequence_length=30, shape_descriptor_function="raw", metric_params=None) elif cls.lower() == "shapedtw_dwt": return ShapeDTW( subsequence_length=30, shape_descriptor_function="dwt", metric_params={"num_levels_dwt": 3}, ) elif cls.lower() == "shapedtw_paa": return ShapeDTW( subsequence_length=30, shape_descriptor_function="paa", metric_params={"num_intervals_paa": 5}, ) elif cls.lower() == "shapedtw_slope": return ShapeDTW( subsequence_length=30, shape_descriptor_function="slope", metric_params={"num_intervals_slope": 5}, ) elif cls.lower() == "shapedtw_hog1d": return ShapeDTW( subsequence_length=30, shape_descriptor_function="hog1d", metric_params={ "num_bins_hog1d": 8, "num_intervals_hog1d": 2, "scaling_factor_hog1d": 0.1, }, ) elif cls.lower() == "tsfcomposite": # It defaults to TSF return ensemble.TimeSeriesForestClassifier() elif cls.lower() == "risecomposite": steps = [ ("segment", RandomIntervalSegmenter(n_intervals=1, min_length=5)), ( "transform", FeatureUnion([ ( "acf", make_row_transformer( FunctionTransformer(func=acf_coefs, validate=False)), ), ( "ps", make_row_transformer( FunctionTransformer(func=powerspectrum, validate=False)), ), ]), ), ("tabularise", Tabularizer()), ("clf", DecisionTreeClassifier()), ] base_estimator = Pipeline(steps) return ensemble.TimeSeriesForestClassifier(estimator=base_estimator, n_estimators=100) else: raise Exception("UNKNOWN CLASSIFIER")
def set_classifier(cls, resampleId): """ Basic way of determining the classifier to build. To differentiate settings just and another elif. So, for example, if you wanted tuned TSF, you just pass TuneTSF and set up the tuning mechanism in the elif. This may well get superceded, it is just how e have always done it :param cls: String indicating which classifier you want :return: A classifier. """ if cls.lower() == "pf": return pf.ProximityForest(random_state=resampleId) elif cls.lower() == "pt": return pf.ProximityTree(random_state=resampleId) elif cls.lower() == "ps": return pf.ProximityStump(random_state=resampleId) elif cls.lower() == "rise": return fb.RandomIntervalSpectralForest(random_state=resampleId) elif cls.lower() == "tsf": return ib.TimeSeriesForest(random_state=resampleId) elif cls.lower() == "cif": return CanonicalIntervalForest(random_state=resampleId) elif cls.lower() == "boss": return BOSSEnsemble(random_state=resampleId) elif cls.lower() == "cboss": return ContractableBOSS(random_state=resampleId) elif cls.lower() == "tde": return TemporalDictionaryEnsemble(random_state=resampleId) elif cls.lower() == "st": return st.ShapeletTransformClassifier(time_contract_in_mins=1500) elif cls.lower() == "dtwcv": return nn.KNeighborsTimeSeriesClassifier(metric="dtwcv") elif cls.lower() == "ee" or cls.lower() == "elasticensemble": return dist.ElasticEnsemble() elif cls.lower() == "tsfcomposite": # It defaults to TSF return ensemble.TimeSeriesForestClassifier() elif cls.lower() == "risecomposite": steps = [ ("segment", RandomIntervalSegmenter(n_intervals=1, min_length=5)), ( "transform", FeatureUnion([ ( "acf", make_row_transformer( FunctionTransformer(func=acf_coefs, validate=False)), ), ( "ps", make_row_transformer( FunctionTransformer(func=powerspectrum, validate=False)), ), ]), ), ("tabularise", Tabularizer()), ("clf", DecisionTreeClassifier()), ] base_estimator = Pipeline(steps) return ensemble.TimeSeriesForestClassifier(estimator=base_estimator, n_estimators=100) elif cls.lower() == "rocket": rocket_pipeline = make_pipeline( Rocket(random_state=resampleId), RidgeClassifierCV(alphas=np.logspace(-3, 3, 10), normalize=True), ) return rocket_pipeline else: raise Exception("UNKNOWN CLASSIFIER")
def __init__(self, **kwargs): super().__init__(sktime_tsf.TimeSeriesForest(**kwargs), encode_sktime_X)