Search code examples
pythonmachine-learningdatasettraining-data

Train and test split data with features


Load the Iris dataset from sklearn. Split the dataset into training and testing parts. Pick 2 of the 4 features. I write this code:

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split

iris = load_iris()
X, y = iris.data, iris.target
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.33,random_state=42)

But I didn't understand "Pick 2 of the 4 features". Is that means test_size and random_state? Or is it something different?


Solution

  • Iris dataset has petal length,petal width,sepal length,sepal width as 4 features. Pick 2 of the 4 feature means take two of those 4 features in your training model. I don't know why you want to do that as using all four feature makes model more accurate