Affine
10+ Norwich Clinical Services Interview Questions and Answers
Q1. you have a pandas dataframe with three columns, filled with state names, city names and arbitrary numbers respectively. How to retrieve top 2 cities per state. (top according to the max number in the third colu...
read moreRetrieve top 2 cities per state based on max number in third column of pandas dataframe.
Group the dataframe by state column
Sort each group by the third column in descending order
Retrieve the top 2 rows of each group using head(2) function
Concatenate the resulting dataframes using pd.concat() function
Q2. How to retain special characters (that pandas discards by default) in the data while reading it?
To retain special characters in pandas data, use encoding parameter while reading the data.
Use encoding parameter while reading the data in pandas
Specify the encoding type of the data file
Example: pd.read_csv('filename.csv', encoding='utf-8')
Q3. how will the resultant table be, when you "merge" two tables that match at a column. and the second table has many of keys repeated.
The resultant table will have all the columns from both tables and the rows will be a combination of matching rows.
The resultant table will have all the columns from both tables
The rows in the resultant table will be a combination of matching rows
If the second table has repeated keys, there will be multiple rows with the same key in the resultant table
Q4. How to read large .csv files in pandas quickly?
Use pandas' read_csv() method with appropriate parameters to read large .csv files quickly.
Use the chunksize parameter to read the file in smaller chunks
Use the low_memory parameter to optimize memory usage
Use the dtype parameter to specify data types for columns
Use the usecols parameter to read only necessary columns
Use the skiprows parameter to skip unnecessary rows
Use the nrows parameter to read only a specific number of rows
Use the na_values parameter to specify values to...read more
Q5. how does look up happens in a list when you do my_list[5]?
my_list[5] retrieves the 6th element of the list.
Indexing starts from 0 in Python.
The integer inside the square brackets is the index of the element to retrieve.
If the index is out of range, an IndexError is raised.
Q6. what is the purpose of lambda function when regural functions(of def) exist? how are they different?
Lambda functions are anonymous functions used for short and simple operations. They are different from regular functions in their syntax and usage.
Lambda functions are defined without a name and keyword 'lambda' is used to define them.
They can take any number of arguments but can only have one expression.
They are commonly used in functional programming and as arguments to higher-order functions.
Lambda functions are often used for short and simple operations that do not requir...read more
Q7. how to create dictionaries in python with repeated keys?
To create dictionaries in Python with repeated keys, use defaultdict from the collections module.
Import the collections module
Create a defaultdict object
Add key-value pairs to the dictionary using the same key multiple times
Access the values using the key
Example: from collections import defaultdict; d = defaultdict(list); d['key'].append('value1'); d['key'].append('value2')
Q8. explain eign vectors and eign values? what purpose do they serve in ML?
Eigenvalues and eigenvectors are linear algebra concepts used in machine learning for dimensionality reduction and feature extraction.
Eigenvalues represent the scaling factor of the eigenvectors.
Eigenvectors are the directions along which a linear transformation acts by stretching or compressing.
In machine learning, eigenvectors are used for principal component analysis (PCA) to reduce the dimensionality of data.
Eigenvalues and eigenvectors are also used in image processing f...read more
Q9. How do perform the manipulations quicker in pandas?
Use vectorized operations, avoid loops, and optimize memory usage.
Use vectorized operations like apply(), map(), and applymap() instead of loops.
Avoid using iterrows() and itertuples() as they are slower than vectorized operations.
Optimize memory usage by using appropriate data types and dropping unnecessary columns.
Use inplace=True parameter to modify the DataFrame in place instead of creating a copy.
Use the pd.eval() function to perform arithmetic operations on large DataFr...read more
Q10. explain PCA briefly? what can it be used for and what can it not be used for?
PCA is a dimensionality reduction technique used to transform high-dimensional data into a lower-dimensional space.
PCA can be used for feature extraction, data visualization, and noise reduction.
PCA cannot be used for causal inference or to handle missing data.
PCA assumes linear relationships between variables and may not work well with non-linear data.
PCA can be applied to various fields such as finance, image processing, and genetics.
Q11. do we minimize or maximize the loss in logistic regression?
We minimize the loss in logistic regression.
The goal of logistic regression is to minimize the loss function.
The loss function measures the difference between predicted and actual values.
The optimization algorithm tries to find the values of coefficients that minimize the loss function.
Minimizing the loss function leads to better model performance.
Examples of loss functions used in logistic regression are cross-entropy and log loss.
Q12. how does one vs rest work for logistic regression?
One vs Rest is a technique used to extend binary classification to multi-class problems in logistic regression.
It involves training multiple binary classifiers, one for each class.
In each classifier, one class is treated as the positive class and the rest as negative.
The class with the highest probability is predicted as the final output.
It is also known as one vs all or one vs others.
Example: In a 3-class problem, we train 3 binary classifiers: class 1 vs rest, class 2 vs re...read more
Q13. what is one vs one classification?
One vs one classification is a binary classification method where multiple models are trained to classify each pair of classes.
It is used when there are more than two classes in the dataset.
It involves training multiple binary classifiers for each pair of classes.
The final prediction is made by combining the results of all the binary classifiers.
Example: In a dataset with 5 classes, 10 binary classifiers will be trained for each pair of classes.
Q14. what is VIF and how is it calculated?
VIF stands for Variance Inflation Factor, a measure of multicollinearity in regression analysis.
VIF is calculated for each predictor variable in a regression model.
It measures how much the variance of the estimated regression coefficient is increased due to multicollinearity.
A VIF of 1 indicates no multicollinearity, while a VIF greater than 1 indicates increasing levels of multicollinearity.
VIF is calculated as 1 / (1 - R^2), where R^2 is the coefficient of determination fro...read more
Q15. what is AIC & BIC in linear regression?
AIC & BIC are statistical measures used to evaluate the goodness of fit of a linear regression model.
AIC stands for Akaike Information Criterion and BIC stands for Bayesian Information Criterion.
Both AIC and BIC are used to compare different models and select the best one.
AIC penalizes complex models less severely than BIC.
Lower AIC/BIC values indicate a better fit of the model to the data.
AIC and BIC can be calculated using the log-likelihood function and the number of param...read more
Q16. explain generators and decorators in python
Generators are functions that allow you to iterate over a sequence of values without creating the entire sequence in memory. Decorators are functions that modify the behavior of other functions.
Generators use the yield keyword to return values one at a time
Generators are memory efficient and can handle large datasets
Decorators are functions that take another function as input and return a modified version of that function
Decorators can be used to add functionality to existing...read more
Q17. merge vs join in pandas
Merge and join are used to combine dataframes in pandas.
Merge is used to combine dataframes based on a common column or index.
Join is used to combine dataframes based on their index.
Merge can handle different column names, while join cannot.
Merge can handle different types of joins (inner, outer, left, right), while join only does inner join by default.
Q18. what is r squared value
R-squared value is a statistical measure that represents the proportion of the variance in the dependent variable that is predictable from the independent variable(s).
R-squared value ranges from 0 to 1, with 1 indicating a perfect fit.
It is used to evaluate the goodness of fit of a regression model.
A higher R-squared value indicates that the model explains a larger proportion of the variance in the dependent variable.
For example, an R-squared value of 0.8 means that 80% of th...read more
Interview Process at Norwich Clinical Services
Top Data Scientist Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month