Esempio n. 1
0
 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 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')
Esempio n. 4
0
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()
Esempio n. 5
0
 def plt_histogram():
     H = Plot(idx, data, par_fpath)
     H.histogram(param, outpath)
Esempio n. 6
0
 def plt_scatterplot():
     S = Plot(idx, data, par_fpath)
     S.scatterplot(param, outpath)
Esempio n. 7
0
 def plt_boxplot():
     B = Plot(
         idx, df,
         par_fpath)  # for boxplot whole df passed, not the one with summary
     B.boxplot(param, outpath)
Esempio n. 8
0
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)
Esempio n. 9
0
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!')