0

Machine Learning - Training and Testing - Training and Testing in Sklearn

Machine Learning Training and Testing Training and Testing in Sklearn We have 2d numpy array X of 100 datapoints and 4 features and 1d array y of 100 target values. What is the output of this code? X_train, X_test, y_train, y_test = train_test_split(X, y) print(X_train.shape, y_train.shape) what i've tried : 1 already search the https://www.sololearn.com/Discuss and google but no enlight for this question 2 tested in jupyter notebook pip install -U sklearn import numpy as np from sklearn.model_selection import train_test_split X = np.array([[100], [4] ] ) y = np.array(100) X_train, X_test, y_train, y_test = train_test_split(X, y) traceback error TypeError: Singleton array array(100) cannot be considered a valid collection. my question : how to get the result ? ( ___1___ , ___2___ ) ( ___3___ ,) thanks

7th Apr 2021, 1:04 PM
Stifan Kristi
Stifan Kristi - avatar
7 Answers
+ 3
La réponse est : (75,4) (75,) Je me suis basé sur l'exemple du cours pour trouver la réponse, par exemple dans le cours lorsqu'on avait 887 éléments on a eu comme résultat au shape 667 et 222 par défaut soit 222/887 = 0.25... donc 25% ce qui équivaut à 100-25 = 75 (qu'on peut trouver en faisant 667/887 aussi)
28th Apr 2021, 12:25 PM
Abass SANA
+ 1
pip install -U sklearn import numpy as np from sklearn.model_selection import train_test_split X = np.array([[100], [4] ] ) y = np.array([100] ) X_train, X_test, y_train, y_test = train_test_split(X, y) traceback error ValueError: Found input variables with inconsistent numbers of samples: [2, 1]
7th Apr 2021, 2:01 PM
Stifan Kristi
Stifan Kristi - avatar
+ 1
how to translate : We have 2d numpy array X of 100 datapoints and 4 features and 1d array y of 100 target values. into python numpy, so that can test it on jupyter notebook ? thanks
7th Apr 2021, 4:02 PM
Stifan Kristi
Stifan Kristi - avatar
+ 1
Result : 75,4,75
30th May 2021, 8:15 AM
Amin Nouri
Amin Nouri - avatar
0
100 is an integer Try this: y = np.array([100]) đŸ€”
7th Apr 2021, 1:24 PM
Namit Jain
Namit Jain - avatar
0
Ohh ya, the length of x and y should be same ig (dimensions also)
7th Apr 2021, 2:58 PM
Namit Jain
Namit Jain - avatar
0
Result: (75, 4) (75,)
17th Jun 2021, 10:47 AM
Anchal Dayal
Anchal Dayal - avatar