Re: pysftp / paramiko problem

2019-06-12 Thread Robin Becker

On 12/06/2019 05:59, dieter wrote:

Robin Becker  writes:

I am trying to convert older code that uses ftplib as the endpoint has switched 
to sftp only.

I am using the pysftp wrapper around paramiko.

The following script fails

def main():
 import pysftp
 with pysftp.Connection('ftp.remote.com', username='me', password='xx') 
as sftp:
 print('top level')
 print(sftp.listdir())
 print(sftp.normalize(u''))


 From the "sftp" documentation:

  |  normalize(self, remotepath)
  |  Return the expanded path, w.r.t the server, of a given path.  This
  |  can be used to resolve symlinks or determine what the server believes
  |  to be the :attr:`.pwd`, by passing '.' as remotepath.

This suggests that your observation could be explained
by "u''" being a broken symlink.


Well with real sftp I can cd to that path so if it is a symlink it goes 
somewhere.

With pysftp I am unable to chdir or cd into it. With a bit of difficulty I can use subprocess + sshpass + sftp to do the required 
transfer.

--
Robin Becker

--
https://mail.python.org/mailman/listinfo/python-list


Why am a getting wrong prediction when combining two list of samples, which individually gives correct prediction?

2019-06-12 Thread Rishika Sen
So I am coding in Python. I have to set of samples. Set1 contains samples of 
class A and the other set, Set2 contains samples of class B. When I am 
predicting set1 and set2 individually, the classification is perfect. Now when 
I am merging the two sets for prediction into one set, the prediction gives the 
wrong result for the samples in Set2, i.e., predicting the samples of set 2 to 
be in class A. However, samples belonging to Set1 are predicted to be in class 
A in the merged set. Why is this happening?

model.add(Dense(newshape[1]+1, activation='relu', input_shape=(newshape[1],)))
model.add(Dropout(0.5))
model.add(Dense(500, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(250, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(100, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(50, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
  optimizer='adam',
  metrics=['binary_accuracy'])
model.fit(X_train, y_train,validation_data=(X_test, 
y_test),validation_split=0.2, epochs=500, batch_size=25, verbose=0)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why am a getting wrong prediction when combining two list of samples, which individually gives correct prediction?

2019-06-12 Thread Peter Pearson
On Wed, 12 Jun 2019 04:12:34 -0700 (PDT), Rishika Sen wrote:

> So I am coding in Python. I have to set of samples. Set1 contains
> samples of class A and the other set, Set2 contains samples of class
> B. When I am predicting set1 and set2 individually, the classification
> is perfect. Now when I am merging the two sets for prediction into one
> set, the prediction gives the wrong result for the samples in Set2,
> i.e., predicting the samples of set 2 to be in class A. However,
> samples belonging to Set1 are predicted to be in class A in the merged
> set. Why is this happening?
>
> model.add(Dense(newshape[1]+1, activation='relu', input_shape=(newshape[1],)))
> model.add(Dropout(0.5))
> model.add(Dense(500, activation='relu'))
> model.add(Dropout(0.5))
> model.add(Dense(250, activation='relu'))
> model.add(Dropout(0.5))
> model.add(Dense(100, activation='relu'))
> model.add(Dropout(0.5))
> model.add(Dense(50, activation='relu'))
> model.add(Dropout(0.5))
> model.add(Dense(1, activation='sigmoid'))
> model.compile(loss='binary_crossentropy',
>   optimizer='adam',
>   metrics=['binary_accuracy'])
> model.fit(X_train, y_train,validation_data=(X_test, y_test),
>  validation_split=0.2, epochs=500, batch_size=25, verbose=0)

This is really a question about some model-fitting package that you're
using, not about Python.  And you don't even tell us which model-fitting
package it is.  Please share more information.

Are you expecting that any model-fitting process that works individually
on Set1 and Set2 must work on the union of the two sets?  'Cause I don't
think it works that way.

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pysftp / paramiko problem

2019-06-12 Thread dieter
Robin Becker  writes:
> On 12/06/2019 05:59, dieter wrote:
>> Robin Becker  writes:
>>> I am trying to convert older code that uses ftplib as the endpoint has 
>>> switched to sftp only.
> ...
> Well with real sftp I can cd to that path so if it is a symlink it goes 
> somewhere.
>
> With pysftp I am unable to chdir or cd into it. With a bit of
> difficulty I can use subprocess + sshpass + sftp to do the required
> transfer.

Maybe, the problem is the "u" prefix.
Can you try your script with Python 3 or encode the unicode
into a native ``str``?

-- 
https://mail.python.org/mailman/listinfo/python-list