You are on page 1of 1

2)

import pandas as pd

import numpy as np

from sklearn.model_selection import train_test_split

from sklearn.linear_model import LinearRegression

# Load the dataset

fish_data = pd.read_csv('fish_data.csv')

# Identify the independent and target variables

X = fish_data[['Length3', 'Height', 'Width']]

y = fish_data['Weight']

# Split the dataset into training and testing sets

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

# Create a linear regression model

model = LinearRegression()

# Fit the model to the training data

model.fit(X_train, y_train)

# Print the model summary

print(model.summary())

# Print the training and testing sets

print("Training set:")
print(X_train)
print("Training set targets:")
print(y_train)
print("\nTesting set:")
print(X_test)
print("Testing set targets:")
print(y_test)
# Make predictions on the testing set
predictions = model.predict(X_test)
# Print the predictions

print("Predictions:")

print(predictions)

You might also like