Posts

Python data science questions- Basic

1) randomly select an element from list- import random foo = [ 'a' , 'b' , 'c' , 'd' , 'e' ] print ( random . choice ( foo )) 2) Package to control key board and mouse in python- Pynput 3) Package to interact with web pages in Python- Selenium, webbrowser 4) Package for creating API is python -Flask

open multiple sites in python Script using web browser package

including required packages- ! pip install random ! pip install webbrowser import random import webbrowser import os adding multiple sites in a list- ls=['/2016/08/business-analytics-on-sales-data-of.html', '/recommendation-engine-market-basket.html', '/2016/08/optimizing-e-commerce-site-using.html'    ,'/2016/08/8-simple-ways-to-increse-your-blog.html', '/2016/08/business-analytics-on-sales-data-of.html',    '/2017/12/gaussian-state-space-model-in-r-using.html', '/2017/09/assumptions-of-linear-regression.html',    '/2017/09/neural-network-forward-propagation-in.html', '/2018/06/lda-linear-discriminant-analysis-where.html',    '/2018/10/religious-demographics-of-india-in.html', '/2020/04/forecasting-total-deaths-from.html',    '/2019/11/automatic-ticket-resolution-for.html', '/2019/09/sentiment-analysis-using-nltk-and.html', '/2019/07/deep-learning-with-h2o-in-py...

Automatically open and do some actions on web pages in python using different packages

1) Automatically open web url using Selenium- get chrome driver from here- https://chromedriver.storage.googleapis.com/index.html?path=80.0.3987.106  place the chrome driver in user/username/bin location from selenium import webdriver browser = webdriver.Chrome(executable_path = '/Users/abcarp/bin/chromedriver') browser.get('https://in.linkedin.com/') sleep(10) browser.close() 2) Automatically login to Linkedin and do some action using selenium- from selenium.webdriver.common.keys import Keys      # url of LinkedIn  url = "https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin"   # path to browser web driver  driver = webdriver.Chrome( '/Users/esisarp/bin/chromedriver')       driver.get(url)  # getting the user-name element username = driver.find_element_by_id("username")   # Sending the keys for username        username.s...

Explainability in Data Science:- Data, Model & Prediction

Image
XAI( Explainable AI  ) is grabbing lime-light in machine learning. How can we be sure that image classification algo is learning faces not background ? Customer wants to know why loan is disapproved? Globally important variable might not be responsible/ imp for individual prediction. Here XAI comes to rescue- We have taken data from  classification_data This has some sensor values and an output class.  A) Data Explainability - what are the basic understanding required from data perspective.  1)       Identify missing values, co-linear feature, feature interaction, zero importance feature, low important feature, single value feature and handle missing values, remove/ handle features accordingly. 2)       Missing values- no missing values from data description 3)       No good correlation between variables- can be seen from correlation plots 4)    ...

Auto Reload Python package after making changes in it.

autoreload IPython extension to reload modules before executing user code. autoreload reloads modules automatically before entering the execution of code typed at the IPython prompt. % load_ext autoreload % autoreload 2 from foo import some_function some_function () Out[4]: 42 # open foo.py in an editor and change some_function to return 43 some_function () Out[6]: 43 https://ipython.org/ipython-doc/3/config/extensions/autoreload.html

Speech Recognition using PyAudio and SpeechRecognition Libraries

This is simple program to convert audio into text. I have used speec_recognition library to do it. import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source:     print("Speak Anything :")     audio = r.listen(source)     try:         text = r.recognize_google(audio)         print("You said : {}".format(text))     except:         print("Sorry could not recognize what you said") Output- Speak Anything : You said : internet is required to access the Google API if there is no internet you will not be able to convert voice into text to install SpeechRecognition- https://pypi.org/project/SpeechRecognition/ one of the dependencies is PyAudio which is not supported after 3.6. For python verison 3.6+ one needs to download wheel (  https://python101.pythonlibrary.org/chapter39_wheels.html )  and install PyAudio separately. https://sta...