+ 1

I have problems in machine learning project "Bob the builder" here's my code. I am not expert in python I know only basics so -

So I can't tell what's wrong with this Here's my code import pandas as pd from sklearn.linear_model import LogisticRegression n = int(input()) X = [] for i in range(n): X.append([float(x) for x in input().split()]) y = [int(x) for x in input().split()] datapoint = [float(x) for x in input().split()] datapoint = [float(x) for x in input().split()] model = LogisticRegression() model.fit(X,y) print(model.predict(datapoint))

15th Jun 2024, 12:18 PM
Girish Sahu
Girish Sahu - avatar
8 odpowiedzi
+ 1
The issue in your code is that the list comprehension for collecting data points in the variable `X` is incomplete. It lacks the expression that should be appended to the list `X`.
16th Jun 2024, 7:05 AM
Wajid Rahim
Wajid Rahim - avatar
+ 5
Girish Sahu You cannot call the input so many times in the for loop, only you call one time and then build a for loop. The best way to see how the data see is to print it, or a small part of it.
15th Jun 2024, 1:14 PM
JaScript
JaScript - avatar
+ 4
Could you present the task description?
15th Jun 2024, 12:55 PM
JaScript
JaScript - avatar
+ 3
JaScript Task You are given a feature matrix and a single datapoint to predict. Your job will be to build a Logistic Regression model with the feature matrix and make a prediction (1 or 0) of the single datapoint. Input Format First line: Number of data points in the feature matrix (n) Next n lines: Values of the row in the feature matrix, separated by spaces Next line: Target values separated by spaces Final line: Values (separated by spaces) of a single datapoint without a target value
15th Jun 2024, 1:00 PM
Girish Sahu
Girish Sahu - avatar
+ 3
Wilbur Jaywright that was mistaken I fixed that
15th Jun 2024, 1:01 PM
Girish Sahu
Girish Sahu - avatar
+ 3
In addition to the above mentioned will be needed the datapoint to reshape.
16th Jun 2024, 10:58 AM
JaScript
JaScript - avatar
+ 2
Why do you have the datapoint line twice?
15th Jun 2024, 12:52 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
+ 2
I think I should learn how to convert that n variable into array and acces last elements
16th Jun 2024, 4:12 AM
Girish Sahu
Girish Sahu - avatar