I have a Pandas dataframe with 10 columns, 9 of which are features to be used to predict the 10th column.
How is it ossible to convert this Pandas dataframe into X and y vectors to use in a linear regression problem?
If you have your dataframe loaded as the variable df, you can simply use this
X = df[['A','B','C']]
y = df['Z']
where A, B and C are your independent variables and Z is your dependent variable.
Are you looking for this?
#format the data as a numpy array to feed into the algorithm
X = np.asarray([np.asarray(df['Ind1']),np.asarray(df['Ind2']),np.asarray(df['Ind3'])])
y = np.asarray([np.asarray(df['Dep'])])
Or, simplified.
# array(['a', 'b', 'c'], dtype=object)
arr = df.index.to_numpy()
# array([1, 2, 3])
arr = df['A'].to_numpy()