Re: basic Python question

2020-05-08 Thread MRAB
On 2020-05-08 21:19, joseph pareti wrote: yet, something is still unclear; in Python you can do things like: *clf0.fit(X_train,y_train)* which is not the way I programmed in other languages where a left-hand side and a right hand side is required. All it's doing is performing the calculation

Re: basic Python question

2020-05-08 Thread joseph pareti
yet, something is still unclear; in Python you can do things like: *clf0.fit(X_train, y_train)* which is not the way I programmed in other languages where a left-hand side and a right hand side is required. Am Fr., 8. Mai 2020 um 21:52 Uhr schrieb joseph pareti < joeparet...@gmail.com>: > yes,

Re: basic Python question

2020-05-08 Thread joseph pareti
yes, it is random forest classifier from scikit learn. Thank you. Am Fr., 8. Mai 2020 um 21:50 Uhr schrieb MRAB : > On 2020-05-08 20:02, joseph pareti wrote: > > In general I prefer doing: > > > > > > X_train, X_test, y_train, y_test = train_test_split(X, y, > test_size=0.33, random_state=42) >

Re: basic Python question

2020-05-08 Thread MRAB
On 2020-05-08 20:02, joseph pareti wrote: In general I prefer doing: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) >clf = RandomForestClassifier(n_estimators = 100, max_depth= None) *clf_f = clf.fit(X_train, y_train)* predicted_labels = clf_f.pred

basic Python question

2020-05-08 Thread joseph pareti
In general I prefer doing: X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) clf = RandomForestClassifier(n_estimators = 100, max_depth= None) *clf_f = clf.fit(X_train, y_train)* predicted_labels = clf_f.predict( X_test) score = clf.score(X_test, y_test) s

Re: Basic python question

2019-10-03 Thread Peter Otten
Jagga Soorma wrote: > Thanks again Aldwin. This seems to work, guess it is the set that is > flipping the numbers: > > x,y = (output.split()) The parens on the right are superfluous: >>> a, b = "foo bar".split() >>> a 'foo' >>> b 'bar' > inode_cmd = "/bin/df --output=pcent,ipcent /var| grep -

Re: Basic python question

2019-10-02 Thread Jagga Soorma
Thanks again Aldwin. This seems to work, guess it is the set that is flipping the numbers: x,y = (output.split()) Much appreciated! On Wed, Oct 2, 2019 at 9:19 PM Aldwin Pollefeyt wrote: > > Seems to work also: > > >>> [x,y] = output.split() > > On Thu, Oct 3, 2019 at 12:17 PM Aldwin Pollefeyt

Re: Basic python question

2019-10-02 Thread Aldwin Pollefeyt
Seems to work also: >>> [x,y] = output.split() On Thu, Oct 3, 2019 at 12:17 PM Aldwin Pollefeyt wrote: > Oh, sorry .. please try this: > > >>> x,y = tuple(output.split()) > > On Thu, Oct 3, 2019 at 12:11 PM Jagga Soorma wrote: > >> Thanks Aldwin that helps but it looks like it is reversing the

Re: Basic python question

2019-10-02 Thread Aldwin Pollefeyt
Oh, sorry .. please try this: >>> x,y = tuple(output.split()) On Thu, Oct 3, 2019 at 12:11 PM Jagga Soorma wrote: > Thanks Aldwin that helps but it looks like it is reversing the numbers > for some reason: > > the df command returns the following: > 7 2 > > I used your example and did: > x,y =

Re: Basic python question

2019-10-02 Thread Jagga Soorma
Thanks Aldwin that helps but it looks like it is reversing the numbers for some reason: the df command returns the following: 7 2 I used your example and did: x,y = set(output.split()) My assumption would be that x should be 7 and y should be 2. However, when I print x and y it seems to be rev

Re: Basic python question

2019-10-02 Thread Aldwin Pollefeyt
You could use: >>> x, y = set(output.split()) On Thu, Oct 3, 2019 at 11:44 AM Jagga Soorma wrote: > Hello, > > I am new to python and trying to do some basic things with python. I > am writing a script that runs a df command and I need parts of that > output saved in 2 different variables. Is

Basic python question

2019-10-02 Thread Jagga Soorma
Hello, I am new to python and trying to do some basic things with python. I am writing a script that runs a df command and I need parts of that output saved in 2 different variables. Is this something that can be done? I can do this by running multiple df commands but would prefer to make only

Re: A small and very basic python question

2008-04-27 Thread Dan Bishop
On Apr 27, 5:26 pm, Dennis <[EMAIL PROTECTED]> wrote: > Dennis wrote: > > Could anyone tell me how this line of code is working: > > > filter(lambda x: x in string.letters, text) > > > I understand that it's filtering the contents of the variable text and I > > know that lambda is a kind of embedde

Re: A small and very basic python question

2008-04-27 Thread Dennis
I didn't give up after posting and managed to grasp this whole lambda thing! No need to respond now :-) I understood it the moment I tried to type out, instead of just thinking in my head, what was going on as a normal function. Dennis wrote: Could anyone tell me how this line of code is wor

A small and very basic python question

2008-04-27 Thread Dennis
Could anyone tell me how this line of code is working: filter(lambda x: x in string.letters, text) I understand that it's filtering the contents of the variable text and I know that lambda is a kind of embedded function. What I'd like to know is how it would be written if it was a normal fun

Re: basic python question about for loop

2008-04-12 Thread Steve Holden
jmDesktop wrote: [...] > So what is n and x in the first iteration? Sorry. I'm trying. Somewhat feebly, if you don't mind my saying so, but don't worry. The usual way to proceed in the face of such ignorance is to insert some form of output that will tell you the answer to your question. So:

Re: basic python question about for loop

2008-04-12 Thread Jason Stokes
"jmDesktop" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > So what is n and x in the first iteration? Sorry. I'm trying. Remember how Python's range operator works. range(n, x) constructs a list that consists of all elements starting with n and up to, but /not including/, x.

Re: basic python question about for loop

2008-04-09 Thread Terry Reedy
|So what is n and x in the first iteration? Sorry. I'm trying. When n == 2, the inner loop executes 0 times (the length of range(2,n)) and then falls thru to the else clause, printing the correct answer. -- http://mail.python.org/mailman/listinfo/python-list

Re: basic python question about for loop

2008-04-09 Thread Diez B. Roggisch
jmDesktop schrieb: > On Apr 9, 4:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> jmDesktop schrieb: >> >> >> >> >> >>> From the Python.org tutorial: >> for n in range(2, 10): >>> ... for x in range(2, n): >>> ... if n % x == 0: >>> ... print n, 'equals', x, '*',

RE: basic python question about for loop

2008-04-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 5:04 PM > To: python-list@python.org > Subject: Re: basic python question about for loop > > > > > > >>&g

Re: basic python question about for loop

2008-04-09 Thread jmDesktop
On Apr 9, 4:59 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of jmDesktop > > Sent: Wednesday, April 09, 2008 4:51 PM > > To: [EMAIL PROTECTED

Re: basic python question about for loop

2008-04-09 Thread jmDesktop
On Apr 9, 4:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > jmDesktop schrieb: > > > > > > > From the Python.org tutorial: > > for n in range(2, 10): > > ...     for x in range(2, n): > > ...         if n % x == 0: > > ...             print n, 'equals', x, '*', n/x > > ...             b

Re: basic python question about for loop

2008-04-09 Thread Steve Holden
jmDesktop wrote: >>From the Python.org tutorial: > for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ...

RE: basic python question about for loop

2008-04-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 4:51 PM > To: python-list@python.org > Subject: basic python question about for loop > > >From the Python.org tutorial

Re: basic python question about for loop

2008-04-09 Thread Diez B. Roggisch
jmDesktop schrieb: > From the Python.org tutorial: > for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ...

basic python question about for loop

2008-04-09 Thread jmDesktop
>From the Python.org tutorial: >>> for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... # loop fell through without finding a factor ... print n, 'is a prime number' ..