def validate_sintel(sess, framework, dataset, path): tflearn.is_training(False, session=sess) validationImg1, validationImg2, validationFlow = zip(*dataset) validationSize = len(dataset) batchEpe = [] c = 0 for j in tqdm(range(0, validationSize, batchSize)): if j + batchSize <= validationSize: batchImg1 = [sintel.load(p) for p in validationImg1[j: j + batchSize]] batchImg2 = [sintel.load(p) for p in validationImg2[j: j + batchSize]] batchFlow = [sintel.load(p) for p in validationFlow[j: j + batchSize]] batchEpe.append(sess.run(framework.epe, framework.feed_dict( img1=batchImg1, img2=batchImg2, flow=batchFlow ))) if (j // batchSize) % 5 == 0: batchPred = sess.run(framework.flow, framework.feed_dict( img1=batchImg1, img2=batchImg2, flow=batchFlow )) batchImg1 = batchImg1[::4] batchImg2 = batchImg2[::4] batchFlow = batchFlow[::4] batchPred = batchPred[::4] visualization.plot(batchImg1, batchImg2, batchFlow, batchPred, path, c) c += len(batchImg1) mean_epe = np.mean(batchEpe) return float(mean_epe)
def summary_analysis(data, chamber, param): step_l = list(set(data['step'])) print(data['step'].value_counts()) diff = {param: [], "current": [], "previous": []} index_l = {} # 각 step별 데이터들의 index 리스트 for step in step_l: index_l[step] = list(data[data['step'] == step].index) for index in data.index: if index % 1000 == 0: print('processing ...', index) step = data.loc[index]['step'] # 동일한 step을 가진 데이터 중 이전 주기 데이터 previous_index = index_l[step].index(index) - 1 if previous_index < 0: previous_index = 0 previous_index = index_l[step][previous_index] current_value = data.loc[index][param] previous_value = data.loc[previous_index][param] diff["current"].append(current_value) diff["previous"].append(previous_value) diff[param].append(current_value - previous_value) diff_df = pd.DataFrame(diff) diff_df['time'] = data['time'] diff_df['step'] = data['step'] print(diff_df) vs.plot(diff_df, param, chamber, show=True, save=False, save_folder="")
def periodity_analysis(chamber): parameter = 'Ch C MFC 2 Flow x1000' df = pd.read_csv(parameter + " summary_by_step.csv") df['time'] = pd.to_datetime(df['time']) print(df) for step in df.columns[1:]: vs.plot(df, step, chamber, show=True, save=False, save_folder="")
def visualize(instrument, tensor_data, epoch, num_batch): for i in range(tensor_data.shape[0]): dimage = tensor_data.data[i].numpy() df = DataFrame(dimage, columns=['high', 'low', 'open', 'close']) plot(df, epoch, num_batch, i, instrument=instrument, generate=True, v=False)
def solveLinear(self): solved = False i = 0 while (not solved): xa, ya = self.updateW() i += 1 if len(xa) == 0: solved = True print("Linearly Seperable:") print("Solved in " + str(i) + " epochs / " + str(self.updates) + \ " updates:") print("W = " + str(self.w) + "\n") if self.visual: vis.plot(self.data.xp, self.data.yp, self.data.xn, self.data.yn,\ xa, ya, self.w)
def execute(input_file, op_exec): # pass """ This function will help execute the tree """ # input_file = viz.read_matrix(input_file) input_file = viz.csv_to_ts(input_file) input_file = prep.impute_missing_data(input_file) input_file = prep.impute_outliers(input_file) return_value = None if op_exec == "plot": return_value = viz.plot(input_file) elif op_exec == "histogram": return_value = viz.histogram(input_file) elif op_exec == "summary": return_value = viz.summary(input_file) elif op_exec == "box_plot": return_value = viz.box_plot(input_file) elif op_exec == "shapiro_wilk": return_value = viz.shapiro_wilk(input_file) elif op_exec == "d_agostino": return_value = viz.d_agostino(input_file) elif op_exec == "anderson_darling": return_value = viz.anderson_darling(input_file) elif op_exec == "qq_plot": return_value = viz.qq_plot(input_file) return return_value
def solveNonlinear(self, epochs): solved = False epochstart = epochs xa, ya = [], [] while (not solved and epochs > 0 and self.cError > 0.08): epochs -= 1 xa, ya = self.updateW() if len(xa) == 0: solved = True print("Linearly Nonseperable:") print("Solution after " + str(epochstart-epochs) + " epochs / " + \ str(self.updates) + " updates:") print("W = " + str(self.w)) print(str(len(xa)) + " still misclassified. Error rate is " + \ str(int(100*self.cError)) + "%\n") if self.visual: vis.plot(self.data.xp, self.data.yp, self.data.xn, self.data.yn,\ xa, ya, self.w)
def visualization(df, save_folder, chamber, show=True, save=False): # 실수 형식의 데이터만 분석 for parameter in df.select_dtypes('number').columns: #line plot (by time) vs.plot(df, parameter, chamber, show=show, save=save, save_folder=save_folder) # scatter plot (by recipe) vs.scatter_plot(df, parameter, chamber, group_by="Ch " + chamber + " Running Recipe", show=show, save=save, save_folder=save_folder) # scatter plot (by step) vs.scatter_plot(df, parameter, chamber, group_by="Ch " + chamber + " Step Number", show=show, save=save, save_folder=save_folder) # box plot (by step) vs.box_plot(df, parameter, chamber, group_by="Ch " + chamber + " Step Number", show=show, save=save, save_folder=save_folder) # historam vs.histogram(df, parameter, show=show, save=save, save_folder=save_folder)
def test(self, testdata): n_misclass = 0 xa, ya = [], [] for d in testdata.points: x = [d.coords[0]] + d.coords[1] + [d.coords[2]] if d.c > 0 and dot(self.w, x) < 0: n_misclass += 1 xa.append(x[1]) ya.append(x[-1]) if d.c < 0 and dot(self.w, x) >= 0: n_misclass += 1 xa.append(x[1]) ya.append(x[-1]) error = n_misclass / len(testdata.points) print("Testing:\nMisclassified: " + str(n_misclass), "Test Error: " + \ str(int(100*error)) + "%") if self.visual: vis.plot(testdata.xp, testdata.yp, testdata.xn, testdata.yn,\ xa, ya, self.w)
def validate(sess, framework, model=None): tflearn.is_training(False, session=sess) batchEpe = [] for j in range(0, validationSize, batchSize): if j + batchSize <= validationSize: batchImg1 = validationImg1[j: j + batchSize] batchImg2 = validationImg2[j: j + batchSize] batchFlow = validationFlow[j: j + batchSize] # batchGamma = [1.0] * batchSize # batchCropX = [32] * batchSize # batchCropY = [32] * batchSize # batchBrightness = [0.0] * batchSize # batchContrast = [1.0] * batchSize batchEpe.append(sess.run(framework.epe, framework.feed_dict( img1=batchImg1, img2=batchImg2, flow=batchFlow ))) if model is not None and j == 0: batchPred = sess.run(framework.flow, framework.feed_dict( img1=batchImg1, img2=batchImg2, flow=batchFlow )) visualization.plot(batchImg1, batchImg2, batchFlow, batchPred, model) # batchEpe.append(sess.run(framework.epe, { # 'img1:0': batchImg1, # 'img2:0': batchImg2, # 'flow:0': batchFlow, # 'gamma:0': batchGamma, # 'cropX:0': batchCropX, # 'cropY:0': batchCropY, # 'brightness:0': batchBrightness, # 'contrast:0': batchContrast # })) return float(np.mean(batchEpe))
def testing(csv): # establish series variable to be used throughout series = viz.csv_to_ts(csv) print("\n----data frame head----") print(series.head()) print("\n----data frame column types----") print(series.dtypes) print("\n----plot----") viz.plot(series) print("\n----histogram----") viz.histogram(series) print("\n----5 number summary----") viz.summary(series) print("\n----box plot----") viz.box_plot(series) print("\n----Shapiro-Wilk Normality test----") sw_stats = viz.shapiro_wilk(series) print("\n----d'agostino Normality test----") ag_stats = viz.d_agostino(series) print("\n----Quantile-Quantile Plot----") viz.qq_plot(series) print("\n----Anderson Darling Normality test----") ad_stats = viz.anderson_darling(series) print("\n----Mean Squared Error----") actual = [0.0, 0.5, 0.0, 0.5, 0.0] forecast = [0.2, 0.4, 0.1, 0.6, 0.2] mse_stats = viz.MSE(actual, forecast) print("\n----Root Mean Square Error----") actual = [0.0, 0.5, 0.0, 0.5, 0.0] forecast = [0.2, 0.4, 0.1, 0.6, 0.2] rmse_stats = viz.RMSE(actual, forecast) print("\n----Mean Absolute Percentage Error----") actual = [12, 13, 14, 15, 15,22, 27] forecast = [11, 13, 14, 14, 15, 16, 18] mape_stats = viz.MAPE(actual, forecast) print("\n----Symmetrical Mean Absolute Percentage Error----") actual = np.array([12, 13, 14, 15, 15,22, 27]) forecast = np.array([11, 13, 14, 14, 15, 16, 18]) smape_stats = viz.sMAPE(actual, forecast)
def viewForm(): st.plotly_chart(plot()) title = st.text_input("Report Title") desc = st.text_area('Report Description') btn = st.button("Submit") if btn: report1 = Report(title=title, desc=desc, data="") sess.add(report1) sess.commit() st.success('Report Saved')
area_tuples = zip(components, areas) components = sorted(area_tuples, key=itemgetter(1), reverse=True) components = components[:10] components = [c[0].mesh for c in components] mesh = pm.merge_meshes(components) return Topex(mesh) def scatter(self, light_direction, viewer_direction): return self.facet_model.scatter(light_direction, viewer_direction) def total_scatter(self, viewer_direction): return self.facet_model.total_scatter(viewer_direction) if __name__ == "__main__": #topex_dir = Path('/home/drew/dev/photometry/data/models/topex-poseidon/obj/') topex_dir = Path('/home/drew/dev/photometry/photometry/') #topex_file_path = topex_dir / "Topex-Posidon-composite.obj" topex_file_path = topex_dir / "cube.obj" topex = Topex.from_path(topex_file_path) #topex = topex.reduced() #light_direction = SpherePoint.from_list([1,1,1]) def func(viewer_direction): return topex.total_scatter(viewer_direction) plot(func)
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ''' from pathlib import Path import os from os.path import basename, splitext import sys from models import WavefrontModel from visualization import plot_function_triangles as plot if __name__ == "__main__": path = sys.argv[1] objname = splitext(basename(path))[0] model = WavefrontModel.from_path(path) def func(viewer_direction): return model.total_scatter(viewer_direction) filename = objname + ".html" plot(func, filename)
import numpy as np import visualization as v def gaussian(x, mu, sigma): """ Implementation of Gaussian function """ norm = 1 / np.sqrt(2 * np.pi) * sigma return norm * np.exp(-0.5 * ((x - mu) / sigma)**2) x = np.linspace(-10, 10, 100) v.plot(x, gaussian(x, 0, 2))
def main(config_path: str): config = Config.get(input_conf=load_json_file(file_path=config_path)) paths_evaluation_results = evaluate(config=config) plot(config=config, score_paths=paths_evaluation_results)
def basic_f(y, v0): """ The equation for the trajectory of a ball can be solved to find the time it takes the ball to reach a certain height How long does it take for the ball to reach 0.2m with an initial velocity of 5m per se? """ sqrt_term = np.sqrt((v0**2 - 2 * g * y)) return (v0 - sqrt_term, v0 + sqrt_term) print( f"At t={basic_f(0.2, 5.0)[0]} s and {basic_f(0.2, 5.0)[1]} s, the height is 0.2 m" ) def f(x, theta, v0, y): """ A ball is either kicked or thrown with a certain velocity at a certain angle. Calculate the height when it is 5m from it's original position """ const = 1 / (v0 * 2) return x * np.tan(theta) - const * (g * x**2 / (np.cos(theta) * np.cos(theta))) + y print( f"The height of the ball at 0.1 metres from the starting position is {round(f(0.1, 60 * (np.pi/180), 15, 1), 2)} m" ) #x = np.linspace(-np.pi / 2 + 0.1, np.pi / 2 - 0.1, 20) x = np.linspace(0, 2, 10) visualization.plot(x, f(x, 60 * (np.pi / 180), 15, 1), False)