This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras | |
from keras import layers | |
from keras.layers.core import Dense, Activation | |
from keras.models import Sequential | |
from keras.callbacks import EarlyStopping | |
from keras.callbacks import ModelCheckpoint | |
import pandas as pd | |
from sklearn.model_selection import train_test_split | |
import numpy as np | |
from sklearn.metrics import accuracy_score |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.ensemble import RandomForestClassifier | |
X = df[['Open', 'Max 7', 'Min 7', 'Change', 'Mean Change 7', 'Drop 7', 'Up 7']].values | |
y = df['Actual'].values | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=42) | |
clf = RandomForestClassifier(max_depth=2, random_state=0) | |
clf.fit(X_train, y_train) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
import datetime | |
import pandas as pd | |
df = pd.DataFrame(columns=['Date', 'Value']) | |
def data_retriever(sleep=30): | |
global df | |
while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_drop(numbers): | |
return len([x for x in numbers if x < 0]) | |
def count_up(numbers): | |
return len([x for x in numbers if x > 0]) | |
def actual_calc(row): | |
if row['Value'] > row['Open 2']: | |
return 0 | |
return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def player_3(start_date=None, sleep=False, sleep_time=1, plot=False, output=True, miss_output=False, miss_plot=False, kind='line'): | |
user_key, day_info, amount, invested, profit, loss, game_active = stock_game(start_date=start_date) | |
miss_colors = ['g'] | |
while game_active == False: | |
predict = clf.predict(day_info[['Value USD', 'Max 7', 'Min 7', 'Change', 'Mean Change 7', 'Drop 7', 'Up 7']].values.reshape(1, -1))[0] | |
state = abs(day_info['Predict']) | |
if state == 0: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
def get_pixels(image): | |
im = Image.open(image) | |
pixels = [] | |
pix = im.load() | |
width,height = im.size | |
img_width, img_height = 0,0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import datetime | |
import time | |
import tweepy | |
#get this from apps.twitter.com | |
consumer_key = 'xxxx' | |
consumer_secret = 'xxxx' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*CSRF Code */ | |
function csrfSafeMethod(method) { | |
// these HTTP methods do not require CSRF protection | |
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); | |
} | |
function sameOrigin(url) { | |
// test that a given url is a same-origin URL | |
// url could be relative or scheme relative or absolute | |
var host = document.location.host; // host + port | |
var protocol = document.location.protocol; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render, render_to_response | |
import random | |
import string | |
from PIL import Image, ImageFont, ImageDraw | |
from captcha.models import Captcha | |
import json | |
from django.http import HttpResponse, HttpResponseRedirect | |
from django.contrib.auth.models import User | |
from django.contrib.auth import login as django_login | |
def random_filename(path=None, length=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def login_page(request, template_name="login.html"): | |
context = {'title': 'Login Page'} | |
file_name, answer, _, result_id = generate_captcha() | |
context['captcha_url'] = '/' + file_name | |
context['ref_id'] = result_id | |
return render_to_response(template_name, context) | |
def login_ajax(request): | |
response = {'status': None} | |
if request.method == 'POST': |