Hello, Guys,
I have a question about the linear_least_squares in Numpy.
My linear_least_squares cannot give me the results.
I use Numpy1.0. The newest version. So I checked online and get your
guys some examples.
I did like this.
[john@crux 77] ~ >py
Python 2.4.3 (#1, May 18 2006, 07:40:45)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>from Numeric import * from LinearAlgebra import linear_least_squares from Matrix import * y = Matrix([[1], [2], [4]]) x = Matrix([[1, 1], [1, 2], [1, 3]]) print y
Matrix([[1],
[2],
[4]])
>>x
Matrix([[1, 1],
[1, 2],
[1, 3]])
>>print linear_least_squares(x, y)
Here my Numpy stops. and never give me a result. THis is the problem of
Numpy or sth wrong.
Can you guys give me a LinearAlgebra.py so that I can have a try?
Thanks,
John 1 7475
I have a question about the linear_least_squares in Numpy.
Not quite sure what is going on, it looks like there could be some
confusion as to linear_least_squares is expecting as an argument of
some Numeric arrays and what you are supplying (a Matrix) is perhaps
not close enough to being the same thing.
Up-to-date versions for all this are all in "numpy" nowadays and the
numpy mailing list is perhaps a better place to ask: http://projects.scipy.org/mailman/li...mpy-discussion
Anyway, I've pasted in an example using Numeric and LinearAlgebra,
which you seem to have on your system. They still work fine. Not sure
what the "Matrix" package is that you are using?
HTH,
Jon
example:
C:\>python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>from Numeric import * from LinearAlgebra import linear_least_squares a=array( [[1, 1], [1, 2], [1, 3]] ) y=array( [ 1,2,4] ) # note 1 D a
array([[1, 1],
[1, 2],
[1, 3]])
>>y
array([1, 2, 4])
>>linear_least_squares(a,y)
(array([-0.66666667, 1.5 ]), array([ 0.16666667]), 2, array([
4.07914333, 0.60049122]))
>>>
# Is this what you expect as output???
Jianzhong Liu wrote:
Hello, Guys,
I have a question about the linear_least_squares in Numpy.
My linear_least_squares cannot give me the results.
I use Numpy1.0. The newest version. So I checked online and get your
guys some examples.
I did like this.
[john@crux 77] ~ >py
Python 2.4.3 (#1, May 18 2006, 07:40:45)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>from Numeric import * from LinearAlgebra import linear_least_squares from Matrix import * y = Matrix([[1], [2], [4]]) x = Matrix([[1, 1], [1, 2], [1, 3]]) print y
Matrix([[1],
[2],
[4]])
>x
Matrix([[1, 1],
[1, 2],
[1, 3]])
>print linear_least_squares(x, y)
Here my Numpy stops. and never give me a result. THis is the problem of
Numpy or sth wrong.
Can you guys give me a LinearAlgebra.py so that I can have a try?
Thanks,
John
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: nikie |
last post by:
I'm a little bit stuck with NumPy here, and neither the docs nor
trial&error seems to lead me anywhere:
I've got a set of data points (x/y-coordinates) and want to fit a
straight line through...
|
by: sql guy123 |
last post by:
This is a real challenge. I hope someone is smart enough to know how
to do this.
I have a table
TABLE1
|
by: wirecom |
last post by:
Hi all,
I am seeking a module that will do the equivalent of linear regression in
3D to yield a best fit a plane through a set of points (X1, Y1, Z1), (X1,
Y1, Z1),... (Xn, Yn, Zn).
The...
|
by: zRaVeNk |
last post by:
anyone help me with linear regression in visual basic
here's what i'm working with: screenshot
|
by: Nod Lee |
last post by:
Hi all
Is there any tools/objects from Microsoft that I can use to perform linear
regression in webform and generate the results into a graph?
If not, is there any recommendations for 3rd...
|
by: Michael O'Brien |
last post by:
Hola~
I have a large array of points (over a million). I would like to
multiply each point in the array by a 4x4 matrix. I keep thinking
there should be an easy way to do this using numpy, but I...
|
by: ntuyen01 |
last post by:
Hi All,
Does anyone has examples for Linear Regression formula using c#.
Or any good third party software create this.
Thanks in advance
Regards,
Ted
|
by: jivelasquezt |
last post by:
Hi all,
I'm new to this group so I don't know if this question has been posted
before, but does anyone knows about linear/integer programming
routines in Python that are available on the web,...
|
by: PlsHelp |
last post by:
Hi every1,this is my 1st time using this forum....pls can any1 tell me how to create a code in VB that can do LINEAR REGRESSION in excel.....i'm not sure how to xplain exactly what i need but...
|
by: drfish |
last post by:
Hi, I'm a complete novice when it comes to VB so need some help.
I would like a macro that performs linear regression for different cell ranges each time it is run, depending on the number of...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |