Python for Machine Learning

  1. Download and install Anaconda or the smaller Miniconda.
  2. On Windows open the Start menu and open an Anaconda Command Prompt.
  3. Choose an alias name for your TensorFlow environment, such as “tf”.
  4. conda create -n tf tensorflow
  5. conda activate tf
  6. Or, to install the current release of GPU TensorFlow on Linux or Windows:
  7. conda create -n tf-gpu tensorflow-gpu

how to find files and skip directories in os.listdir?

If you want to filter the directories then:
os.listdir() —> will return the list of all names in a given path.
You can use os.path.isdir() for this:

basic_path = ‘/path/to/directory’
for name in os.listdir(basic_path):
paths = os.path.join(basic_path, name)
if os.path.isdir(paths):
# skip directories
os.walk()–> this function does the same work under the hood and unless you want to recurse down subdirectories

Can you help me with this error: ModuleNotFoundError: No module named ‘cv2’ ?

This error may come if you do not have an opencv installed module in your system.

check the module is available or not.

$ pip list or conda list

If it is not available, then install Opencv

$ pip install opencv-python or conda install opencv-python

But before that, Install numpy module

$ pip install numpy

What is the difference between list and tuple?

1.The main difference between lists and tuples is: lists are mutable whereas tuples are immutable.
2.Implication of iterations is Time-consuming for list
3. Implication of iterations is comparatively Faster for Tuple
4. The list is better for performing operations, such as insertion and deletion.
5.Tuple data type is appropriate for accessing the elements
6. Lists consume more memory
7.Tuple consume less memory as compared to the list

Why is there no do while loop in python?

What is the difference between Python’s list methods append and extend?

There is no do while loop present in python because there is no proper way to define the loop. do…while statement has been rejected because it doesn’t fit in the general format of indented block statement: indented block used by every other Python compound statement.
while True:


if not condition:

Append():This function is used to add new element at the end of the list and increases the length of the list by one.
a= [1,2,3]
print (a)

Extend(): Extend() function appends the elements from iterables at the end of the list. It increases the list by the number of elements present in that iterable argument.
a = [11, 12, 13]
print (a)

1 Like

class MyEmployee:
def init(self,_fname,_lname):
def Display(self):
return self.Fname,self.Lname,self.Email

class Enginners(MyEmployee):

** and == In python you use == to indicate if it is equal to something but if you use = then it will create a variable and if you use ** a power of b
Thank you , @toby

1 Like

Mr. Toby jain List is mutable(can be edited , can be extended),
while tuple cant be extended or appended.
we can address tuple as a fixed list

Sir i am benerplz help me

If you append a list of elements into a new list then it will be appended as single value for example
l = [1,2,3] is your list you want to append a new list l1 = [4,5,6] then it gives list l as [1,2,3,[4,5,6]] the length of the list will be 4. Whereas by using extend l = [1,2,3] and l1 = [4,5,6] extend gives l = [1,2,3,4,5,6] hence length is 6.This is the difference between methods append and extend. I hope this is helpful.

Tuple has this bracket () while list has this []

Is both python for machine learning in english and hindi are same, as i see that some videos from English course are not available in hindi course

list is mutable datatype
where as tuple is immutable data type

1 Like

How can I reverse a list in python without reverse function?