Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: How to define train set and test set
Post: RE: How to define train set and test set

Here's a simple example of slicing a numpy array... >>> import numpy as np >>> dataset = np.array([[1,2,3,4],[2,3,4,5],[3,4,5,6],[4,5,6,7],[5,6,7,8]]) >>> dataset array([[1,...
mpd Data Science 6 7,890 Mar-07-2018, 01:49 PM
    Thread: question about train_test_split()
Post: RE: question about train_test_split()

(Mar-06-2018, 07:18 AM)fadi Wrote: (Mar-05-2018, 07:37 PM)mpd Wrote: It's just indicating that it's a long integer. But the data I have are mix of negative and positive fraction integers, how can ...
mpd General Coding Help 3 3,313 Mar-06-2018, 12:40 PM
    Thread: question about train_test_split()
Post: RE: question about train_test_split()

It's just indicating that it's a long integer.
mpd General Coding Help 3 3,313 Mar-05-2018, 07:37 PM
    Thread: startswith() function
Post: RE: startswith() function

You're trying to compare the whole word (x) to one letter. You want to look at the first letter of the word (strings support the [] operator).
mpd General Coding Help 4 3,327 Mar-05-2018, 04:48 PM
    Thread: Creating code to make up to 4 turtle move simultaneously in a random heading
Post: RE: Creating code to make up to 4 turtle move simu...

There is definitely a more reasonable way to create that grid using one or more for-loops. However, I can't understand your current for-loop without spending way more time than I have to work it out o...
mpd Homework 3 5,488 Mar-05-2018, 03:48 PM
    Thread: How to define train set and test set
Post: RE: How to define train set and test set

(Mar-05-2018, 01:39 PM)Raj Wrote: Yes, I am using sklearn my definition as below: X_train,X_test,Y_train,Y_test=train_test_split(x,y,test_size=0.3,random_state=0) My data size is 1000, and I want to...
mpd Data Science 6 7,890 Mar-05-2018, 02:08 PM
    Thread: Creating code to make up to 4 turtle move simultaneously in a random heading
Post: RE: Creating code to make up to 4 turtle move simu...

First off, you need to format your code using the BBCode tags: https://python-forum.io/misc.php?action=help&hid=25 Your code is too hard to read to be much help. A few things to look at: Check o...
mpd Homework 3 5,488 Mar-05-2018, 12:28 PM
    Thread: re , TypeError: unsupported operand type(s) for -: 'str' and 'str'
Post: RE: re , TypeError: unsupported operand type(s) fo...

A TypeError is a Python exception. In this case, it's "thrown" or "raised" when the argument to int() is not a number. Exceptions are a common way for raising errors. Check out the tutorial about th...
mpd General Coding Help 1 11,420 Mar-04-2018, 01:06 PM
    Thread: Aggregate multiple telnet connections
Post: RE: Aggregate multiple telnet connections

Python provides a lot of support for concurrency: https://docs.python.org/3/library/concurrency.html I would probably start by using Threads and a concurrent queue; each thread connects to a device a...
mpd Networking 1 4,267 Mar-02-2018, 07:21 PM
    Thread: socket.gaierror: [Errno -2] Name or Service not known
Post: RE: socket.gaierror: [Errno -2] Name or Service no...

http_Server = socketserver.TCPServer((" ", 4444), HTTPHandler)That empty string is your problem. You need to give the server a hostname or interface for it to "listen" for incoming connections. If y...
mpd Networking 1 11,662 Mar-02-2018, 07:14 PM
    Thread: if else with comparison >= does not work
Post: RE: if else with comparison >= does not work

I copied and pasted your code and ran it with python3 on Windows 10, I get the following output: Output:Enter Hours:43 Enter Rate:23 Pay <function computepay at 0x0581C150>Running with python2,...
mpd General Coding Help 7 4,147 Mar-02-2018, 06:34 PM
    Thread: How to define train set and test set
Post: RE: How to define train set and test set

I assume you're using sklearn here. The train_test_split method randomly breaks up your data; that is its purpose. By specifying random_state=0, you will always get the same output for the same inpu...
mpd Data Science 6 7,890 Mar-02-2018, 05:38 PM
    Thread: I'm not sure why this code isn't printing... Can someone tell me?
Post: RE: I'm not sure why this code isn't printing... C...

(Mar-01-2018, 06:42 PM)Wilminer4 Wrote: Oh okay, I'll try that and sorry about using Python 2, I made this at a website called codehs.com because we use it in class. I'm ahead of other people, so I ...
mpd General Coding Help 5 3,697 Mar-01-2018, 06:54 PM
    Thread: serial communication write(comand) and read(result)
Post: RE: serial communication write(comand) and read(re...

Be more specific. What isn't working right? Any errors or exceptions? Is it doing the wrong thing? Is it doing nothing at all? Do you know if the device is receiving your messages? I don't know ...
mpd General Coding Help 1 2,908 Mar-01-2018, 04:26 PM
    Thread: I'm not sure why this code isn't printing... Can someone tell me?
Post: RE: I'm not sure why this code isn't printing... C...

What do you get if you add a print statement before the if ad == "Attack": if decision == "Yes": print "You decide to continue on with your journey!" print "You descend into the first room......
mpd General Coding Help 5 3,697 Mar-01-2018, 04:22 PM
    Thread: How can I save a class as a module
Post: RE: How can I save a class as a module

Create a file foo.py with the class definition: class Foo: def __init__(self): pass def bar(self): passIn file main.py import it: import foo myfoo = foo.Foo() # -- or -- from foo...
mpd General Coding Help 2 4,947 Feb-07-2018, 02:57 PM
    Thread: Global vs local variable
Post: RE: Global vs local variable

Quote:I'm addressing the 'learn some python' part of it, and this will be easier by using classes right away We'll have to agree to disagree on this.
mpd General Coding Help 11 7,034 Jan-13-2018, 12:21 AM
    Thread: Global vs local variable
Post: RE: Global vs local variable

(Jan-12-2018, 08:31 PM)Gribouillis Wrote: (Jan-12-2018, 07:33 PM)mpd Wrote: you can have simple, extensible examples without using classes.It may be true, but this is for expert programmers, and t...
mpd General Coding Help 11 7,034 Jan-12-2018, 10:59 PM
    Thread: Global vs local variable
Post: RE: Global vs local variable

(Jan-12-2018, 07:13 PM)Gribouillis Wrote: (Jan-12-2018, 06:47 PM)mpd Wrote: Why? What benefit is gained by using classes here instead of methods?There are two immediate benefits: Classes is the t...
mpd General Coding Help 11 7,034 Jan-12-2018, 07:33 PM
    Thread: Global vs local variable
Post: RE: Global vs local variable

Quote:I think it is time to start using classes Why? What benefit is gained by using classes here instead of methods?
mpd General Coding Help 11 7,034 Jan-12-2018, 06:47 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020