please help me write algorithm for my task

This is the place for queries that don't fit in any of the other categories.

please help me write algorithm for my task

Postby synthex » Fri Mar 15, 2013 7:30 am

Hello colleagues, could you help me write algorithm for my task.I need to solve the problem using python to data processing. Namely: i have got data of test (in .txt file) The subjects answered on 14 tasks , they did it 5 times
The subjects are separated by a blank line.
for example
1,0,0,1,0,1,0,1,1,1,0,1,1,1
1,0,1,1,0,0,1,1,0,1,0,1,1,1
1,0,0,1,0,1,0,1,1,0,0,1,0,1
1,0,0,0,1,1,1,1,0,1,1,0,1,0
0,1,0,1,1,1,0,1,1,0,0,1,1,0

1,1,1,1,1,0,1,1,0,0,1,1,1,1
1,0,1,1,1,0,0,1,1,1,0,1,0,1
1,1,0,0,0,0,0,0,0,0,0,1,0,1
1,0,0,1,1,0,1,0,0,1,0,1,0,1
1,0,0,1,0,1,1,1,1,1,1,1,0,1

0,1,0,1,0,1,1,1,0,0,1,1,1,1
1,0,1,0,1,1,1,1,1,0,1,1,1,0
1,0,1,0,1,0,0,1,1,1,0,1,1,1
1,0,0,1,1,1,1,0,0,0,1,1,1,0
1,0,0,1,1,1,1,1,1,0,1,1,1,1

0,1,1,1,0,1,0,0,1,0,1,1,1,0
1,1,1,1,0,1,1,1,1,0,1,1,0,0
1,1,1,1,1,0,1,1,1,0,0,1,1,0
1,1,1,1,0,1,1,1,1,0,1,1,1,0
1,1,1,0,1,0,1,1,1,0,1,1,1,1

0,1,1,1,0,0,1,1,0,1,1,0,0,1
0,1,0,1,1,1,1,1,1,1,1,1,0,0
0,1,0,1,0,0,1,0,0,0,0,1,0,1
0,1,0,1,1,1,1,1,0,1,1,1,0,1
0,0,0,1,1,1,1,1,0,0,1,1,1,1

0,0,1,1,0,0,1,1,1,0,1,1,1,1
1,1,1,1,1,0,1,1,1,1,1,1,1,0
0,0,1,1,1,0,1,1,0,0,1,1,1,1
1,0,0,0,1,1,0,1,1,1,1,1,1,1
1,1,1,1,1,0,1,0,1,1,1,0,1,1

0,0,1,0,0,0,1,1,1,0,1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,0,0,1,1,0,1,0,1,0
1,0,1,0,0,1,1,1,0,0,0,0,1,0
0,0,1,0,1,0,0,1,1,0,0,0,1,0

1,0,1,1,0,1,0,1,1,0,1,1,1,0
1,1,0,1,0,1,0,1,0,0,1,1,0,0
1,1,0,1,0,0,0,1,0,0,1,0,0,0
0,1,0,1,0,0,0,0,1,1,1,0,0,0
1,0,0,1,0,0,0,1,0,0,1,1,1,0

0,1,1,0,0,0,1,0,1,0,0,0,0,1
0,0,1,1,0,1,0,0,0,0,0,0,0,0
1,1,1,1,0,0,1,1,1,1,1,0,0,1
0,0,1,1,0,1,1,0,0,0,0,1,0,0
1,0,1,0,0,1,0,0,0,0,0,0,0,1

1,1,0,1,0,0,0,1,1,0,1,0,1,0
1,1,1,1,1,1,1,1,1,0,0,0,1,1
1,1,1,0,0,1,1,1,1,0,1,1,1,0
1,1,1,1,0,1,1,0,1,0,1,1,1,0
1,1,1,1,0,1,1,1,1,0,1,0,1,0

0,0,0,1,1,1,1,1,1,0,0,1,1,0
0,1,1,1,1,0,1,1,1,1,0,0,1,1
1,1,0,1,1,0,0,1,0,1,0,1,0,1
1,0,1,0,1,0,1,1,1,0,0,0,1,1
1,0,0,1,1,0,1,1,1,0,0,0,1,0

0,0,0,0,1,0,0,1,0,0,0,0,0,1
0,0,0,1,0,0,1,1,0,0,0,1,1,1
1,1,1,1,0,0,1,1,0,1,1,1,0,1
1,1,0,1,0,1,1,1,0,0,0,1,0,0
0,0,0,1,0,1,1,1,1,0,1,1,1,0
19 subjects respectively
each of subject has this series 14 task 5 times

1- task done right
0-task done wrong
In other words, each subject done 70 tasks. where 1- task done right , and 0-task done wrong
If you add up all correctly solved tasks and divide by 70, you get the probability that subject will decide right following test.
Please Tell me how to write code to calculate the probability of error for each of the subjects and to print these probability to the screen
thank you
synthex
 
Posts: 2
Joined: Fri Mar 15, 2013 7:02 am

Re: please help me write algorithm for my task

Postby setrofim » Fri Mar 15, 2013 9:24 am

synthex wrote:In other words, each subject done 70 tasks. where 1- task done right , and 0-task done wrong
If you add up all correctly solved tasks and divide by 70, you get the probability that subject will decide right following test.

Not really. They have done 14 tasks, each of them five times; this is different than them doing 70 different task. The performance of a subject is unlikely to be uniform across the tasks. For example, if you look at subject 17 (third from the bottom), they excelled at the first three tasks (preforming perfectly for the first two and getting the third one wrong only once), but not task 10 (didn't get it right once). Your proposed metric will be very inaccurate for determining the probability that a particular subject does a particular task correctly; and it will only be a decent predictor of the subject's overall performance on the next test, if the next test's overall task distribution is similar to the one you have data for.

As for helping with implementing the calculation, first post the attempt you've made on your own.
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: please help me write algorithm for my task

Postby synthex » Fri Mar 15, 2013 9:53 am

initially i have Trouble in import my data in python

look
Image
i cant import my file
synthex
 
Posts: 2
Joined: Fri Mar 15, 2013 7:02 am

Re: please help me write algorithm for my task

Postby setrofim » Fri Mar 15, 2013 10:41 am

In the future, please copy an paste the (complete) error message and traceback into your post, rather than attaching a screenshot (or even worse, linking to one hosted on some random site).

You don't need to do the whole "if __name__ == '__main__'" thing when you're in the interactive shell. Also you're calling something called main() without defining it. Finally, when opening a file, you need to specify the path to the file as a string, not file.

In other words, just do
Code: Select all
f = open("data.txt")
# do stuff with f...
f.close()

Assuming, your data is a file called "data.txt" in the same directory that you've started Python shell in.
Additionally, a more "pythonic" way of opening files is to do
Code: Select all
with open("data.txt") as f:
    # do stuff with f...

This way, you don't have to remember to close the file once you are done with it.
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: please help me write algorithm for my task

Postby metulburr » Fri Mar 15, 2013 11:57 am

In the future, please copy an paste the (complete) error message and traceback into your post, rather than attaching a screenshot (or even worse, linking to one hosted on some random site).

+1
I have added that into "what to not include in a post" in New Users, Read This becausse its common enough
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1473
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to General Coding Help

Who is online

Users browsing this forum: buran and 6 guests