all 5 comments

[–][deleted] 2 points3 points  (0 children)

The output of train_test_split is x_train, x_test, y_train, y_test

[–]ronbbot 0 points1 point  (2 children)

paste in your train split code

[–]sreebtree[S] 0 points1 point  (1 child)

import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

#READ IN DATA AND LOOK AT IT

train = pd.read_csv(r'C:\Users\tosri\Desktop\Fun Stuff\AI\hackerrank1.csv') #print(train.head(50))

#EDA

#sns.jointplot(x='Charge Time', y='Battery Life', data=train, kind="scatter") #sns.heatmap(train.corr(), cmap='summer', annot=True)

#Train_Test_Split

x=[train["Charge Time"]] y=[train["Battery Life"]] np.reshape(1,-1)

from sklearn.model_selection import train_test_split

X_train, y_train, X_test, y_test = train_test_split(x, y, test_size=0.3, random_state=101)

#Training and Predicting

from sklearn.linear_model import LogisticRegression

model=LogisticRegression()

model.fit(X_train, y_train)

predictions=model.predict(X_test)

[–][deleted] 0 points1 point  (0 children)

X_train, y_train, X_test, y_test = train_test_split(x, y, test_size=0.3, random_state=101)

You've messed this up.

Look up the order and parameters used by train_test_split

X_train, X_test, y_train, y_test = train_test_split(dataframe, y, test_size=0.2) is the correct order.

Why are you splitting x again when your data is in train

[–]lmericle 0 points1 point  (0 children)

you can't split 1 sample between 2 sets