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

  • SEARCH
  • Home
  • 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 8845075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:38:59+00:00 2026-06-14T11:38:59+00:00

I have a method that returns a numpy array. What I want to do

  • 0

I have a method that returns a numpy array. What I want to do is in each iteration take this array and concatenate it into another array of arrays so that at the end of the loop I have a matrix

This is my code so far, but its crashing the program at the given line

 delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05, 0.06,0.07, 0.08, 0.09, 0.10])
 theta_Matrix = np.zeros(8)

 t = Ridge(Xtrain, ytrain, .3) # This method returns an array of 8 elements
 np.append(theta_Matrix,t, axis=0)
 print delta_Array
 print theta_Matrix

With this method, My current output is this

 [ 0.01  0.02  0.03  0.04  0.05  0.06  0.07  0.08  0.09  0.1 ] # delta_Array
 [ 0.  0.  0.  0.  0.  0.  0.  0.] # theta_Matrix

The output Id like should look something like this after 2 iterations. Also I do not know in advance the number of iterations the lop would go through.So any number of arrays could be produced after the method runs. But either way all arrays should form the theta_matrix:

  theta_Matrix:

 [[ 0.65  0.65565  0.19181  0.923  0.51561  0.846  0.6464  0.6464]
  [ 0.9879  0.31213  0.68464  0.611  0.6161  0.61651  0.29858  0.1811]]

Thanks

  • 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-06-14T11:39:00+00:00Added an answer on June 14, 2026 at 11:39 am

    I have a project were I need to do something very similar. You can implement dynamic resizing in your loop, but python’s list type is actually implemented as a dynamic array so you might as well take advantage of the tools that are already available to you. You can do something like this:

    delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05, 0.06,0.07, 0.08, 0.09, 0.10])
    theta_Matrix = []
    
    for i in range(N):
         t = Ridge(Xtrain, ytrain, .3)
         theta_Matrix.append(t)
    theta_Matrix = np.array(theta_Matrix)
    

    I should mention that if you already know the size you expect for theta_Matrix, you’ll get the best performance by doing something like:

    delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05, 0.06,0.07, 0.08, 0.09, 0.10])
    theta_Matrix = np.zeros((N, 8))
    
    for i in range(N):
         t = Ridge(Xtrain, ytrain, .3)
         theta_Matrix[i] = t
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that returns a value, and I want this value to
Hi I have a method that returns an array of support tickets. Each support
I have a method that returns a list of type string. I want to
All, I have a method that returns a List. This method is used to
I have a method that returns an instance of Map<String, List<Foo>> x(); and another
I have a method that returns an IEnumerable that I want to be able
I have a method that returns a CGMutablePathRef , something like this: - (CGMutablePathRef)somePath;
I have a method that returns a double. When I call this method and
I have a method that returns a list of roles, I want to put
Suppose I have a method that returns an array or list or some other

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.