0

I'm not exactly sure how to approach this question. The dataset has 8 attributes and one y-value. How would I train a linear regression model on 85% of the dataset?

image

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
eess
  • 21
  • 2

2 Answers2

1

You can also use train_test_split from sklearn as in sklearn example to split the data into training and testing sets e.g. if X is data with features and y is label then:

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.15)

And for linear regression you can try using: linregress from scipy as in similar question:

niraj
  • 17,498
  • 4
  • 33
  • 48
0

Use ndf = df.sample(frac=0.85) to get a DataFrame with 85% of your total rows and then use this new DataFrame ndf to train your linear regression model.

joaoavf
  • 1,343
  • 1
  • 12
  • 25