SimpleLinear_Regression
SimpleLinear_Regression
data = pd.read_csv('/Users/srunjith/Desktop/cardata.csv')
print("Shape of the Data:")
print(data.shape)
print("\nData Type:")
print(type(data))
print("\nFirst 10 Rows of the Data:")
print(data.head(10))
#print(data.describe())
plt.title("Car Data")
sns.displot(data['Selling_Price'])
plt.show()
plt.scatter(data['Selling_Price'], data['Present_Price'])
plt.title("Selling Price vs Present Price")
plt.xlabel("Selling Price")
plt.ylabel("Present Price")
plt.box(False)
plt.show()
# regression model
regressor = LinearRegression()
regressor.fit(X_train, Y_train)
y_pred_test = regressor.predict(X_test)
y_pred_train = regressor.predict(X_train)
print("\nPredicted Values:")
print(y_pred_test)
print(f'\nCoefficients: {regressor.coef_}')
print(f'Intercept: {regressor.intercept_}')