mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-26 17:49:09 +00:00
analysis.py v 1.1.6.001
This commit is contained in:
parent
5b39bb771e
commit
bfa69bf070
@ -7,10 +7,12 @@
|
|||||||
# current benchmark of optimization: 1.33 times faster
|
# current benchmark of optimization: 1.33 times faster
|
||||||
# setup:
|
# setup:
|
||||||
|
|
||||||
__version__ = "1.1.6.000"
|
__version__ = "1.1.6.001"
|
||||||
|
|
||||||
# changelog should be viewed using print(analysis.__changelog__)
|
# changelog should be viewed using print(analysis.__changelog__)
|
||||||
__changelog__ = """changelog:
|
__changelog__ = """changelog:
|
||||||
|
1.1.6.001:
|
||||||
|
- added additional hyperparameters to decisiontree()
|
||||||
1.1.6.000:
|
1.1.6.000:
|
||||||
- fixed __version__
|
- fixed __version__
|
||||||
- fixed __all__ order
|
- fixed __all__ order
|
||||||
@ -391,10 +393,10 @@ def pca(data, kernel = sklearn.decomposition.PCA(n_components=2)):
|
|||||||
|
|
||||||
return kernel.fit_transform(data)
|
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)
|
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)
|
model = model.fit(data_train,labels_train)
|
||||||
predictions = model.predict(data_test)
|
predictions = model.predict(data_test)
|
||||||
accuracy = sklearn.metrics.accuracy_score(labels_test, predictions)
|
accuracy = sklearn.metrics.accuracy_score(labels_test, predictions)
|
||||||
|
Loading…
Reference in New Issue
Block a user