Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:29pm On Jun 06, 2020 |
donproject:
Exactly, I can see you've taken your game further beyond comfort zone. One of my goals is to know in and out of python and along this path i can see c language being my next programming language because of cpython implementation and being the first language to implement python but dont think i can move to it now. |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:24pm On Jun 06, 2020 |
Predstan:
I decided to use Binary Search and Sorted List, now looks good a little.
Do you understand that your equation to calculate complexity will be Sorted list + binary search |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 2:04pm On Jun 06, 2020 |
donproject:
Programming is not about learning a difficult or easy syntax, it is about knowing the fundamentals. Either you choose Python, Ruby, PHP, Java, C#, etc, can you do the sleekest thing with them?
Today, Python is the most sought-after programming language that let you worry less about the syntactic make-up and focus on the big events with its rich collections of libraries. Why choosing to do what you can do with just 5 lines of Python code with 30 lines of code of some other syntactically difficult languages? There are too many things to learn than wasting your time on syntax.
Moreover, I will still never agree that Python is as simple as many people try to believe, not when you have tried some advanced topics that will leave you sweating over your computer. One can only say that Python is simple if what one is doing all along is playing safe. Well said.... >>>python get complex when someone begin to define wrapper with decorators and functional concept where functions in some cases chaining this way My_new = func(argument)(first_fuc)(second_func)
>>>More complex,when writing abstract class using metaclass and >>> most complex when writing in c language to work in python(most advanced) |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 10:05am On Jun 06, 2020 |
Should: lmao this is what I've been awake for... with this pace, I'd probably be killing Artificial Intelligence(AI) by nxt week!.. 
Lolz....small small sir,a step at a time |
Programming / Re: Python And C++ Programmer Needed ASAP by gbolly1151(m): 10:12pm On Jun 05, 2020 |
For Python pm on 07060435624 |
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 10:03pm On Jun 05, 2020 |
Give a recursive algorithm to compute the product of two positive integers, m and n, using only addition and subtraction. |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 5:17pm On Jun 05, 2020 |
Should: Gratitudes! However, I hope you wouldn't mind if I make you my personal superior, whom to fall back to, in terms of correction... PS: Seanwilliam, what's your update? felt like informing you, so we could learn together and on our own.. You can reach me on WhatsApp 07060435624 1 Like |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 2:57pm On Jun 05, 2020 |
Should: please, kindly outline necessary things and best step to be taken.. I've got nothing on ground, but I've made up my mind for perfection concerning python.. Finance isn't the issue, vivid explanation is... >>>start with python basic,solve questions along the line >>>socket programming using python >>>start reading basic ethical hacking,understand the theory >>>test your skill with practical |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 1:36pm On Jun 05, 2020 |
Should: Firstly, I'm totally a newbie on programming. my aim is to get soaked in everything concerning python and other important language.. goal; Cybersecurity, intend using it compliment myself as a Dss agent... That is good...python is a great way to start ethical hacking, you can pick up book on google and videos then build yourself up |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:41am On Jun 05, 2020 |
Should: Pls, how do I make the command valid? What do you want to achieve ? |
Programming / Re: Data Structures And Algorithms: A Beginner's Journey. by gbolly1151(m): 9:54pm On Jun 04, 2020 |
Rafoski: Day 03
The last two days have been somewhat crazy. We've still not had power supply but earlier in the evening, the EDC here gave us four minutes of power supply for the whole day lol-how amazing. I'm sure theyll get their groove on by the end of the day. Okay, what did I learn yesterday evening from the video? Big-O notations for some algorithms. After looking at some algorithms that were used as examples, I came to the conclusion that the Big-O of any function is the number of n(s) you can find in the function. Just count the number of n(s) and raise it to the order(power). So, if I have 2 ns in an algorithm, that means it's O(n^2). Now, this is not conventional, it's merely a pattern I observed. Plus it doesn't work in the cases of logarithmic functions. But the Big-O of any function is found either graphically or by deduction. I don't yet know how to deduce the time complexity of functions but I'm learning. Below are some examples of algorithms from the video and their Big-O's. Finding all subsets of a set-O(2^n) Finding all permutations of a string-O(n!) Sorting using mergesort- O(n log(n)) Okay, there they are. He talked about Static and Dynamic arrays, I talked about arrays in day 01 ba? I can't remember but it's pretty much the same content except I didn't mention dynamic arrays. Dynamic arrays do not contain a fixed length like static arrays. They are gotten from static arrays. That's the little I can share, there are many examples and codes from the video and in my notebook. But that's today's account. In case you're wondering how I'm able to charge my device, we turn on the generator in my house by 7:00 and before we had our power problem, there was a power surge that spoiled my phone's charger so I can only charge with my laptop and that's really slow. So, I'll be going to the video course once I leave here.
If f(n) = n + n That doesn't mean the Big - O is n^2 ,the big - O is (n) |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:40pm On Jun 04, 2020 |
Predstan:
Its a sparse Matrix with several Zero elements. So i used a List for the elements(non zero) in the Matrix and another class to store the row number, col number and value. So the zero elements does not accupy any space in the ADT. To Multiply two matrices, we first calculate transpose of the second matrix to simplify our comparisons and maintain the sorted order. So, the resultant matrix is obtained by traversing through the entire length of both matrices and summing the appropriate multiplied values. Any row value equal to x in the first matrix and row value equal to y in the second matrix (transposed one) will contribute towards result[x][y]. This is obtained by multiplying all such elements having col value in both matrices and adding only those with the row as x in first matrix and row as y in the second transposed matrix to get the result[x][y]. Storing rows using nested list would have been easy...right now,i haven't think what best algorithm will be better. |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 11:40am On Jun 04, 2020 |
Predstan: i wrote a sparseMatrix ADT implementation. But i am trying to figure out better way to complete the __mul__ implementation. Would you be kind enough to check if there is a better way. Its a long code and works perfectly though but the time-complexity of the __mul__ implementation seems very long.
Here i have the link to the complete code on Github: https://github.com/Predstan/Algorithm-and-Data-Structure/blob/master/ch4/sparseMatrix.py
Can you give worked example of matrix multiplication output you want, because only dot product i can remember now....dont mind me oo |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:30am On Jun 04, 2020 |
|
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:27am On Jun 04, 2020 |
iCode2: You're good, man. Glad it work |
Programming / Re: Data Structures And Algorithms: A Beginner's Journey. by gbolly1151(m): 10:13pm On Jun 03, 2020 |
Following your thread. 1 Like |
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 9:12pm On Jun 03, 2020 |
Guy...this is advance question and it is base on graph data structure,i myself haven't try to solve it but you can give it a try and test your data structure skill
Write a program that builds the routing tables for the nodes in a computer network, based on shortest-path routing, where path distance is measured by hop count, that is, the number of edges in a path. The input for this problem is the connectivity information for all the nodes in the network, as in the following example: 241.12.31.14: 241.12.31.15 241.12.31.18 241.12.31.19
which indicates three network nodes that are connected to 241.12.31.14, that is, three nodes that are one hop away. The routing table for the node at address A is a set of pairs (B,C), which indicates that, to route a message from A to B, the next node to send to (on the shortest path from A to B) is C. Your program should output the routing table for each node in the network, given an input list of node connectivity lists, each of which is input in the syntax as shown above, one per line. |
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 9:01pm On Jun 03, 2020 |
Shepherdd:
Nice one
def reverse(data): if len(data) == 0: return data else: return [data[-1]] + reverse(data[:-1])
or
def reverse(data): return [data[-1]] + reverse(data[:-1]) if len(data) > 0 else data
Good job boss....i will be back with graph question 1 Like |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 8:55pm On Jun 03, 2020 |
iCode2: Hmmm I don't understand that screenshot You are trying to access an invalid command |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 8:48pm On Jun 03, 2020 |
iCode2: For this code:
text = input('Enter a string: ') for i in range(len(text)): if text[i] == a: print(i, end=',')
If i type in 'amalgamate', I'll get the following output: 0,2,5,7,
Question: How can I discard that comma after 7? This my solution might not be best algorithm but it solve it text = 'amalgamate' stop=text.rfind('a') for i in range(len(text)): if text[i] == 'a': if i != stop: print(i,end=',') else:print(i,end='.')
|
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:49pm On Jun 03, 2020 |
iCode2: For this code:
text = input('Enter a string: ') for i in range(len(text)): if text[i] == a: print(i, end=',')
If i type in 'amalgamate', I'll get the following output: 0,2,5,7,
Question: How can I discard that comma after 7? Just seeing this will check |
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 7:30pm On Jun 03, 2020 |
Shepherdd: @ jayphe Collinsanele gbolly1151 kensmoney StevDesmond Please let's roll in more exciting challenges. The thread is winding down. Write a recursive function to reverse a list |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 10:23am On Jun 03, 2020 |
UNDERSTAND isinstance() METHOD USING A SIMPLE QUESTION
if someone ask you "is mr.A from Nigeria?"
the reply is either yes or No i.e True or False that is the same question you are asking whenever isinstance() method is invoked "Is object A from class Z?"
e.g isinstance(1,int) is the same as asking, "is 1 from int?" in which the answer is True |
Programming / Re: Artificial Intelligence And Machine Learning Group by gbolly1151(m): 1:35pm On May 30, 2020 |
Thanks |
Programming / Re: Artificial Intelligence And Machine Learning Group by gbolly1151(m): 8:26am On May 30, 2020 |
Few weeks ago,i pick up deep learning and it seem easy to me, please it is that easy or am getting it wrong? So far,i have been able to understand >>>weight >>>perceptron >>>activation function >>>multi-perceptron >>>feed forward >>>back propagation >>>loss (cost function) >>>optimizer Below is the link to my posts about what i have learnt so far https://www.nairaland.com/5869408With all these,it was easy to go back to ML and start picking the algorithm. I have been able to build a model and tune the hyperparameter. Is there still something am getting wrong,it seem easy than the hype |
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 5:14pm On May 29, 2020 |
DONT HARDCODE SPLIT() FUNCTIONAssuming full name is seperated by space e.g 'john smith', 'issac newton' and you want to split to firstname and lastname fullname = 'john smith' #avoid this name= fullname.split(' ') firstname = name[0] lastname = name[1] print(firstname, lastname)
#pythonic way firstname, lastname = fullname.split(' ') print(firstname,lastname)
|
Programming / Re: Let Learn Artificial Neutral Network by gbolly1151(m): 2:35pm On May 29, 2020 |
gbolly1151: What is Back propagation? To understand back propagation, you need to understand calculus. It is the way of obtaining error in each weight of the network in order to update it. Recall that
Input >>>> Z=weight * input >>>> activation (Z) >>>>> predicted output
If the predicted output is equal to real output,then we need not to update the weight else we will update
Using mean square error(MSE) to find the error, 1/2(sum(real output - predicted output)^2 E = 1/2 sum(Y - PY)^2
To calculate how far weight has contributed to error we find
dE/dw
e.g input = x , output = Y Z= a + bx (b= weight, a=bias) PY = sigmoid (Z)
E = 1/2 sum(Y - PY)^2
Let U = Y - PY dU/dPY = -1 dU/dY = 1
dE/dU = sum(Y - PY)
PY= sigmoid( Z) dPY/dZ = z (1 - z) (activation function derivative)
Z= a + bx dZ/db=x dZ/da = 1
dE/dPY =dE/dU . dU/dPY =sum (Y - PY) - 1 = sum(PY - Y)
dE/db = dE/dPY . dPY/dZ . dZ/db = sum( (PY -Y) * z(1-z) * x) dE/da = dE/dPY . dPY/dZ . dZ/db = sum((PY - Y) * z(1-z))
b = b + lr * dE/db a = a + lr * dE/da
note that lr * dE/db and lr * dE/db are know as gradient decent
learning rate (lr) help to reduce the amount of dE/db to be added in order not to pass real weight (b) that satisfy the equation
This is for simply linear equations,it get complex when we have y = a + b1x1 + b2x2 If not for research purpose,you dont need them and you can proceed to use keras to start building your model since you get overview of the concept... In next update i will post how to build a model using keras |
Programming / Re: Let Learn Artificial Neutral Network by gbolly1151(m): 2:28pm On May 29, 2020 |
What is Back propagation? To understand back propagation, you need to understand calculus. It is the way of obtaining error in each weight of the network in order to update it. Recall that Input >>>> Z=weight * input >>>> activation (Z) >>>>> predicted output If the predicted output is equal to real output,then we need not to update the weight else we will update Using mean square error(MSE) to find the error, 1/2(sum(real output - predicted output)^2 E = 1/2 sum(Y - PY)^2
To calculate how far weight has contributed to error we find
dE/dw
e.g input = x , output = Y Z= a + bx (b= weight, a=bias) PY = sigmoid (Z)
E = 1/2 sum(Y - PY)^2
Let U = Y - PY dU/dPY = -1 dU/dY = 1
dE/dU = sum(Y - PY)
PY= sigmoid( Z) dPY/dZ = z (1 - z) (activation function derivative)
Z= a + bx dZ/db=x dZ/da = 1
dE/dPY =dE/dU . dU/dPY =sum (Y - PY) - 1 = sum(PY - Y)
dE/db = dE/dPY . dPY/dZ . dZ/db = sum( (PY -Y) * z(1-z) * x) dE/da = dE/dPY . dPY/dZ . dZ/db = sum((PY - Y) * z(1-z))
b = b + lr * dE/db a = a + lr * dE/da
note that lr * dE/db and lr * dE/db are know as gradient decent
learning rate (lr) help to reduce the amount of dE/db to be added in order not to pass real weight (b) that satisfy the equation
|
|
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 3:49pm On May 27, 2020 |
PLEASE AVIOD THIS MISTAKE IN YOUR CODE a=1 if a ==3 or 4 or 6: print('yes') else: print('no')
#The answer will always be Yes why?
Let me break it down here
a=1 print(a == 3) # False print(False or 4) # 4 (i.e True) print(4 or 6) # 4 (i.e True)
now
if a == 3 or 4 or 6: # this is equivalent to
if False or True or True: print('yes') else: print('No')
The condition is True so print('yes') will be executed
#solution to the problem a=1 if a in [3,4,6]: print('yes') else: print('no')
|
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 2:57pm On May 27, 2020 |
KEY DIFFERENCE BETWEEN is AND ==is operator is use to check if two object have the same id number == is use to check if two objects have the same value #e.g a=[1,2,3] b=[1,2,3] print(a is b) #output false ''' The above print expression will return false because a and b are two objects with different id number,let check their id '''
print(id(a)) print(id(b))
''' id output is different on different devices,my device print
3066478144 3065959488
'''Since the value are the same,when you use == the output will be True'''
print(a == b) #output True
|
Programming / Re: Let Learn Artificial Neutral Network by gbolly1151(m): 10:31am On May 26, 2020 |
WHAT IS FEEDFORWARD?
When an input move from input layer through hidden layers then to ouput layer,that is feedforward
Input >>> hidden layer >>> output (feedforward operation) |