# Constructing List of Rules from imported data

I would like to create a List of Rules data structure to be used in the Classify function.

I have sample input data stored in one .csv file and target output values in another. There are four columns in the data file and one column in the target file. The information in one row of the four columns in the data file map to one row in the one column in the target file.

I can import the data and get it into a Data structure with:

X = Dataset[Import["x_data.csv"]];
Y = Dataset[Import["y_data.csv"]];


How would I construct a List of Rules mapping the four entries in each row in X to the entry in the one column in Y?

The required structure should look something like:

{x1,x2,x3,x4}->y


Note: This is a standard way to set up Machine Learning data in Scikit-learn in Python (the tool I have been using), if there is another better way in Mathematica, I would be interested in knowing.

This is what the input data looks like:

This is the target data (note that this is category data and further on there is non-zero data):

• Can you give an example of what you expect? Does each row in X correspond to the same row in Y? Do you expect to see a rule of the form {x1,x2,x3,x4}->y, or something else? Mar 5 '17 at 3:48
• Hi, I expanded the question, hope its more clear now. {x1,x2,x3,x4}->y is basically what I want, (I think).
– Mike
Mar 5 '17 at 4:05

xdata = Import[FileNameJoin[{$HomeDirectory, "Desktop", "x_data.csv"}]]  {{5.1, 3.5, 1.4, 0.2}, {4.9, 3., 1.4, 0.3}} ydata = Import[FileNameJoin[{$HomeDirectory, "Desktop", "y_data.csv"}]] // Flatten

{1, 2}
Thread[Rule[xdata, ydata]]

{{5.1, 3.5, 1.4, 0.2} -> 1, {4.9, 3., 1.4, 0.3} -> 2}