本文整理汇总了Python中pyeq3.dataConvertorService函数的典型用法代码示例。如果您正苦于以下问题:Python dataConvertorService函数的具体用法?Python dataConvertorService怎么用?Python dataConvertorService使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dataConvertorService函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: SetParametersAndFit
def SetParametersAndFit(equationString, inFittingTargetString, inExtendedVersionString, inTextData):
# individual cluster nodes must be able to import pyeq3
import pyeq3
exec('equation = ' + equationString +'("' + inFittingTargetString + '", "' + inExtendedVersionString + '")')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(inTextData, equation, False)
try:
# check for number of coefficients > number of data points to be fitted
if len(equation.GetCoefficientDesignators()) > len(equation.dataCache.allDataCacheDictionary['DependentData']):
return None
# check for functions requiring non-zero nor non-negative data such as 1/x, etc.
if equation.ShouldDataBeRejected(equation):
return None
equation.Solve()
fittedTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)
if fittedTarget > 1.0E290: # error too large
return None
except:
return None
return [fittedTarget, equation.GetDisplayName(), equation.solvedCoefficients, equationString, inExtendedVersionString]
开发者ID:bssrdf,项目名称:pyeq3,代码行数:26,代码来源:FitAllEquations_2D.py
示例2: test_SolveUsingLevenbergMarquardt_2D
def test_SolveUsingLevenbergMarquardt_2D(self):
coefficientsShouldBe = numpy.array([-8.01913565, 1.5264473])
model = pyeq3.Models_2D.Polynomial.Linear('SSQABS')
model.estimatedCoefficients = numpy.array([-4.0, 2.0]) # starting values for the simplex solver
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, model, False)
coefficients = pyeq3.solverService().SolveUsingSelectedAlgorithm(model, inAlgorithmName="Levenberg-Marquardt")
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:7,代码来源:Test_SolverService.py
示例3: test_SolveUsingODR_3D
def test_SolveUsingODR_3D(self):
coefficientsShouldBe = numpy.array([-0.04925, -0.90509, 1.28076])
model = pyeq3.Models_3D.Polynomial.Linear('ODR')
model.estimatedCoefficients = numpy.array([0.2, -1.0, 1.0]) # starting values for the ODR solver
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D, model, False)
coefficients = pyeq3.solverService().SolveUsingODR(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0E-03, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:7,代码来源:Test_SolverService.py
示例4: test_SolveUsingSimplex_SSQREL_2D
def test_SolveUsingSimplex_SSQREL_2D(self):
coefficientsShouldBe = numpy.array([-6.74510573, 1.32459622])
model = pyeq3.Models_2D.Polynomial.Linear('SSQREL')
model.estimatedCoefficients = numpy.array([1.0, 1.0]) # starting values for the simplex solver
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, model, False)
coefficients = pyeq3.solverService().SolveUsingSimplex(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:7,代码来源:Test_SolverService.py
示例5: test_SolveUsingSimplex_3D
def test_SolveUsingSimplex_3D(self):
coefficientsShouldBe = numpy.array([0.28658383, -0.90215775, 1.15483864])
model = pyeq3.Models_3D.Polynomial.Linear('SSQABS')
model.estimatedCoefficients = numpy.array([1.0, 1.0, 1.0]) # starting values for the simplex solver
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D, model, False)
coefficients = pyeq3.solverService().SolveUsingSimplex(model)
self.assertTrue(numpy.allclose(coefficients, coefficientsShouldBe, rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:7,代码来源:Test_SolverService.py
示例6: test_SolveUsingDE_3D
def test_SolveUsingDE_3D(self):
coefficientsShouldBe = numpy.array([-2.05105972, -0.49194959, 1.77817475])
model = pyeq3.Models_3D.UserDefinedFunction.UserDefinedFunction('SSQABS', 'Default', 'a + b*X + c*Y')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D_small, model, False)
coefficients = pyeq3.solverService().SolveUsingDE(model)
fittingTarget = model.CalculateAllDataFittingTarget(coefficients)
self.assertTrue(fittingTarget <= 0.1)
开发者ID:bssrdf,项目名称:pyeq3,代码行数:7,代码来源:Test_SolverService.py
示例7: test_GenerationOf_MATLAB
def test_GenerationOf_MATLAB(self):
generatedShouldBe = '''% To the best of my knowledge this code is correct.
% If you find any errors or problems please contact
% me directly using [email protected]
%
% James
% Fitting target: lowest sum of squared absolute error
% Fitting target value = 0.223837322455
function y = Polynomial_Linear_model(x_in)
\ttemp = 0.0;
\t% coefficients
\ta = -8.01913564075E+00;
\tb = 1.52644729419E+00;
\ttemp = temp + a + b .* x_in;
\ty = temp;
'''
equation = pyeq3.Models_2D.Polynomial.Linear('SSQABS')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)
equation.Solve()
generated = pyeq3.outputSourceCodeService().GetOutputSourceCodeMATLAB(equation, inDigitsOfPrecisionString = '11')
self.assertEqual(generated, generatedShouldBe)
开发者ID:bssrdf,项目名称:pyeq3,代码行数:27,代码来源:Test_OutputSourceCodeService.py
示例8: test_GenerationOf_CSHARP
def test_GenerationOf_CSHARP(self):
generatedShouldBe = '''// To the best of my knowledge this code is correct.
// If you find any errors or problems please contact
// me directly using [email protected]
//
// James
using System;
// Fitting target: lowest sum of squared absolute error
// Fitting target value = 0.223837322455
class Polynomial_Linear
{
\tdouble Polynomial_Linear_model(double x_in)
\t{
\t\tdouble temp;
\t\ttemp = 0.0;
\t\t// coefficients
\t\tdouble a = -8.01913564075E+00;
\t\tdouble b = 1.52644729419E+00;
\t\ttemp += a + b * x_in;
\t\treturn temp;
\t}
}
'''
equation = pyeq3.Models_2D.Polynomial.Linear('SSQABS')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)
equation.Solve()
generated = pyeq3.outputSourceCodeService().GetOutputSourceCodeCSHARP(equation, inDigitsOfPrecisionString = '11')
self.assertEqual(generated, generatedShouldBe)
开发者ID:bssrdf,项目名称:pyeq3,代码行数:34,代码来源:Test_OutputSourceCodeService.py
示例9: test_GenerationOf_PYTHON
def test_GenerationOf_PYTHON(self):
generatedShouldBe = '''# To the best of my knowledge this code is correct.
# If you find any errors or problems please contact
# me directly using [email protected]
#
# James
import math
# Fitting target: lowest sum of squared absolute error
# Fitting target value = 0.223837322455
def Polynomial_Linear_model(x_in):
temp = 0.0
# coefficients
a = -8.01913564075E+00
b = 1.52644729419E+00
temp += a + b * x_in
return temp
'''
equation = pyeq3.Models_2D.Polynomial.Linear('SSQABS')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, equation, False)
equation.Solve()
generated = pyeq3.outputSourceCodeService().GetOutputSourceCodePYTHON(equation, inDigitsOfPrecisionString = '11')
self.assertEqual(generated, generatedShouldBe)
开发者ID:bssrdf,项目名称:pyeq3,代码行数:28,代码来源:Test_OutputSourceCodeService.py
示例10: OnFit_3D
def OnFit_3D(self):
textData = self.text_3D.get("1.0", tk.END)
equationSelection = dfc.exampleEquationList_3D[self.equationSelect_3D.get()]
fittingTargetSelection = dfc.fittingTargetList[self.fittingTargetSelect_3D.get()]
# the GUI's fitting target string contains what we need - extract it
fittingTarget = fittingTargetSelection.split('(')[1].split(')')[0]
if equationSelection == 'Linear Polynomial':
self.equation = pyeq3.Models_3D.Polynomial.Linear(fittingTarget)
if equationSelection == 'Full Quadratic Polynomial':
self.equation = pyeq3.Models_3D.Polynomial.FullQuadratic(fittingTarget)
if equationSelection == 'Full Cubic Polynomial':
self.equation = pyeq3.Models_3D.Polynomial.FullCubic(fittingTarget)
if equationSelection == 'Monkey Saddle A':
self.equation = pyeq3.Models_3D.Miscellaneous.MonkeySaddleA(fittingTarget)
if equationSelection == 'Gaussian Curvature Of Whitneys Umbrella A':
self.equation = pyeq3.Models_3D.Miscellaneous.GaussianCurvatureOfWhitneysUmbrellaA(fittingTarget)
if equationSelection == 'NIST Nelson Autolog':
self.equation = pyeq3.Models_3D.NIST.NIST_NelsonAutolog(fittingTarget)
if equationSelection == 'Custom Polynomial One':
self.equation = pyeq3.Models_3D.Polynomial.UserSelectablePolynomial(fittingTarget, "Default", 3, 1)
# convert text to numeric data checking for log of negative numbers, etc.
try:
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(textData, self.equation, False)
except:
tk_mbox.showerror("Error", self.equation.reasonWhyDataRejected)
return
# check for number of coefficients > number of data points to be fitted
coeffCount = len(self.equation.GetCoefficientDesignators())
dataCount = len(self.equation.dataCache.allDataCacheDictionary['DependentData'])
if coeffCount > dataCount:
tk_mbox.showerror("Error", "This equation requires a minimum of " + str(coeffCount) + " data points, you have supplied " + repr(dataCount) + ".")
return
# Now the status dialog is used. Disable fitting buttons until thread completes
self.buttonFit_2D.config(state=tk.DISABLED)
self.buttonFit_3D.config(state=tk.DISABLED)
# create simple topl-level text dialog to display status as fitting progresses
# when the fitting thread completes, it will close the status box
self.statusBox = tk.Toplevel()
self.statusBox.title("Fitting Status")
self.statusBox.text = tk.Text(self.statusBox)
self.statusBox.text.pack()
# in tkinter the status box must be manually centered
self.statusBox.update_idletasks()
width = self.statusBox.winfo_width()
height = self.statusBox.winfo_height()
x = (self.statusBox.winfo_screenwidth() // 2) - (width // 2) # integer division
y = (self.statusBox.winfo_screenheight() // 2) - (height // 2) # integer division
self.statusBox.geometry('{}x{}+{}+{}'.format(width, height, x, y))
# thread will automatically start to run
# "status update" handler will re-enable buttons
self.fittingWorkerThread = FittingThread.FittingThread(self, self.equation)
开发者ID:tuyendothanh,项目名称:tkInterFit,代码行数:59,代码来源:FittingInterface.py
示例11: test_SplineSolve_3D
def test_SplineSolve_3D(self):
resultShouldBe = (numpy.array([0.607, 0.607, 0.607, 3.017, 3.017, 3.017]),
numpy.array([1.984, 1.984, 1.984, 3.153, 3.153, 3.153]),
numpy.array([2.33418963, 1.80079612, 5.07902936, 0.54445029, 1.04110843, 2.14180324, 0.26992805, 0.39148852, 0.8177307])
)
model = pyeq3.Models_3D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 2, inYOrder = 2)
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(model.exampleData, model, False)
result = model.Solve()
self.assertTrue(numpy.allclose(result[0], resultShouldBe[0], rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(result[1], resultShouldBe[1], rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(result[2], resultShouldBe[2], rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:11,代码来源:Test_ModelSolveMethods.py
示例12: test_SplineSolve_2D
def test_SplineSolve_2D(self):
resultShouldBe = (numpy.array([5.357, 5.357, 5.357, 5.357, 9.861, 9.861, 9.861, 9.861]),
numpy.array([0.38297001, 1.95535226, 4.59605664, 7.16162379, 0.0, 0.0, 0.0, 0.0]),
3
)
model = pyeq3.Models_2D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 3)
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(model.exampleData, model, False)
result = model.Solve()
self.assertTrue(numpy.allclose(result[0], resultShouldBe[0], rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(result[1], resultShouldBe[1], rtol=1.0E-06, atol=1.0E-300))
self.assertEqual(result[2], resultShouldBe[2])
开发者ID:bssrdf,项目名称:pyeq3,代码行数:11,代码来源:Test_ModelSolveMethods.py
示例13: fitEquationUsingDispyCluster
def fitEquationUsingDispyCluster(inEquationString, inFittingTargetString, inExtendedVersionString, inTextData):
# individual cluster nodes must be able to import pyeq3
import pyeq3
exec('equation = ' + inEquationString +'("' + inFittingTargetString + '", "' + inExtendedVersionString + '")')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(inTextData, equation, False)
equation.Solve()
fittedTarget = equation.CalculateAllDataFittingTarget(equation.solvedCoefficients)
# this result list allows easy sorting of multiple results later
return [fittedTarget, inEquationString, equation.solvedCoefficients]
开发者ID:bssrdf,项目名称:pyeq3,代码行数:12,代码来源:Test_Parallel_Fit.py
示例14: SetParametersAndFit
def SetParametersAndFit(inEquation, inPrintStatus): # utility function
global globalDataCache
global globalReducedDataCache
global globalRawData
inEquation.dataCache = globalDataCache
if inEquation.dataCache.allDataCacheDictionary == {}:
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(globalRawData, inEquation, False)
inEquation.dataCache.CalculateNumberOfReducedDataPoints(inEquation)
if inEquation.numberOfReducedDataPoints in globalReducedDataCache:
inEquation.dataCache.reducedDataCacheDictionary = globalReducedDataCache[inEquation.numberOfReducedDataPoints]
else:
inEquation.dataCache.reducedDataCacheDictionary = {}
try:
# check for number of coefficients > number of data points to be fitted
if len(inEquation.GetCoefficientDesignators()) > len(inEquation.dataCache.allDataCacheDictionary['DependentData']):
return None
# check for functions requiring non-zero nor non-negative data such as 1/x, etc.
if inEquation.ShouldDataBeRejected(inEquation):
return None
if inPrintStatus:
print('Process ID', str(os.getpid()), 'Fitting', inEquation.__module__, "'" + inEquation.GetDisplayName() + "'")
inEquation.Solve()
if inEquation.numberOfReducedDataPoints not in globalReducedDataCache:
globalReducedDataCache[inEquation.numberOfReducedDataPoints] = inEquation.dataCache.reducedDataCacheDictionary
target = inEquation.CalculateAllDataFittingTarget(inEquation.solvedCoefficients)
if target > 1.0E290: # error too large
return None
except:
print("Exception in " + inEquation.__class__.__name__ + '\n' + str(sys.exc_info()[0]) + '\n' + str(sys.exc_info()[1]) + '\n')
return None
t0 = copy.deepcopy(inEquation.__module__)
t1 = copy.deepcopy(inEquation.__class__.__name__)
t2 = copy.deepcopy(inEquation.extendedVersionHandler.__class__.__name__.split('_')[1])
t3 = copy.deepcopy(target)
t4 = copy.deepcopy(inEquation.solvedCoefficients)
t5 = copy.deepcopy(inEquation.polyfunctional2DFlags)
t6 = copy.deepcopy(inEquation.xPolynomialOrder)
t7 = copy.deepcopy(inEquation.rationalNumeratorFlags)
t8 = copy.deepcopy(inEquation.rationalDenominatorFlags)
return [t0,t1,t2,t3,t4,t5,t6,t7,t8]
开发者ID:bssrdf,项目名称:pyeq3,代码行数:50,代码来源:FitAllEquationsInParallelUsingQueues_LargeResultList_2D.py
示例15: test_SolveUsingSpline_2D
def test_SolveUsingSpline_2D(self):
knotPointsShouldBe = numpy.array([5.357, 5.357, 5.357, 5.357, 9.861, 9.861, 9.861, 9.861])
coefficientsShouldBe = numpy.array([ 0.38297001, 1.95535226, 4.59605664, 7.16162379, 0.0, 0.0, 0.0, 0.0])
testEvaluationShouldBe = numpy.array([4.02361487093])
model = pyeq3.Models_2D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 3)
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, model, False)
fittedParameters = pyeq3.solverService().SolveUsingSpline(model)
# example of later using the saved spline knot points and coefficients
unFittedSpline = scipy.interpolate.fitpack2.UnivariateSpline(model.dataCache.allDataCacheDictionary['X'], model.dataCache.allDataCacheDictionary['DependentData'], s=model.smoothingFactor, k=model.xOrder)
unFittedSpline._eval_args = fittedParameters
testEvaluation = unFittedSpline(numpy.array([8.0]))
self.assertTrue(numpy.allclose(testEvaluation, testEvaluationShouldBe, rtol=1.0E-10, atol=1.0E-300))
self.assertTrue(numpy.equal(fittedParameters[0], knotPointsShouldBe).all())
self.assertTrue(numpy.allclose(fittedParameters[1], coefficientsShouldBe, rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:16,代码来源:Test_SolverService.py
示例16: OnFit2D
def OnFit2D(self, evt):
textData = str(self.text_2D.GetValue())
equationSelection = self.rbEqChoice_2D.GetStringSelection()
fittingTargetSelection = self.rbFittingTargetChoice_2D.GetStringSelection()
# the GUI's fitting target string contains what we need - extract it
fittingTarget = fittingTargetSelection.split('(')[1].split(')')[0]
if equationSelection == 'Linear Polynomial':
self.equation = pyeq3.Models_2D.Polynomial.Linear(fittingTarget)
if equationSelection == 'Quadratic Polynomial':
self.equation = pyeq3.Models_2D.Polynomial.Quadratic(fittingTarget)
if equationSelection == 'Cubic Polynomial':
self.equation = pyeq3.Models_2D.Polynomial.Cubic(fittingTarget)
if equationSelection == 'Witch Of Maria Agnesi A':
self.equation = pyeq3.Models_2D.Miscellaneous.WitchOfAgnesiA(fittingTarget)
if equationSelection == 'VanDeemter Chromatography':
self.equation = pyeq3.Models_2D.Engineering.VanDeemterChromatography(fittingTarget)
if equationSelection == 'Gamma Ray Angular Distribution (degrees) B':
self.equation = pyeq3.Models_2D.LegendrePolynomial.GammaRayAngularDistributionDegreesB(fittingTarget)
if equationSelection == 'Exponential With Offset':
self.equation = pyeq3.Models_2D.Exponential.Exponential(fittingTarget, 'Offset')
# convert text to numeric data checking for log of negative numbers, etc.
try:
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(textData, self.equation, False)
except:
wx.MessageBox(self.equation.reasonWhyDataRejected, "Error")
return
# check for number of coefficients > number of data points to be fitted
coeffCount = len(self.equation.GetCoefficientDesignators())
dataCount = len(self.equation.dataCache.allDataCacheDictionary['DependentData'])
if coeffCount > dataCount:
wx.MessageBox("This equation requires a minimum of " + str(coeffCount) + " data points, you have supplied " + repr(dataCount) + ".", "Error")
return
# Now the status dialog is used. Disable fitting buttons until thread completes
self.btnFit2D.Disable()
self.btnFit3D.Disable()
self.statusBox.text.SetValue('')
self.statusBox.Show() # hidden by OnThreadStatus() when thread completes
# thread will automatically start to tun
self.fittingWorkerThread = CustomThreads.FittingThread(self, self.equation)
开发者ID:raj347,项目名称:wxPythonFit,代码行数:45,代码来源:wxPythonFit.py
示例17: OnFit3D
def OnFit3D(self, evt):
textData = str(self.text_3D.GetValue())
equationSelection = self.rbEqChoice_3D.GetStringSelection()
fittingTargetSelection = self.rbFittingTargetChoice_3D.GetStringSelection()
# the GUI's fitting target string contains what we need - extract it
fittingTarget = fittingTargetSelection.split('(')[1].split(')')[0]
if equationSelection == 'Linear Polynomial':
self.equation = pyeq3.Models_3D.Polynomial.Linear(fittingTarget)
if equationSelection == 'Full Quadratic Polynomial':
self.equation = pyeq3.Models_3D.Polynomial.FullQuadratic(fittingTarget)
if equationSelection == 'Full Cubic Polynomial':
self.equation = pyeq3.Models_3D.Polynomial.FullCubic(fittingTarget)
if equationSelection == 'Monkey Saddle A':
self.equation = pyeq3.Models_3D.Miscellaneous.MonkeySaddleA(fittingTarget)
if equationSelection == 'Gaussian Curvature Of Whitneys Umbrella A':
self.equation = pyeq3.Models_3D.Miscellaneous.GaussianCurvatureOfWhitneysUmbrellaA(fittingTarget)
if equationSelection == 'NIST Nelson Autolog':
self.equation = pyeq3.Models_3D.NIST.NIST_NelsonAutolog(fittingTarget)
if equationSelection == 'Custom Polynomial One':
self.equation = pyeq3.Models_3D.Polynomial.UserSelectablePolynomial(fittingTarget, "Default", 3, 1)
# convert text to numeric data checking for log of negative numbers, etc.
try:
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(textData, self.equation, False)
except:
wx.MessageBox(self.equation.reasonWhyDataRejected, "Error")
return
# check for number of coefficients > number of data points to be fitted
coeffCount = len(self.equation.GetCoefficientDesignators())
dataCount = len(self.equation.dataCache.allDataCacheDictionary['DependentData'])
if coeffCount > dataCount:
wx.MessageBox("This equation requires a minimum of " + str(coeffCount) + " data points, you have supplied " + repr(dataCount) + ".", "Error")
return
# Now the status dialog is used. Disable fitting buttons until thread completes
self.btnFit2D.Disable()
self.btnFit3D.Disable()
self.statusBox.text.SetValue('')
self.statusBox.Show() # hidden by OnThreadStatus() when thread completes
# thread will automatically start to run
self.fittingWorkerThread = CustomThreads.FittingThread(self, self.equation)
开发者ID:raj347,项目名称:wxPythonFit,代码行数:45,代码来源:wxPythonFit.py
示例18: test_SolveUsingSpline_3D
def test_SolveUsingSpline_3D(self):
xKnotPointsShouldBe = numpy.array([0.607, 0.607, 0.607, 3.017, 3.017, 3.017])
yKnotPointsShouldBe = numpy.array([1.984, 1.984, 1.984, 3.153, 3.153, 3.153])
coefficientsShouldBe = numpy.array([2.33418963, 1.80079612, 5.07902936, 0.54445029, 1.04110843, 2.14180324, 0.26992805, 0.39148852, 0.8177307])
testEvaluationShouldBe = numpy.array([0.76020577997])
model = pyeq3.Models_3D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 2, inYOrder = 2)
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_3D, model, False)
fittedParameters = pyeq3.solverService().SolveUsingSpline(model)
# example of later using the saved spline knot points and coefficients
unFittedSpline = scipy.interpolate.fitpack2.SmoothBivariateSpline(model.dataCache.allDataCacheDictionary['X'], model.dataCache.allDataCacheDictionary['Y'], model.dataCache.allDataCacheDictionary['DependentData'], s=model.smoothingFactor, kx=model.xOrder, ky=model.yOrder)
unFittedSpline.tck = fittedParameters
testEvaluation = unFittedSpline.ev(2.5, 2.5)
self.assertTrue(numpy.allclose(testEvaluation, testEvaluationShouldBe, rtol=1.0E-10, atol=1.0E-300))
self.assertTrue(numpy.equal(fittedParameters[0], xKnotPointsShouldBe).all())
self.assertTrue(numpy.equal(fittedParameters[1], yKnotPointsShouldBe).all())
self.assertTrue(numpy.allclose(fittedParameters[2], coefficientsShouldBe, rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:18,代码来源:Test_SolverService.py
示例19: test_CalculateCoefficientAndFitStatisticsUsingUserDefinedFunction_2D
def test_CalculateCoefficientAndFitStatisticsUsingUserDefinedFunction_2D(self):
model_df_e_ShouldBe = 9.0
model_df_r_ShouldBe = 1.0
model_r2_ShouldBe = 0.996389372503
model_rmse_ShouldBe = 00.142649386595
model_r2adj_ShouldBe = 0.99598819167
model_Fstat_ShouldBe = 2483.64151657
model_Fpv_ShouldBe = 2.64577248998e-12
model_ll_ShouldBe = 5.81269665017
model_aic_ShouldBe = -0.693217572758
model_bic_ShouldBe = -0.620872977703
model_cov_beta_ShouldBe = numpy.array([[ 1.93842855, -0.26398964], [-0.26398964, 0.03772113]])
model_sd_beta_ShouldBe = numpy.array([ 0.0482103, 0.00093816])
model_tstat_beta_ShouldBe = numpy.array([-36.52226166, 49.83614545])
model_pstat_beta_ShouldBe = numpy.array([4.28455049e-11, 2.64588351e-12])
model_ci_ShouldBe = numpy.array([[-8.5158339321793157, -7.5224373409719512], [1.4571589560702567, 1.595735631605572]])
model = pyeq3.Models_2D.UserDefinedFunction.UserDefinedFunction('SSQABS', 'Default', 'm*X + b')
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(model.exampleData, model, False)
model.Solve()
model.CalculateModelErrors(model.solvedCoefficients, model.dataCache.allDataCacheDictionary)
model.CalculateCoefficientAndFitStatistics()
self.assertTrue(numpy.allclose(model.df_e, model_df_e_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.df_r, model_df_r_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.r2, model_r2_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.rmse, model_rmse_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.r2adj, model_r2adj_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.Fstat, model_Fstat_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.Fpv, model_Fpv_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.ll, model_ll_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.aic, model_aic_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.bic, model_bic_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.cov_beta, model_cov_beta_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.sd_beta, model_sd_beta_ShouldBe, rtol=1.0E-05, atol=1.0E-300)) # extra tolerance
self.assertTrue(numpy.allclose(model.tstat_beta, model_tstat_beta_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.pstat_beta, model_pstat_beta_ShouldBe, rtol=1.0E-04, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.ci, model_ci_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
开发者ID:bssrdf,项目名称:pyeq3,代码行数:38,代码来源:Test_CalculateCoefficientAndFitStatistics.py
示例20: test_CalculateCoefficientAndFitStatisticsUsingSpline_2D
def test_CalculateCoefficientAndFitStatisticsUsingSpline_2D(self):
model_df_e_ShouldBe = 8.0
model_df_r_ShouldBe = 2.0
model_r2_ShouldBe = 0.999870240966
model_rmse_ShouldBe = 0.0270425329959
model_r2adj_ShouldBe = 0.999837801207
model_Fstat_ShouldBe = 30822.3699783
model_Fpv_ShouldBe = 3.33066907388e-16
model_ll_ShouldBe = 24.1054640542
model_aic_ShouldBe = -3.83735710076
model_bic_ShouldBe = -3.72884020818
model_cov_beta_ShouldBe = None
model_sd_beta_ShouldBe = None
model_tstat_beta_ShouldBe = None
model_pstat_beta_ShouldBe = None
model_ci_ShouldBe = None
model = pyeq3.Models_2D.Spline.Spline(inSmoothingFactor = 1.0, inXOrder = 3)
pyeq3.dataConvertorService().ConvertAndSortColumnarASCII(DataForUnitTests.asciiDataInColumns_2D, model, False)
pyeq3.solverService().SolveUsingSpline(model)
model.CalculateModelErrors(model.solvedCoefficients, model.dataCache.allDataCacheDictionary)
model.CalculateCoefficientAndFitStatistics()
self.assertTrue(numpy.allclose(model.df_e, model_df_e_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.df_r, model_df_r_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.r2, model_r2_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.rmse, model_rmse_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.r2adj, model_r2adj_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.Fstat, model_Fstat_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.Fpv, model_Fpv_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.ll, model_ll_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.aic, model_aic_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertTrue(numpy.allclose(model.bic, model_bic_ShouldBe, rtol=1.0E-06, atol=1.0E-300))
self.assertEqual(model.cov_beta, None)
self.assertEqual(model.sd_beta, None)
self.assertEqual(model.tstat_beta, None)
self.assertEqual(model.pstat_beta, None)
self.assertEqual(model.ci, None)
开发者ID:bssrdf,项目名称:pyeq3,代码行数:38,代码来源:Test_CalculateCoefficientAndFitStatistics.py
注:本文中的pyeq3.dataConvertorService函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论