예제 #1
0
	output, metadata = D.readLearningResults(filename)

	output_vec.append(output)	
	metadata_vec.append(metadata)
	filename_vec.append(filename)

print('files = [')
for f in filename_vec:
	print("\'"+f+"\',")
print(']')

## PLOT

A = Analyze()
savename = 'Burgers_MC_CDF'
A.plotRMSEandCoefs(output_vec, MCcountvec, '$N_{MC}$, Number of Realizations', threshold=0.01, set_grid=False, cdf=True, invert_sign=True, savename='Burgers_MC_CDF')

##############

##Function of Regularization - For MC = num_realizations (MAX)
## WTF??
# fig, ax = plt.subplots(1, 2)
# alphas, mse = A.getRegMseDependence_single(output_vec[-1])
# ax[0].plot(alphas, mse)
# ax[0].set_xlabel('Regularization Coefficient')
# ax[0].set_ylabel('MSE')

# alphas, coefficients, feats = A.getCoefRegDependence(output_vec[-1], threshold=0.0)
# for i in range(len(feats)):
# 	ax[1].plot(alphas, coefficients[i])
# ax[1].set_xlabel('Regularization Coefficient')
예제 #2
0
    # READ Learning
    D = DataIO(case, directory=LEARNDIR)
    output, metadata = D.readLearningResults(filename)

    output_vec.append(output)
    metadata_vec.append(metadata)
    filename_vec.append(filename)

print('files = [')
for f in filename_vec:
    print("\'" + f + "\',")
print(']')

## PLOT
A = Analyze()
savename = 'advectreact_rde'
A.plotRMSEandCoefs(output_vec,
                   rfe_alpha_vec,
                   'Percentage Distance from Boundary',
                   threshold=0.01,
                   invert_sign=True,
                   savename=savename)

# Plot boundary
s = 8
V = Visualize(grid)
V.plot_fu3D(fu)
V.plot_fu(fu, dim='t', steps=s)
V.plot_fu(fu, dim='x', steps=s)
V.show()
예제 #3
0
    output_vec.append(output)
    metadata_vec.append(metadata)
    filename_vec.append(filename)

print('files = [')
for f in filename_vec:
    print("\'" + f + "\',")
print(']')

## PLOT
A = Analyze()
savename = 'advectreact_MC' + "_" + LassoType + "_" + str(mu[0]).split('.')[1]
A.plotRMSEandCoefs(output_vec,
                   MCcountvec,
                   'Number of Realizations',
                   threshold=0.01,
                   invert_sign=True,
                   use_logx=False,
                   set_grid=True,
                   savename=savename)

## PLOT 3D

# s = 8
# V = Visualize(grid)
# V.plot_fu3D(fu)
# V.plot_fu(fu, dim='t', steps=s)
# V.plot_fu(fu, dim='x', steps=s)
# V.show()
예제 #4
0
                         trainratio=trainratio,
                         verbose=printlearning)
    filename = difflearn.fit_sparse(feature_opt=feature_opt, variableCoef=variableCoef, variableCoefBasis=variableCoefBasis, \
            variableCoefOrder=coeforder, use_rfe=use_rfe, rfe_alpha=rfe_alpha, nzthresh=nzthresh, maxiter=maxiter, \
            LassoType=LassoType, RegCoef=RegCoef, cv=cv, criterion=criterion, print_rfeiter=print_rfeiter, shuffle=shuffle, \
            basefile=savenamepdf, adjustgrid=adjustgrid, save=save, normalize=normalize, comments=comments)

    # READ Learning
    D = DataIO(case, directory=LEARNDIR)
    output, metadata = D.readLearningResults(filename)

    output_vec.append(output)
    metadata_vec.append(metadata)
    filename_vec.append(filename)

## PLOT

# Error function of MC

A = Analyze()
savename = 'Burgers_rfe'
A.plotRMSEandCoefs(output_vec,
                   rfe_alpha_vec,
                   'RFE Threshold',
                   threshold=0.01,
                   invert_sign=True,
                   savename=savename)
plt.show()

# Plot Coefficients as a function of t0
예제 #5
0
    output_vec.append(output)
    metadata_vec.append(metadata)
    filename_vec.append(filename)

## PLOT

# Error function of MC
# fig = plt.figure()

A = Analyze()
savename = 'Burgers_shock'
portion = [(t[1] - 0.5) / (t[1] - t[0]) for t in mtvec]
A.plotRMSEandCoefs(output_vec,
                   portion,
                   '$p_s$, Time Portion in Shock Region',
                   threshold=0.01,
                   invert_sign=True,
                   cdf=True,
                   set_grid=False,
                   savename='Burgers_shock')

# trainRMSE, testRMSE = A.getTrainTestDependence(output_vec)
# t0 = [t[0] for t in mtvec]

# plt.plot(t0, testRMSE, linwidth=3)
# plt.plot(t0, trainRMSE, linwidth=3)
# plt.xlabel('Initial Time (0.5 duration)', fontsize=14)
# plt.ylabel('Test Error', fontsize=14)
# plt.legend(['Test Error', 'Train Error'], fontsize=14)

# # Plot Coefficients as a function of t0
# fig = plt.figure()
예제 #6
0
                    output, metadata = D.readLearningResults(filename)

                    output_vec.append(output)
                    metadata_vec.append(metadata)
                    filename_vec.append(filename)

                print('files = [')
                for f in filename_vec:
                    print("\'" + f + "\',")
                print(']')

                ## PLOT
                A = Analyze()
                savename = 'advectreact_rfe' + "_" + feature_opt + "_" + LassoType + "_" + str(
                    coeforder)
                A.plotRMSEandCoefs(output_vec,
                                   rfe_alpha_vec,
                                   'RFE Threshold',
                                   threshold=0.001,
                                   use_logx=True,
                                   set_grid=True,
                                   invert_sign=True,
                                   savename=savename,
                                   show=True)

            except:
                print("\n\n\n************************\n\n\n")
                print("Exception Happened for ", feature_opt, " ", LassoType,
                      " ", rfe_alpha)
                print("\n\n\n************************\n\n\n")