Creating our Machine Learning Classifiers – Python for Finance 16

Now that we have our features and our labels, we’re ready to create and train our machine learning classifiers for our algorithmic trading strategy.

The classifiers we use here are the Random Forest, Linear SVC, NuSVC, and Logistic Regression.

sample code:

9 comments

  1. RedstoneIs Awesome says:

    Nice!
    How Do I download specific files from websites, with urllib?
    Thanks, sorry if I am going on a tangent.

  2. Adam Fatyga says:

    Hi!
    Its me, again… 😉
    As always i have problem with build.
    “Runtime exception: TypeError: unbound method fit() must be called with
    RandomForestClassifier instance as first argument (got ndarray instance
    instead)”
    at line 85
    74: clf = RandomForestClassifier

    82: current_features = X[-1]
    83: X = X[:-1]
    84:
    85: clf.fit(X,y)

  3. Limin Mandrawa says:

    Dear Harrison,

    Pls check the Video you have uploaded in Python for Finance 16, It seems
    you have uploaded Python for Finance 15 for this tutorial. Thx

  4. Alex Kalder says:

    sentdex please please PLEASE make some videos about R (language). i m
    beginner-goodish to both languages and let me tell you you are gonna LOVE
    it

  5. Fredo says:

    +sentdex hello ive been following the series with ease but for some weird
    reason for this part i get the error message:
    ” ValueError: setting an array element with a sequence.” for the line:
    clf.fit(X,y)
    I dont really understand why I’m getting this message, could you help?
    Thanks in advance & Thank you for giving us the opportunity to learn a
    combination of things :)

  6. Jester Bobbity says:

    Keep getting a runtime error. No idea why 🙁
    ValueError: setting an array element with a sequence.
    There was a runtime error on line 85.

    I deleted line 85 just to see what happen and got the same error on line
    90.

    79 clf = RandomForestClassifier()

    81 last_prices = price_list[-context.feature_window:]
    82 current_features = (np.around(np.diff(last_prices) / last_prices[:-1]) *
    100.0, 1)

    84 X.append(current_features)
    85 X = preprocessing.scale(X)

    87 current_features = X[-1]
    88 X = X[:-1]

    90 clf.fit(X,y)

    92 p = clf.predit(current_features)[0]
    93 print((‘Prediction’,p))

Comments are closed.