Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:30:05+00:00 2026-05-31T23:30:05+00:00

I have an array Y of the form(it is just an example, i have

  • 0

I have an array Y of the form(it is just an example, i have a huge data in this form). The array is formed by using numpy’s vstack and hstack (i.e I don’t want to change how I obtain this array as I have obtained it by some complex operations):

 Y=array([[1,  1,2],
        [1,  2,0],
        [-1, 3,1],
        [-1, 2,2]])
y=[1,1,-1,-1]
Y1=list(Y)

Now I am inputting the data to a libsvm function, this library expects the input parameters to be in dictionary, list or tuple form. Therefore, the code for the same is:

prob=svm_problem(y, Y1)

The above function throws an error that ‘xi should be a dictionary, list or tuple’. The other way that I know is to convert Y to list iteratively. The manner to do it is:

Y1=[] 
for i in range(0, Y.shape[0]):
      Y1.append(list(Y[i])

The above method works well but is slow considering the huge data that I have. Is there any faster method to accomplish the same?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:30:06+00:00Added an answer on May 31, 2026 at 11:30 pm
    >>> Y.tolist()
    [[1, 1, 2], [1, 2, 0], [-1, 3, 1], [-1, 2, 2]]
    

    I’m not sure if this will be much faster than what you have for large two-dimensional arrays. Converting such arrays to plain lists of lists is an inherently inefficient operation — that’s why you use NumPy in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable that contains an array from form data, seen below: $option1
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have set the form decorators in this way: <?php $this->setElementDecorators(array( 'Label', array(array('labelTd' =>
I have an array of integers in string form: var arr = new string[]
I have declared an array in the form: var refs = { 'EE810': Presence
I have an array of JButtons which form a keypad interface. After six numbers
I have an array of strings of the form: @source = ( something,something2,third ,something,something3
My problem is as follows. I have an array of objects in the form
I have the following Symfony2 form: public function buildForm(FormBuilder $builder, array $options) { $builder
Say if I have an array and I want to check if an element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.