I am trying out some machine learning algorithms to be able to predict the people who survived who were aboard the titanic. I am following this example https://github.com/mlakhavani/titanic/blob/master/TitanixFinal.ipynb
However on from patsy import dmatrices
y, x = dmatrices('survived ~ sex + age + sibsp + parch + pclass + fare + C + Q + S + Col + Dr + Master + Miss + Mr + Mrs + Rev',
titanic_train, return_type="dataframe")
y_test, x_test = dmatrices('survived ~ sex + age + sibsp + parch + pclass + fare + + C + Q + S + Col + Dr + Master + Miss + Mr + Mrs + Rev',
titanic_test, return_type="dataframe")
i get this error
PatsyError Traceback (most recent call last)
<ipython-input-153-63b2f538454b> in <module>()
1 y_test, x_test = dmatrices('Survived ~ Sex + Age + SibSp + Parch + Pclass + Fare + + C + Q + S ++ Dr + Master + Miss + Mr + Mrs + Rev',
----> 2 titanic_test, return_type="dataframe")
C:\Anaconda\lib\site-packages\patsy\highlevel.pyc in dmatrices(formula_like, data, eval_env, NA_action, return_type)
295 eval_env = EvalEnvironment.capture(eval_env, reference=1)
296 (lhs, rhs) = _do_highlevel_design(formula_like, data, eval_env,
--> 297 NA_action, return_type)
298 if lhs.shape[1] == 0:
299 raise PatsyError("model is missing required outcome variables")
C:\Anaconda\lib\site-packages\patsy\highlevel.pyc in _do_highlevel_design(formula_like, data, eval_env, NA_action, return_type)
154 return build_design_matrices(builders, data,
155 NA_action=NA_action,
--> 156 return_type=return_type)
157 else:
158 # No builders, but maybe we can still get matrices
C:\Anaconda\lib\site-packages\patsy\build.pyc in build_design_matrices(builders, data, NA_action, return_type, dtype)
945 for evaluator in builder._evaluators:
946 if evaluator not in evaluator_to_values:
--> 947 value, is_NA = evaluator.eval(data, NA_action)
948 evaluator_to_isNAs[evaluator] = is_NA
949 # value may now be a Series, DataFrame, or ndarray
C:\Anaconda\lib\site-packages\patsy\build.pyc in eval(self, data, NA_action)
161 result = self.factor.eval(self._state, data)
162 result = categorical_to_int(result, self._levels, NA_action,
--> 163 origin=self.factor)
164 assert result.ndim == 1
165 return result, np.asarray(result == -1)
C:\Anaconda\lib\site-packages\patsy\categorical.pyc in categorical_to_int(data, levels, NA_action, origin)
270 if hasattr(data, "shape") and len(data.shape) > 1:
271 raise PatsyError("categorical data must be 1-dimensional",
--> 272 origin)
273 if (not iterable(data)
274 or isinstance(data, (six.text_type, six.binary_type))):
PatsyError: categorical data must be 1-dimensional
Survived ~ Sex + Age + SibSp + Parch + Pclass + Fare + + C + Q + S ++ Dr + Master + Miss + Mr + Mrs + Rev
How can i solve this issue?