Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Help importing a function from another python file
Post: RE: Help importing a function from another python ...

(Apr-11-2018, 12:51 AM)Larz60+ Wrote: you need to add an __init__.py in the parent directory (cnc-binary) that looks like: Thanks. So my new file structure is: cnc-binary/ __init__.py try.p...
JoeB General Coding Help 5 4,231 Apr-11-2018, 12:54 AM
    Thread: Help importing a function from another python file
Post: RE: Help importing a function from another python ...

(Apr-11-2018, 12:05 AM)ljmetzger Wrote: Please double check your spelling of model_validataion Thanks, Still throws up the same error though.
JoeB General Coding Help 5 4,231 Apr-11-2018, 12:24 AM
    Thread: Help importing a function from another python file
Post: Help importing a function from another python file

My directory structure is like so: cnc-binary ---> ff_repos ---> ---> ff_nlp_trained_models ---> ---> ---> ff_nlp_trained_models ---> ---> ---> ---> __init__.py --->...
JoeB General Coding Help 5 4,231 Apr-10-2018, 11:54 PM
    Thread: ValueError: Attempted relative import in non-package
Post: ValueError: Attempted relative import in non-packa...

There are answers here: https://stackoverflow.com/questions/1153...th-init-py but I don't really understand them. My directory structure is as follows: Output:dir1/ __init__.py model_helpers...
JoeB General Coding Help 1 11,957 Mar-08-2018, 10:30 AM
    Thread: Word co-occurrence matrix for a string (NLP)
Post: Word co-occurrence matrix for a string (NLP)

I need to create a word co-occurrence matrix that shows how many times one word in a vocabulary precedes all other words in the vocabulary for a given corpus. The input sentence can be tokenized or n...
JoeB General Coding Help 2 11,640 Feb-27-2018, 07:15 PM
    Thread: Regex: How to say 'any number of characters of any type until x'?
Post: Regex: How to say 'any number of characters of any...

I want to be able to refer to any number of characters of any type (including special characters) up until a specified character, which we'll call 'x' here. So for example: wdq3jdbmhb..s?//seuybwbxqw...
JoeB General Coding Help 2 2,377 Jan-24-2018, 03:11 PM
    Thread: What is wrong with this implementation of the cost function for linear regression?
Post: What is wrong with this implementation of the cost...

I am trying to write the cost function for regularised linear regression. (I am doing exercise 5 from the Stanford Coursera course on machine learning.) In the code below I also include a print of the...
JoeB Data Science 1 3,222 Dec-22-2017, 07:24 PM
    Thread: Why do floats get turned to scientific notation when used to populate an array?
Post: Why do floats get turned to scientific notation wh...

I am trying to populate an array with a data set of numbers that are imported as strings. I start by converting them to floats, and then put the floats into an array. After the stage of float conver...
JoeB Data Science 2 9,570 Dec-10-2017, 05:47 PM
    Thread: Why is my gradient descent algorithm requiring such a small alpha?
Post: Why is my gradient descent algorithm requiring suc...

I am trying to implement a gradient descent algorithm for linear regression. Unfortunately I can't attach the data set. My algorithm is shown below: import numpy as np import csv import matplotlib.p...
JoeB Data Science 1 2,410 Dec-08-2017, 05:15 PM
    Thread: Why is my gradient descent algorithm requiring such a small alpha?
Post: Why is my gradient descent algorithm requiring suc...

I am trying to implement a gradient descent algorithm for linear regression. I am using the attached data. My algorithm is shown below: import numpy as np import csv import matplotlib.pyplot as plt ...
JoeB Data Science 1 2,410 Dec-08-2017, 05:09 PM
    Thread: Identifying the value of all adjacent elements in an array
Post: How can I adapt this piece of code to find nearest...

This function is used to compute a list of horizontal, vertical and diagonal neighbours in a 10x10 array: X = 10 Y = 10 neighbours = lambda x, y : [(x2-1, y2-1) for x2 in range(x-1, x+2) for y2 in ra...
JoeB General Coding Help 2 8,640 Nov-23-2017, 05:10 PM
    Thread: Adding a row to a character array
Post: Adding a row to a character array

m = np.chararray((10, 10)) m[:] = "*" m(5, 4), m(5, 6) = "O", "O"So I have the following character array: Output:m = [['*' '*' '*' '*' '*' '*' '*' '*' '*' '*'] ['*' '*' '*' '*' '*' '*' '*' '*'...
JoeB General Coding Help 1 2,345 Nov-23-2017, 12:06 PM
    Thread: Identifying the value of all adjacent elements in an array
Post: Identifying the value of all adjacent elements in ...

Consider the following array: Output:m = [['*' '*' '*' '*' '*'] ['*' '*' '*' '*' '*'] ['*' 'O' '*' '*' '*'] ['*' '*' '*' '*' '*'] ['*' '*' '*' '*' '*']]I want to be able to iden...
JoeB General Coding Help 2 8,640 Nov-22-2017, 11:24 PM
    Thread: How can I produce a list of n times the same element?
Post: RE: How can I produce a list of n times the same e...

(Nov-21-2017, 10:51 PM)Larz60+ Wrote:  v = ('* '*5).split()result: Output:>>> v ['*', '*', '*', '*', '*'] Thanks. How come it doesn't work to then append to v? So for example: v = ('* '*5)...
JoeB General Coding Help 6 3,771 Nov-21-2017, 11:11 PM
    Thread: How can I produce a list of n times the same element?
Post: How can I produce a list of n times the same eleme...

I want to produce the list: ["*", "*", "*", "*", "*"]. Can this be done in a simple line? (I don't want to have to create a function to do it.) So far I have been having to do the following, which...
JoeB General Coding Help 6 3,771 Nov-21-2017, 10:39 PM
    Thread: How to find the number of permutations of a list of lists?
Post: RE: How to find the number of permutations of a li...

(Nov-18-2017, 06:10 PM)heiner55 Wrote: import itertools list = [['A', 'M'], ['G', 'R'], ['E', 'T']] for i in itertools.product(list[0], list[1], list[2]):     print(i)Output:('A', 'G', 'E') ('A', ...
JoeB General Coding Help 5 5,361 Nov-18-2017, 06:26 PM
    Thread: How to find the number of permutations of a list of lists?
Post: RE: How to find the number of permutations of a li...

(Nov-18-2017, 05:44 PM)heiner55 Wrote: See https://python-forum.io/Thread-looking-f...r-in-order As shown in the question I'm pretty much already able to solve that problem. The problem in my questi...
JoeB General Coding Help 5 5,361 Nov-18-2017, 05:58 PM
    Thread: How to find the number of permutations of a list of lists?
Post: How to find the number of permutations of a list o...

I have the following list: list = [['A', 'M'], ['G', 'R'], ['T', 'E']] I want to find the number of permutations of these letters, such that a letter from a sublist can only be used once. In this ...
JoeB General Coding Help 5 5,361 Nov-18-2017, 05:18 PM
    Thread: How do you change specific elements in a char array of string?
Post: RE: How do you change specific elements in a char ...

(Oct-31-2017, 08:37 AM)cryomick Wrote: What IDE are you using? I tried this in IDLE and got the following result: >>>a = np.chararray((3,3)) >>> a chararray([['', '\x01', ''], ...
JoeB Data Science 4 6,550 Oct-31-2017, 09:50 AM
    Thread: How do you change specific elements in a char array of string?
Post: RE: How do you change specific elements in a char ...

(Oct-31-2017, 03:30 AM)Mekire Wrote: Firstly, you need to make it clear you are using numpy.  chararray is not a builtin type. Secondly, Quote:I would think that this would edit the element corresp...
JoeB Data Science 4 6,550 Oct-31-2017, 08:20 AM

User Panel Messages

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