analysis.py v 1.1.6.001

This commit is contained in:
art 2019-11-05 12:53:39 -06:00
parent 2cf7d73c9c
commit c886ca8e3f

View File

@ -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)