From bfa69bf070b580c549c03e64d23d14eeeda67758 Mon Sep 17 00:00:00 2001 From: art Date: Tue, 5 Nov 2019 12:53:39 -0600 Subject: [PATCH] analysis.py v 1.1.6.001 --- data analysis/analysis/analysis.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data analysis/analysis/analysis.py b/data analysis/analysis/analysis.py index dbe35ec6..5d58ee3d 100644 --- a/data analysis/analysis/analysis.py +++ b/data analysis/analysis/analysis.py @@ -7,10 +7,12 @@ # current benchmark of optimization: 1.33 times faster # setup: -__version__ = "1.1.6.000" +__version__ = "1.1.6.001" # changelog should be viewed using print(analysis.__changelog__) __changelog__ = """changelog: +1.1.6.001: + - added additional hyperparameters to decisiontree() 1.1.6.000: - fixed __version__ - fixed __all__ order @@ -391,10 +393,10 @@ def pca(data, kernel = sklearn.decomposition.PCA(n_components=2)): return kernel.fit_transform(data) -def decisiontree(data, labels, test_size = 0.3): #expects 2d data and 1d labels +def decisiontree(data, labels, test_size = 0.3, criterion = "gini", splitter = "default", max_depth = None): #expects 2d data and 1d labels data_train, data_test, labels_train, labels_test = sklearn.model_selection.train_test_split(data, labels, test_size=test_size, random_state=1) - model = sklearn.tree.DecisionTreeClassifier() + model = sklearn.tree.DecisionTreeClassifier(criterion = criterion, splitter = splitter, max_depth = max_depth) model = model.fit(data_train,labels_train) predictions = model.predict(data_test) accuracy = sklearn.metrics.accuracy_score(labels_test, predictions)