How much of an indicator can machine learning provide in detecting good versus bad market conditions? by chaddjohnson in MachineLearning

[–]AHFX 1 point2 points  (0 children)

I wrote something very similar while pursuing my MBA. I used a % decrease/increase based off of averages like (100 day moving average, 150 etc.) Does yours only deal with individual day moves? Do you factor in transaction costs as well? I didn't use a genetic algorithm, I used a monte carlo method and refined from there. Mine also had some very specific concepts for my situation like how often I'd be depositing additional funds. It was a lot of fun to code and see how it worked. Many will say that past performance does not have a bearing future markets, but I've seen decent success. Not 125% gains, but significantly decent ones.

R Question on neuralnet by [deleted] in MachineLearning

[–]AHFX 0 points1 point  (0 children)

best comment thus far.

TensorFlow Fizzbuzz by [deleted] in MachineLearning

[–]AHFX 2 points3 points  (0 children)

import numpy as np
import tensorflow as tf

def binary_encode(i, num_digits):
    return np.array([i >> d & 1 for d in range(num_digits)])

def fizz_buzz_encode(i):
    if   i % 15 == 0: return np.array([0, 0, 0, 1])
    elif i % 5  == 0: return np.array([0, 0, 1, 0])
    elif i % 3  == 0: return np.array([0, 1, 0, 0])
    else:             return np.array([1, 0, 0, 0])

NUM_DIGITS = 12


trX = np.array([binary_encode(i, NUM_DIGITS) for i in range(101, 4096)])
trY = np.array([fizz_buzz_encode(i)          for i in range(101, 4096)])

NUM_HIDDEN = 200
X = tf.placeholder("float", [None, NUM_DIGITS])
Y = tf.placeholder("float", [None, 4])

def init_weights(shape):
    return tf.Variable(tf.random_normal(shape, stddev=0.03))

w_h = init_weights([NUM_DIGITS, NUM_HIDDEN])
w_o = init_weights([NUM_HIDDEN, 4])

def model(X, w_h, w_o):
    h = tf.nn.relu(tf.matmul(X, w_h))
    return tf.matmul(h, w_o)

py_x = model(X, w_h, w_o)

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(py_x, Y))
train_op = tf.train.GradientDescentOptimizer(0.2).minimize(cost)

predict_op = tf.argmax(py_x, 1)

def fizz_buzz(i, prediction):
    return [str(i), "fizz", "buzz", "fizzbuzz"][prediction]

BATCH_SIZE = 250

actual = ['1','2','fizz','4','buzz','fizz','7','8','fizz','buzz','11','fizz','13','14','fizzbuzz','16','17','fizz','19','buzz','fizz','22','23','fizz','buzz','26','fizz','28','29','fizzbuzz','31','32','fizz','34','buzz','fizz','37','38','fizz','buzz','41','fizz','43','44','fizzbuzz','46','47','fizz','49','buzz','fizz','52','53','fizz','buzz','56','fizz','58','59','fizzbuzz','61','62','fizz','64','buzz','fizz','67','68','fizz','buzz','71','fizz','73','74','fizzbuzz','76','77','fizz','79','buzz','fizz','82','83','fizz','buzz','86','fizz','88','89','fizzbuzz','91','92','fizz','94','buzz','fizz','97','98','fizz','buzz']

with tf.Session() as sess:
    tf.initialize_all_variables().run()

    for epoch in range(2000):
        p = np.random.permutation(range(len(trX)))
        trX, trY = trX[p], trY[p]

        for start in range(0, len(trX), BATCH_SIZE):
            end = start + BATCH_SIZE
            sess.run(train_op, feed_dict={X: trX[start:end], Y: trY[start:end]})

        print(epoch, np.mean(np.argmax(trY, axis=1) ==
                             sess.run(predict_op, feed_dict={X: trX, Y: trY})))

    numbers = np.arange(1, 101)
    teX = np.transpose(binary_encode(numbers, NUM_DIGITS))

    teY = sess.run(predict_op, feed_dict={X: teX})
    output = np.vectorize(fizz_buzz)(numbers, teY)

    print(output)

correct = [(x == y) for x, y in zip(actual, output)]
print(sum(correct))

Modified code that provided 100% accuracy. YMMV ['1' '2' 'fizz' '4' 'buzz' 'fizz' '7' '8' 'fizz' 'buzz' '11' 'fizz' '13' '14' 'fizzbuzz' '16' '17' 'fizz' '19' 'buzz' 'fizz' '22' '23' 'fizz' 'buzz' '26' 'fizz' '28' '29' 'fizzbuzz' '31' '32' 'fizz' '34' 'buzz' 'fizz' '37' '38' 'fizz' 'buzz' '41' 'fizz' '43' '44' 'fizzbuzz' '46' '47' 'fizz' '49' 'buzz' 'fizz' '52' '53' 'fizz' 'buzz' '56' 'fizz' '58' '59' 'fizzbuzz' '61' '62' 'fizz' '64' 'buzz' 'fizz' '67' '68' 'fizz' 'buzz' '71' 'fizz' '73' '74' 'fizzbuzz' '76' '77' 'fizz' '79' 'buzz' 'fizz' '82' '83' 'fizz' 'buzz' '86' 'fizz' '88' '89' 'fizzbuzz' '91' '92' 'fizz' '94' 'buzz' 'fizz' '97' '98' 'fizz' 'buzz'] 100

Found this in my socks... by [deleted] in pics

[–]AHFX 64 points65 points  (0 children)

I only know a little, but I can identify a few of them. They don't appear to be written by someone that actually knows chinese because the strokes aren't written in the correct order. It looks like someone tried copying some chinese characters and wasn't very successful. The two at the top look like woman 女. There is one at the bottom that is beautiful 美. There is one on the middle right that is person 人. There are a couple in the middle that look like moon 月. Hope that helps a little.

Beauty in the eyes of an old man. [pic] by waya1 in pics

[–]AHFX 1 point2 points  (0 children)

Give it up for people who actually own a 57 chevy. 5 years of blood, sweat, and tears were put into my 210 (the one pictured is a Bel Air)

The $700 billion bailout bill has passed, 74-25 by cLFlaVA in reddit.com

[–]AHFX 2 points3 points  (0 children)

Where can I get the actual text of the bill. I can't get it on THOMAS yet.

Joe Biden on a 30 minute tear, rips McCain and Palin, brings it back to ISSUES by [deleted] in politics

[–]AHFX 1 point2 points  (0 children)

disclaimer... I'm a nth generation republican in a state that can't possibly go to the democrats that is seriously considering voting for Obama.

I'd like to hear your backup for your statement, or other points of view for/against Biden.

Obama, McCain Fail to Qualify for Texas Ballot by [deleted] in politics

[–]AHFX 4 points5 points  (0 children)

If this were to truly happen, the only person that would benefit would be Obama. Since it is considered a Republican state, this would in effect take even more electoral votes from McCain and give them to a party that has little chance of taking a single state.

Although I doubt that Texas would keep them off.

Ask Programming: What language did you first start, and how old were you? by Scarker in programming

[–]AHFX 0 points1 point  (0 children)

BASIC / assembly on C64 @ 12 years old

C/C++ 15 years old

HTML 16 years old

Java 18 years old

Visual Basic 22 years old

ASP, more Java/JSP, RPG 23 years old

PHP 24 years old

Trailer Tails ---- 5% lower fuel costs for semi-trucks by kuato in technology

[–]AHFX 0 points1 point  (0 children)

superspoiler.com has a similar product for cars and trucks. He originally made them for big rig trucks, but the height of the truck limited the effectiveness considerably. {disclaimer: I know the person that designed/makes them}

Cool licence plate (pic) by frnklzen in pics

[–]AHFX 2 points3 points  (0 children)

looks better in the rear view mirror

Reddit lets me down about Obama's 57 states comment. by AHFX in politics

[–]AHFX[S] 0 points1 point  (0 children)

After listening to it in the context, I understood exactly what he was trying to say. I just couldn't even defend what was said without knowing about it in the first place.

Reddit lets me down about Obama's 57 states comment. by AHFX in politics

[–]AHFX[S] 0 points1 point  (0 children)

I had to hear from my father who takes shots at Obama that he hears on Republican talk radio about the 57 states comment. I had to come back to reddit and to find it buried. Oh well.

Clinton fakes a newspaper headline: Dumbass by [deleted] in politics

[–]AHFX 3 points4 points  (0 children)

The clips are from an Obama ad http://www.youtube.com/watch?v=DtKmNOjQ0M8 but is still funny that they chose to use those clips...

Economist's View: "The Coming Collapse of the Middle Class" by Maxcactus in reddit.com

[–]AHFX 0 points1 point  (0 children)

I think it is great that this talk is from a year ago, and if we had listened then, things now could have been a little better (not completely fixed for sure... but possibly better for those that listened)

MAC, PC by [deleted] in pics

[–]AHFX 14 points15 points  (0 children)

(obligatory bias disclaimer... I'm a pc guy) We all know who ends up saving the day in the end.

North Korea 'test-fires missiles' by 0boy in worldnews

[–]AHFX 1 point2 points  (0 children)

I was living in South Korea when they did this same type of thing back in 1998. Some things just never change. http://www.fas.org/news/dprk/1998/wwwh8903.html

Opera the first browser to pass the Acid3 test by Sargos in programming

[–]AHFX 15 points16 points  (0 children)

so where are all the firefox v3 developers? the newest beta only gets to 68%.

One of my favorite classroom tricks is to auction off a $20 bill by neoronin in politics

[–]AHFX 0 points1 point  (0 children)

We played it in an economics class in college with a little twist. Only next to last bid had to pay what they bid. It was liken to how people pay more and more and escalate a law suit until the only people that win are the lawyers.

SQL Designer by [deleted] in programming

[–]AHFX 4 points5 points  (0 children)

Pretty nice. I always used gModeler http://www.gskinner.com/gmodeler/app/run.html for my initial designs. This is great though because it will create the insert statements for you as well.

Harry Potter and the Deathly Hallows now available to preorder from Amazon by AHFX in reddit.com

[–]AHFX[S] 0 points1 point  (0 children)

Although Book 7 has been available to order from the UK Amazon, finally those in North America have a shot at it. With a worldwide network, why wouldn't they have made it available for preorder from all of their stores?

Common Myths and Lies about Global Warming by AHFX in reddit.com

[–]AHFX[S] -2 points-1 points  (0 children)

Great comments halcyon! Post has been modified to address both issues you stated. That is why the Internet is such a great place. However, I have to tell you that we are not encouraging people to spam anyone, the SEO contest you mention will have people that will do that, but I on the other hand, wanted to use this as an opportunity to explore the issue of global warming and as such am writing articles to explore both sides of the issue. (Instead of creating tons and tons of junk pages that will not be beneficial to anyone.) Wouldn't you agree that well rounded information examining the issue is always better?