analysis.py v 1.1.9.000

This commit is contained in:
ltcptgeneral 2019-11-06 15:26:13 -06:00
parent 5b12fa4f9d
commit b6ecda5174

View File

@ -7,10 +7,13 @@
# current benchmark of optimization: 1.33 times faster # current benchmark of optimization: 1.33 times faster
# setup: # setup:
__version__ = "1.1.8.000" __version__ = "1.1.9.000"
# changelog should be viewed using print(analysis.__changelog__) # changelog should be viewed using print(analysis.__changelog__)
__changelog__ = """changelog: __changelog__ = """changelog:
1.1.9.000:
- added SVM class, subclasses, and functions
- note: untested
1.1.8.000: 1.1.8.000:
- added NaiveBayes classification engine - added NaiveBayes classification engine
- note: untested - note: untested
@ -471,6 +474,67 @@ class NaiveBayes:
return model, cm, cr return model, cm, cr
class SVM:
class CustomKernel:
def __init__(self, C, kernel, degre, gamma, coef0, shrinking, probability, tol, cache_size, class_weight, verbose, max_iter, decision_function_shape, random_state):
return sklearn.svm.SVC(C = C, kernel = kernel, gamma = gamma, coef0 = coef0, shrinking + shrinking, probability = probability, tol = tol, cache_size = cache_size, class_weight = class_weight, verbose = verbose, max_iter = max_iter, decision_function_shape = decision_function_shape, random_state = random_state)
class StandardKernel:
def __init__(self, kernel, C=1.0, degree=3, gamma='auto_deprecated', coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight=None, verbose=False, max_iter=-1, decision_function_shape='ovr', random_state=None):
return sklearn.svm.SVC(C = C, kernel = kernel, gamma = gamma, coef0 = coef0, shrinking + shrinking, probability = probability, tol = tol, cache_size = cache_size, class_weight = class_weight, verbose = verbose, max_iter = max_iter, decision_function_shape = decision_function_shape, random_state = random_state)
class PrebuiltKernel:
class Linear:
def __init__(self):
return sklearn.svm.SVC(kernel = 'linear')
class Polynomial:
def __init__(self, power, r_bias):
return sklearn.svm.SVC(kernel = 'polynomial', degree = power, coef0 = r_bias)
class RBF:
def __init__(self, gamma):
return sklearn.svm.SVC(kernel = 'rbf', gamma = gamma)
class Sigmoid:
def __init__(self, r_bias):
return sklearn.svm.SVC(kernel = 'sigmoid', coef0 = r_bias)
def fit(self, kernel, train_data, train_outputs): # expects *2d data, 1d labels or outputs
return kernel.fit(train_data, train_outputs)
def eval_classification(self, kernel, test_data, test_outputs):
predictions = kernel.predict(test_data)
cm = sklearn.metrics.confusion_matrix(labels_test, predictions)
cr = sklearn.metrics.classification_report(labels_test, predictions)
return cm, cr
def eval_regression(self, kernel, test_data, test_outputs):
predictions = kernel.predict(test_data)
r_2 = r_squared(predictions, test_outputs)
mse = mse(predictions, test_outputs)
rms = rms(predictions, test_outputs)
return r_2, mse, rms
class Regression: class Regression:
# Titan Robotics Team 2022: CUDA-based Regressions Module # Titan Robotics Team 2022: CUDA-based Regressions Module