I am trying to do a classification using Python. I have some input columns (let k variables) and one output column.
Let inputfeatures
= array([[ 0, 0, 0, ..., 0, 0, 0],
[ 1, 0, 0, ..., 0, 0, 0],
[ 1, 0, 0, ..., 0, 0, 0],
...,
[ 0, 0, 0, ..., 0, 0, 0],
[ 1, 0, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 1, 0]], dtype=int64)
target_array
= array([0, 0, 0, ..., 0, 0, 1], dtype=int64)
I am fitting the model as,
trainedModel = model.fit(inputfeatures,target_array)
The classifier I am using needs Data Phenotypes for all data instances are represented by a 1 dimensional numpy.ndarray of length n.
I am getting no errors while fitting, since the target_array is 1 dimensional numpy.ndarray of length n.
Suppose, I need to have two output variables, how can I create a 1 dimensional numpy.ndarray of length n to fit the model?
I just tried as given below:
target_array=data[data.columns[data.columns.isin(['var1', 'var2'])]].values
target_array
array([[1, 1],
[0, 1],
[1, 1],
...,
[1, 0],
[0, 0],
[0, 0]], dtype=int64)
But it is 2 dimensional. How to make it 1 dimensional numpy.ndarray of length n?