title: Time Series Classification
body: <p>you can access the data set at this link <a href="https://drive.google.com/file/d/0B9Hd-26lI95ZeVU5cDY0ZU5MTWs/view?usp=sharing" rel="noreferrer">https://drive.google.com/file/d/0B9Hd-26lI95ZeVU5cDY0ZU5MTWs/view?usp=sharing</a></p>
  
  <p>My Task is to predict the price movement of a sector fund. How much it goes up or down doesn't really matter, I only want to know whether it's going up or down. So I define it as a classification problem.</p>
  
  <p>Since this data set is a time-series data, I met many problems. I have read articles about these problems like I can't use k-fold cross validation since this is time series data. You can't ignore the order of the data.</p>
  
  <p>my code is as follows:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import matplotlib.pyplot as plt
  import datetime
  from sklearn.linear_model import LinearRegression
  from math import sqrt
  from sklearn.svm import LinearSVC
  from sklearn.svm import SVCenter code here
  
  lag1 = pd.read_csv(#local file path, parse_dates=['Date']) 
  
  #Trend : if price going up: ture, otherwise false
  lag1['Trend'] = lag1.XLF &gt; lag1.XLF.shift()
  train_size = round(len(lag1)*0.50)
  train = lag1[0:train_size]
  test = lag1[train_size:]
  
  variable_to_use=    ['rGDP','interest_rate','private_auto_insurance','M2_money_supply','VXX']
  y_train = train['Trend']
  X_train = train[variable_to_use]
  y_test = test['Trend']
  X_test = test[variable_to_use]
  
  #SVM  Lag1
  
  this_C = 1.0
  clf = SVC(kernel = 'linear', C=this_C).fit(X_train, y_train)
  print('XLF Lag1 dataset')
  print('Accuracy of Linear SVC classifier on training set: {:.2f}'
   .format(clf.score(X_train, y_train)))
  print('Accuracy of Linear SVC classifier on test set: {:.2f}'
   .format(clf.score(X_test, y_test)))
  
  #Check prediction results
  clf.predict(X_test)
  </code></pre>
  
  <p>First of all, is my method right here : first generating a column of true and false? I am afraid the machine can't understand this column if I simply feed this column to it. Should I first perform a regression then compare the numeric result to generate a list of going up or down? </p>
  
  <p>The accuracy on training set is very low at : 0.58  I am getting an array with all trues with clf.predict(X_test) which I don't know why I would get all trues.</p>
  
  <p>And I don't know whether the resulting accuracy is calculated in which way: for example, I think my current accuracy only counts the number of true and false but ignoring the order of them? Since this is time-series data, ignoring the order is not right and gives me no information about predicting price movement. Let's say I have 40 examples in test set, and I got 20 Tures I would get 50% accuracy. But I guess the trues are no in the right position as it appears in the ground truth set. (Tell me if I am wrong)</p>
  
  <p>I am also considering using Gradient Boosted Tree to do the classification, would it be better?</p>