- Joined
- Jun 29, 2022
- Messages
- 24
- Reaction score
- 0
Hello,
I'm presently working on a supervised learning project using scikit-learn, similar to the example given here, and I've run into an issue that has me stumped. When I try to fit my data into a machine-learning model, I get the following error:
My characteristics and target labels were both loaded from different CSV files with the same amount of rows. However, I'm not clear why this inconsistency issue is occurring. Could someone please assist me in identifying the problem?
Here's a shortened version of my code:
I'd appreciate any help in fixing this inconsistency error. Thank you for your assistance!
I'm presently working on a supervised learning project using scikit-learn, similar to the example given here, and I've run into an issue that has me stumped. When I try to fit my data into a machine-learning model, I get the following error:
Code:
ValueError: Found input variables with inconsistent numbers of samples: [100, 120]
Here's a shortened version of my code:
Code:
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
# Load the data from CSV files
X = pd.read_csv('features.csv')
y = pd.read_csv('labels.csv')
# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Initialize and fit the logistic regression model
model = LogisticRegression()
model.fit(X_train, y_train)