def plt_timeseries(): T = Plot( idx, data, par_fpath) # instantiate a plot object, idx = plot id, data = df T.timeseries( param, outpath ) # call timeseries method, param = parameters from main yaml, outpath = where to save output plot
def classifier(X_train, X_test, y_train, y_test): train_a, train_c, test_a, test_c, y_pred = training_classifier( X_train, X_test, y_train, y_test) f1_score = Plot.report(y_pred, y_test, FLAGS.report) if FLAGS.save_scores == True: Plot.saving_scores(FLAGS, test_a[-1], f1_score) return f1_score
def post(self): Tup = self.request.get('Tup') Tleft = self.request.get('Tleft') Tdown = self.request.get('Tdown') Tright = self.request.get('Tright') plotType = self.request.get('plotType') Tuser = {'Tup':Tup, 'Tleft':Tleft, 'Tright':Tright, 'Tdown':Tdown} T = validTemp(**Tuser) #To avoid zero array passed to contourplot if type(T) == dict: flag = 0 for value in T.values(): if value != 0: flag = 1 break if flag == 0: T = ["error" + key for key in Tuser.keys()] if type(T) == list: for t in T: Tuser[t] = "Input invalid or beyond limits" plots = recentPlots() points=filter(None,(plot.geoPt for plot in plots)) geolocationUrl=None if points: geolocationUrl=gmaps_img(points) self.renderPage("parameters.html", plots = plots,geolocationUrl = geolocationUrl, **Tuser) else: plot = plotcontour(T, plotType) user = users.get_current_user() if user: p = Plot(user = user, image = plot, **T) coords=get_coords(self.request.remote_addr) if coords: p.geoPt = coords p.put() sleep(0.1) recentPlots(True) self.renderPage("result.html", plot = plot, **T)
def main(): plotter = Plot() # Read in data stocks = pd.read_csv("SBUX_Stocks.csv") stocks = stocks.iloc[::-1] # Formatting into correct objects for col in [' Close/Last', ' Open', ' High', ' Low']: stocks[col] = stocks[col].apply(lambda x: float(x[2:])) stocks['Date'] = stocks['Date'].apply(lambda x: datetime.strftime( datetime.strptime(x, '%m/%d/%Y'), '%b %d %Y')) stocks = stocks.rename( columns={ ' Close/Last': 'Close/Last', ' Open': 'Open', ' High': 'High', ' Low': 'Low' }) plotter.basicPlot(stocks, 'Date', 'High')
clf = neighbors.KNeighborsClassifier(15) clf.fit(X_train_res, y_train_res) Z = clf.predict(X_train) acc = clf.score(X_train, y_train) print('Accuracy on split training data: ' + str(acc)) # Put the result into a confusion matrix cnf_matrix_tra = confusion_matrix(y_train, Z) print("Recall metric - split train data: {}%".format(100*cnf_matrix_tra[1,1]/(cnf_matrix_tra[1,0]+cnf_matrix_tra[1,1]))) plt.figure(1) plt.title('Oversampling using SMOTE') plt.subplot(221) plot = Plot() plot.plot_confusion_matrix(cnf_matrix_tra , classes=[0,1], title='Confusion matrix - train') #now try knn on the test data Z1 = clf.predict(X_test) acc1 = clf.score(X_test, y_test) print('Accuracy on split test data: ' + str(acc1)) # Put the result into a confusion matrix cnf_matrix_test = confusion_matrix(y_test, Z1) print("Recall metric - split test data: {}%".format(100*cnf_matrix_test[1,1]/(cnf_matrix_test[1,0]+cnf_matrix_test[1,1]))) #print("Precision metric in the testing dataset: {}%".format(100*cnf_matrix[0,0]/(cnf_matrix[0,0]+cnf_matrix[1,0]))) plt.subplot(222) plot = Plot() plot.plot_confusion_matrix(cnf_matrix_test , classes=[0,1], title='Confusion matrix - test')
from windows import Main from punkts import Punkts from updater import Updater from version import Version from datetime import timedelta from create_output import Output if __name__ == "__main__": config.IS_WINDOWS = True if platform.system() == 'Windows' else False root = tk.Tk() db = DB.DB() Version = Version.Versions() Updater = Updater.Updater(Version) Punkts = Punkts.Punkts(db) Plot = Plot.Plot(Punkts) Outputter = Output.Output(Punkts) app = Main.Main(root, Punkts, Version, Updater, Plot, Outputter) app.pack() root.title("Техпроцесс ") root.geometry("580x350+300+220") #root.resizable(False,False) root.minsize(580, 350) root.mainloop()
def plt_histogram(): H = Plot(idx, data, par_fpath) H.histogram(param, outpath)
def plt_scatterplot(): S = Plot(idx, data, par_fpath) S.scatterplot(param, outpath)
def plt_boxplot(): B = Plot( idx, df, par_fpath) # for boxplot whole df passed, not the one with summary B.boxplot(param, outpath)
import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output # for callbacks import preprocessing from plots import Plot df = preprocessing.process() plot = Plot(df) # Launch the application: app = dash.Dash(__name__) app.layout = html.Div( children=[ # search and table html.Div(children=[ dcc.Input(id="search_input", placeholder='Enter a value...', type='text', value=''), html.Div(dcc.Graph(id="table")), ]), # row of 2 barcharts html.Div(children=[ html.Div(children=[ html.Div(dcc.Graph(id="overall_bc")), dcc.Slider(id="overall_slider", marks={i: str(i)
email = '*****@*****.**' # Valid email period = '' # Check README.md for valid inputs interval = '' # Check README.md for valid inputs # <---------------Stuff You Need to Define-----------------> for o in portfolio: try: os.mkdir('image') except: pass try: os.mkdir(f'image/{o}') except: pass for i in portfolio: try: start = perf_counter() Plot(i, period=period, interval=interval) print(DeciderBuy(i, period=period, interval=interval, receiver=email)) print(DeciderSell(i, period=period, interval=interval, receiver=email)) print(DeciderHold(i, period=period, interval=interval)) end = perf_counter() print(f"\nThe analysis took: {end - start} seconds\n") except Exception as e: print(f'The analysis did not succeed due to: {e}') print('Check README.md for the usage of the program!')
from layer import Layer from sklearn import datasets from plots import Plot from builder import LayerBuilder iris = datasets.load_boston() X = iris.data Y = iris.target l = Layer.new_from_file("testing") p = Plot([l]) p.training_validation() """l = Layer.new(X, Y, num_nodes=50, num_iter=5000, epsilon=1.0, test_size=0.25, boostCV_size=0.15, nodeCV_size=0.18, minibatch=True, validation='Uniform') l.save("testing") Layer.save_multiple(l, "boston-set")""" for a in range(10): print l.predict([X[a]]), Y[a] #Layer.save_multiple(l, "boston-set") exit() l2 = Layer.new_multiple(3, X, Y, num_nodes=50, num_iter=1000, epsilon=1.0, test_size=0.25, boostCV_size=0.15, nodeCV_size=0.18, minibatch=True, validation='Uniform') p = Plot(l, l2) p.training_validation()