import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#importing dataset
train = pd.read_csv("train.csv")
test = pd.read_csv("test.csv")
train_X = train.iloc[:, :-1].values
train_Y = train.iloc[:,1].values
test_X = test.iloc[:, :-1].values
test_Y = test.iloc[:,1].values

#getting column names in dataset

#replace null values
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values = 0,strategy = "mean", axis = 0)
imputer = imputer.fit(train_Y)
train_Y = imputer.transform(train_Y)

#plotting train dataset
plt.scatter(train['x'],train['y'], color = "red")

#madelling the train dataset
from sklearn.linear_model import LinearRegression
reg = LinearRegression()

# predicting test dataset
y_pred = reg.predict(test_X)

I am not getting any errors but just that the nan value is not getting replaced. Thanks in advance!

  • $\begingroup$ Can you share the data points? $\endgroup$ – GadaaDhaariGeek Aug 21 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.