Machine Learning Basics Coding Project Error | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Machine Learning Basics Coding Project Error

The solution I wrote doesn't work even if the AI says it's correct. It also works on python on my pc. Anyone with the same following error? The sololearn compiler gives me a url error when trying to load the csv file at https://sololearn.com/uploads/files/one.csv

25th Feb 2024, 4:03 PM
Into Commercial
Into Commercial - avatar
21 Réponses
+ 2
Here is corrected answer and solution to that project import pandas as pd # Filename to access it. filename = input() # Ask for column input, can be something like “a”. column_name = input() # Read fhe CSV file from input. df = pd.read_csv(filename) # Return the values of the column. arr = df[column_name].values # Print the results print(arr)
26th Feb 2024, 11:44 AM
Hunter
Hunter - avatar
+ 2
Here is an image what it looks like with a working solution. https://ibb.co/8d22h91 Only the first 2 test cases are viewable. From there you can see what inputs the system gave you. There are 2 lines, first is "filename of a csv file", and second is "column name". Those inputs are different for each test case. And your code need to pass all of them.
26th Feb 2024, 2:14 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Sure! import pandas as pd import numpy as np df=pd.read_csv('https://sololearn.com/uploads/files/one.csv') column_name = df['a'] print(column_name)
25th Feb 2024, 5:18 PM
Into Commercial
Into Commercial - avatar
+ 1
How the dataframe can be created? You need to provide the data source, and "one.csv" is just an example. You ran your code, and the system told you are wrong, right? There is a tab called "RESULT". Please click on it and see the output for each test case (3 of them are hidden, not matter you are a PRO or not). You will see "Input" with 2 lines, which is the inputs as the task description told you. First line: filename of a csv file Second line: column name Also "Expected Output", which is the answer the system is expecting. You need to store them in 2 different variables, and use them to code the answer.
26th Feb 2024, 1:56 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
The system here says it's wrong. On my laptop in the Python IDLE it works like charm loading the csv from the url.
26th Feb 2024, 1:58 PM
Into Commercial
Into Commercial - avatar
+ 1
Please read the entire task description carefully. Getting a column from a numpy array. Task Given a csv file and a column name, print the elements in the given column. Input Format First line: filename of a csv file Second line: column name Output Format Numpy array Sample Input https://sololearn.com/uploads/files/one.csv a File one.csv contents: a,b 1,3 2,4 Sample Output [1 2] How is your code handle the "Input Format", NOT the "Sample Input". Also, how can your code handle the "column name"? You are hard coding both of them, the csv file and the column name. Both of them are supply to you on the fly.
26th Feb 2024, 2:04 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
Hello, could you provide the whole code?
25th Feb 2024, 5:16 PM
Hunter
Hunter - avatar
0
Please be more specific which lesson you have trouble with. It took me about 10 mins to find the lesson, it is Machine Learning > The Basics > What's in a Column? As the Task description says, given "a csv file" and a column name, print the elements in the given column. There are 5 test cases, and you are supposed to pass all the tests with the same code. Don't hardcode the file to be open.
26th Feb 2024, 1:31 AM
Wong Hei Ming
Wong Hei Ming - avatar
0
First, the lesson is Machine Learning Basics, as clearly stated in the title. Don't know why it took you 10 minutes to find it. Second, the AI says the code is correct. And indeed it also works in python on my computer. Third, when I select 'show solution' the app ends in an infinite cycle and doesn't show it.
26th Feb 2024, 11:17 AM
Into Commercial
Into Commercial - avatar
0
I'm not here to argue with you, but please pay attention to compare your topic and the actual module name. It is "The Basics", not merely "Basics". Also, it is called "Code Project", not "Coding Project". Furthermore, there are many Coding Project at the end of the modules. If you read it from the web, each Coding Project as a name. In the apps, it shows as a title on the page. I'm not a "Pro", therefore AI is not available to me. I guess the AI only check if there is any syntax error in the code, but not to verify your code to the answer. You may want to try print("Hello World") and see how the AI respond to you. However, please pay more attention to the task description again. Getting a column from a numpy array. Task Given a csv file and a column name, print the elements in the given column. <<ATTENTION>> Input Format First line: filename of a csv file Second line: column name Output Format Numpy array Sample Input https://sololearn.com/uploads/files/one.csv a File one.csv contents: a,b 1,3 2,4 Sample Output [1 2] Your code clearly missing the inputs. Instead, you hardcoded the one of the input. That's why your code cannot pass the tests.
26th Feb 2024, 12:45 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
You're arguing since the beginning in my opinion. XD By the way how is my solution missing the input if I'm creating a dataframe out of the the csv file loaded from the provided url? That's the input. The point is that the AI says my code passes the requirements of the challenge. Indeed it does work everywhere laptop and mobile compilers, except the Sololearn compiler that gives a url error. Hence I guess the problem is in this compiler. And the 'see solution' doesn't work. These are the facts. None of you has addressed my problem honestly. That is why the compiler gives an error that doesn't exist. I think what matters is the result, not that we are imposed how to get there. This looks stupid. Never seen it in any professional course so far.
26th Feb 2024, 12:52 PM
Into Commercial
Into Commercial - avatar
0
You are missing the point. I'm asking you to pay attention. Your code only provide "one" input and the input is "hard-coded". In my previous answer, I already mentioned that there are FIVE test cases. You cannot pass by hard coding "ONE" of the data source. Hunter gave the correct answer, but didn't provide answer or insight why your code doesn't work. You have to think the compiler is a person, who ask you the same question (print the elements in the GIVEN column) on different dataset or inputs. There are five test cases, in each case the compiler give you a dataset, AND tell you WHICH column he is asking.
26th Feb 2024, 1:14 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
No, a person wouldn't make a difference between df = pd.read_csv('one.csv') and df = pd.read_csv('https://sololearn/uploads/files/one.csv') Indeed all other compilers also don't. First time in my life I've seen such a non-sense. This is a stupid obligation turning into a waste of time and not letting one focusing on what really matters. By the way, thanks for having told me this system is stupid. You saved me some time. 😄👍🏻
26th Feb 2024, 1:35 PM
Into Commercial
Into Commercial - avatar
0
Did you try Hunter's answer before posting? You are missing 2 important things. 1. a variable to which the filename of the csv file 2. a variable to which store the column name As I said, there are 5 test cases. Each test case has a different csv file, and each test is asking different column name.
26th Feb 2024, 1:41 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
The variable is df for the dataframe.
26th Feb 2024, 1:42 PM
Into Commercial
Into Commercial - avatar
0
I usually try a specific test case and if it works I make it general. It's a method used in math. But if the system blocks me on stupid thing (cause it thinks a banana isn't a banana if I don't call it banana) I can't even test my particular starting case. And again, if I click on show solution, the system must show a solution, and not make me wait forever for it showing it got stucked. This is another bug.
26th Feb 2024, 1:47 PM
Into Commercial
Into Commercial - avatar
0
By the way thanks to both for suggestions. 😎👍🏻
26th Feb 2024, 1:55 PM
Into Commercial
Into Commercial - avatar
0
No, one.csv is a real file stored at that url. Put it in your browser and see it yourself.
26th Feb 2024, 2:00 PM
Into Commercial
Into Commercial - avatar
0
I think we misunderstood. We talk about the same thing at different stages. You are talking about the generalized form of code. Meaning the final version. Let it go.
26th Feb 2024, 2:03 PM
Into Commercial
Into Commercial - avatar
0
You don't get what I said. This compiler is set to read only the perfect final answer directly. It doesn't let you work on it. Let it go. Already wasted enough time with the stupid compiler and 'show solution' not working. Take care.
26th Feb 2024, 2:07 PM
Into Commercial
Into Commercial - avatar