Monday, December 20, 2010

A Tutorial on Dynamic Programming

http://mat.gsia.cmu.edu/classes/dynamic/dynamic.html

A Tutorial on Dynamic Programming

Michael A. Trick

Mini V, 1997

IMPORTANT:This material is provided since some find it useful. It represents course material from the 1990s. I no longer keep this material up to date. Please DO NOT EMAIL ME ON THIS MATERIAL. In particular, I regret that I have no time to clarify material or provide solutions to any of the questions or projects. I am tempted to just remove this material. Please don't abuse my decision to keep this online.





Michael A. Trick
Sun Jun 14 13:05:46 EDT 1998

Statistical Data Mining Tutorials

http://www.autonlab.org/tutorials/

Statistical Data Mining Tutorials

Tutorial Slides by Andrew Moore

Advertisment: In 2006 I joined Google. We are growing a Google Pittsburgh office on CMU's campus. We are hiring creative computer scientists who love programming, and Machine Learning is one the focus areas of the office. We're also currently accepting resumes for Fall 2008 intenships. If you might be interested, feel welcome to send me email: awm@google.com .

The following links point to a set of tutorials on many aspects of statistical data mining, including the foundations of probability, the foundations of statistical data analysis, and most of the classic machine learning and data mining algorithms.

These include classification algorithms such as decision trees, neural nets, Bayesian classifiers, Support Vector Machines and cased-based (aka non-parametric) learning. They include regression algorithms such as multivariate polynomial regression, MARS, Locally Weighted Regression, GMDH and neural nets. And they include other data mining operations such as clustering (mixture models, k-means and hierarchical), Bayesian networks and Reinforcement Learning.

I hope they're useful (and please let me know if they are, or if you have suggestions or error-corrections). Click here for a short list of topics.

  • Decision Trees. The Decision Tree is one of the most popular classification algorithms in current use in Data Mining and Machine Learning. This tutorial can be used as a self-contained introduction to the flavor and terminology of data mining without needing to review many statistical or probabilistic pre-requisites. If you're new to data mining you'll enjoy it, but your eyebrows will raise at how simple it all is! After having defined the job of classification, we explain how information gain (next Andrew Tutorial) can be used to find predictive input attributes. We show how applying this procedure recursively allows us to build a decision tree to predict future events. We then look carefully at a question so fundamental, it is the basis for much of all statistics and machine learning theory: how do you choose between a complicated model that fits the data really well and an "Occam's razor" model that is succinct yet not so good at fitting data (this topic will be revisited in later Andrew Lectures, including "Cross-validation" and "VC-dimension"). We also discuss the very wide world of improvements and tweaks on the basic decision tree idea.
  • Information Gain. This tutorial steps through the ideas from Information Theory that eventually lead to Information Gain...one of the most popular measures of association currently used in data mining. We visit the ideas of Entropy and Conditional Entropy along the way. Look at the lecture on Gaussians for discussion of Entropy in the case of continuous probability density functions.
  • Probability for Data Miners. This tutorial reviews Probability starting right at ground level. It is, arguably, a useful investment to be completely happy with probability before venturing into advanced algorithms from data mining, machine learning or applied statistics. In addition to setting the stage for techniques to be used over and over again throughout the remaining tutorials, this tutorial introduces the notion of Density Estimation as an important operation, and then introduces Bayesian Classifiers such as the overfitting-prone Joint-Density Bayes Classifier, and the over-fitting-resistant Naive Bayes Classifier.
  • Probability Density Functions. A review of a world that you've probably encountered before: real-valued random variables, probability density functions, and how to deal with multivariate (i.e. high dimensional) probablity densities. Here's where you can review things like Expectations, Covariance Matrices, Independence, Marginal Distributions and Conditional Distributions. Once you're happy with this stuff you won't be a data miner, but you'll have the tools to very quickly become one.
  • Gaussians. Gaussians, both the friendly univariate kind, and the slightly-reticent-but-nice-when-you-get-to-know-them multivariate kind are extremely useful in many parts of statistical data mining, including many data mining models in which the underlying data assumption is highly non-Gaussian. You need to be friend with multivariate Gaussians.
  • Maximum Likelihood Estimation. MLE is a solid tool for learning parameters of a data mining model. It is a methodlogy which tries to do two things. First, it is a reasonably well-principled way to work out what computation you should be doing when you want to learn some kinds of model from data. Second, it is often fairly computationally tractable. In any case, the important thing is that in order to understand things like polynomial regression, neural nets, mixture models, hidden Markov models and many other things it's going to really help if you're happy with MLE.
  • Gaussian Bayes Classifiers. Once you are friends with Gaussians, it it easy to use them as subcomponents of Bayesian Classifiers. This tutorial show you how.
  • Cross-Validation. Cross-validation is one of several approaches to estimating how well the model you've just learned from some training data is going to perform on future as-yet-unseen data. We'll review testset validation, leave-one-one cross validation (LOOCV) and k-fold cross-validation, and we'll discuss a wide variety of places that these techniques can be used. We'll also discuss overfitting...the terrible phenomenon that CV is supposed to present. And at the end, our hairs will stand on end as we realize that even when using CV, you can still overfit arbitrarily badly.
  • Neural Networks. We begin by talking about linear regression...the ancestor of neural nets. We look at how linear regression can use simple matrix operations to learn from data. We gurgle with delight as we see why one initial assumption leads inevitably to the decision to try to minimize sum squared error. We then explore an alternative way to compute linear parameters---gradient descent. And then we exploit gradient descent to allow classifiers in addition to regressors, and finally to allow highly non-linear models---full neural nets in all their glory.
  • Instance-based learning (aka Case-based or Memory-based or non-parametric). Over a century old, this form of data mining is still being used very intensively by statisticians and machine learners alike. We explore nearest neighbor learning, k-nearest-neighbor, kernel methods and locally weighted polynomial regression. Software and data for the algorithms in this tutorial are available from http://www.cs.cmu.edu/~awm/vizier. The example figures in this slide-set were created with the same software and data.
  • Eight Regression Algorithms. You'll have to wait to find out Andrew's ordering on them, but based on all the foundations you've covered so far we will quickly be able to run through: Regression Trees, Cascade Correlation, Group Method Data Handling (GMDH), Multivariate Adaptive Regression Splines (MARS), Multilinear Interpolation, Radial Basis Functions, Robust Regression, Cascade Correlation + Projection Pursuit
  • Predicting Real-valued Outputs: An introduction to regression. This lecture is made up entirely from material from the start of the Neural Nets lecture and a subset of the topics in the "Favorite Regression Algorithms" lecture. We talk about linear regression, and then these topics: Varying noise, Non-linear regression (very briefly), Polynomial Regression, Radial Basis Functions, Robust Regression, Regression Trees, Multilinear Interpolation and MARS.
  • Bayesian Networks. The tutorial first reviews the fundamentals of probability (but to do that properly, please see the earlier Andrew lectures on Probability for Data Mining). It then discusses the use of Joint Distributions for representing and reasoning about uncertain knowledge. Having discussed the obvious drawback (the curse of dimensionality) for Joint Distributions as a general tool, we visit the world of clever tricks involving indepedence and conditional independence that allow us to express our uncertain knowledge much more succinctly. And then we beam with pleasure as we realize we've got most of the knowledge we need to understand and appreciate Bayesian Networks already. The remainder of the tutorial introduces the important question of how to do inference with Bayesian Networks (see also the next Andrew Lecture for that).
  • Inference in Bayesian Networks (by Scott Davies and Andrew Moore). The majority of these slides were conceived and created by Scott Davies (scottd@cs.cmu,edu). Once you've got hold of a Bayesian Network, there remains the question of how you do inference with it. Inference is the operation in which some subset of the attributes are given to us with known values, and we must use the Bayes net to estimate the probability distribution of one or more of the remaining attributes. A typical use of inference is "I've got a temperature of 101, I'm a 37-year-old Male and my tongue feels kind of funny but I have no headache. What's the chance that I've got bubonic plague?".
  • Learning Bayesian Networks. This short and simple tutorial overviews the problem of learning Bayesian networks from data, and the approaches that are used. This is an area of active research by many research group, including Andrew and his students (see the Auton Lab Website for more details).
  • A Short Intro to Naive Bayesian Classifiers. I recommend using Probability For Data Mining for a more in-depth introduction to Density estimation and general use of Bayes Classifiers, with Naive Bayes Classifiers as a special case. But if you just want the executive summary bottom line on learning and using Naive Bayes classifiers on categorical attributes then these are the slides for you.
  • Short Overview of Bayes Nets. This is a very short 5 minute "executive overview" of the intuition and insight behind Bayesian Networks. Read the full Bayes Net Tutorial for more information.
  • Gaussian Mixture Models. Gaussian Mixture Models (GMMs) are among the most statistically mature methods for clustering (though they are also used intensively for density estimation). In this tutorial, we introduce the concept of clustering, and see how one form of clustering...in which we assume that individual datapoints are generated by first choosing one of a set of multivariate Gaussians and then sampling from them...can be a well-defined computational operation. We then see how to learn such a thing from data, and we discover that an optimization approach not used in any of the previous Andrew Tutorials can help considerably here. This optimization method is called Expectation Maximization (EM). We'll spend some time giving a few high level explanations and demonstrations of EM, which turns out to be valuable for many other algorithms beyond Gaussian Mixture Models (we'll meet EM again in the later Andrew Tutorial on Hidden Markov Models). The wild'n'crazy algebra mentioned in the text can be found (hand-written) here.
  • K-means and Hierarchical Clustering. K-means is the most famous clustering algorithm. In this tutorial we review just what it is that clustering is trying to achieve, and we show the detailed reason that the k-means approach is cleverly optimizing something very meaningful. Oh yes, and we'll tell you (and show you) what the k-means algorithm actually does. You'll also learn about another famous class of clusterers: hierarchical methods (much beloved in the life sciences). Phrases like "Hierarchical Agglomerative Clustering" and "Single Linkage Clustering" will be bandied about.
  • Hidden Markov Models. In this tutorial we'll begin by reviewing Markov Models (aka Markov Chains) and then...we'll hide them! This simulates a very common phenomenon... there is some underlying dynamic system running along according to simple and uncertain dynamics, but we can't see it. All we can see are some noisy signals arising from the underlying system. From those noisy observations we want to do things like predict the most likely underlying system state, or the time history of states, or the likelihood of the next observation. This has applications in fault diagnosis, robot localization, computational biology, speech understanding and many other areas. In the tutorial we will describe how to happily play with the mostly harmless math surrounding HMMs and how to use a heart-warming, and simple-to-implement, approach called dynamic programming (DP) to efficiently do most of the HMM computations you could ever want to do. These operations include state estimation, estimating the most likely path of underlying states, and and a grand (and EM-filled) finale, learning HMMs from data.
  • VC dimension. This tutorial concerns a well-known piece of Machine Learning Theory. If you've got a learning algorithm in one hand and a dataset in the other hand, to what extent can you decide whether the learning algorithm is in danger of overfitting or underfitting? If you want to put some formal analysis into the fascinating question of how overfitting can happen, then this is the tutorial for you. In addition to getting good understanding of the overfitting phenomenon, you also end up with a method for estimating how well an algorithm will perform on future data that is solely based on its training set error, and a property (VC dimension) of the learning algorithm. VC-dimension thus gives an alternative to cross-validation, called Structural Risk Minimization (SRM), for choosing classifiers. We'll discuss that. We'll also very briefly compare both CV and SRM to two other model selection methods: AIC and BIC.
  • Support Vector Machines. We review the idea of the margin of a classifier, and why that may be a good criterion for measuring a classifier's desirability. Then we consider the computational problem of finding the largest margin linear classifier. At this point we look at our toes with embarassment and note that we have only done work applicable to noise-free data. But we cheer up and show how to create a noise resistant classifier, and then a non-linear classifier. We then look under a microscope at the two things SVMs are renowned for---the computational ability to survive projecting data into a trillion dimensions and the statistical ability to survive what at first sight looks like a classic overfitting trap.
  • PAC Learning. PAC stands for "Probably Approximately Correct" and concerns a nice formalism for deciding how much data you need to collect in order for a given classifier to achieve a given probability of correct predictions on a given fraction of future test data. The resulting estimate is somewhat conservative but still represents an interesting avenue by which computer science has tried to muscle in on the kind of analytical problem that you would normally find in a statistics department.
  • Markov Decision Processes. How do you plan efficiently if the results of your actions are uncertain? There is some remarkably good news, and some some significant computational hardship. We begin by discussing Markov Systems (which have no actions) and the notion of Markov Systems with Rewards. We then motivate and explain the idea of infinite horizon discounted future rewards. And then we look at two competing approaches to deal with the following computational problem: given a Markov System with Rewards, compute the expected long-term discounted rewards. The two methods, which usually sit at opposite corners of the ring and snarl at each other, are straight linear algebra and dynamic programming. We then make the leap up to Markov Decision Processes, and find that we've already done 82% of the work needed to compute not only the long term rewards of each MDP state, but also the optimal action to take in each state.
  • Reinforcement Learning. You need to be happy about Markov Decision Processes (the previous Andrew Tutorial) before venturing into Reinforcement Learning. It concerns the fascinating question of whether you can train a controller to perform optimally in a world where it may be necessary to suck up some short term punishment in order to achieve long term reward. We will discuss certainty-equivalent RL, the Temporal Difference (TD) learning, and finally Q-learning. The curse of dimensionality will be constantly learning over our shoulder, salivating and cackling.
  • Biosurveillance: An example. We review methods described in other biosurveillance slides as applied to hospital admissions data from the Walkerton Cryptosporidium outbreak of 2000. This is work performed as part of the ECADS project.
  • Elementary probability and Naive Bayes classifiers. This slide repeats much of the material of the main Probability Slide from Andrew's tutorial series, but this slide-set focusses on disease surveillance examples, and includes a very detailed description for non-experts about how Bayes rule is used in practice, about Bayes Classifiers, and how to learn Naive Bayes classifiers from data.
  • Spatial Surveillance. This tutorial discusses Scan Statistics, a famous epidemiological method for discovering overdensities of disease cases.
  • Time Series Methods. This tutorial reviews some elementary univariate time series methods, with a focus on using the time series for alerting when a sequence of observations is starting to behave strangely.
  • Game Tree Search Algorithms, including Alpha-Beta Search. Introduction to algorithms for computer game playing. We describe the assumptions about two-player zero-sum discrete finite deterministic games of perfect information. We also practice saying that noun-phrase in a single breath. After the recovery teams have done their job we talk about solving such games with minimax and then alpha-beta search. We also discuss the dynamic programming approach, used most commonly for end-games. We also debate the theory and practice of heuristic evaluation functions in games.
  • Zero-Sum Game Theory. Want to know how and why to bluff in poker? How games can be compiled down to a matrix form? And general discussion of the basics of games of hidden information? Then these are the slides for you. It might help you to begin by reading the slides on game-tree search.
  • Non-zero-sum Game Theory. Auctions and electronic negotiations are a fascinating topic. These slides take you through most of the basic story of the assumptions, the formalism and the mathematics behind non-zero-sum game theory. It might help you to begin by reading the slides on game-tree search and Zero-sum Game theory with Hidden information available from this same set of tutorials. In this tutorial we cover the definition of a multiplayer non-zero-sum game, domination of strategies, Nash Equilibia. We deal with discrete games, and also games in which strategies include real numbers, such as your bid in a two player double auction negotiation. We cover prisoner's dilemma, tragedy of the commons, double auctions, and multi-player auctions such as the first price sealed auction and the second price auction. The math for the double auction analysis can be found at http://www.cs.cmu.edu/~awm/double_auction_math.pdf .
  • Introductory overview of time-series-based anomaly detection algorithms. This simple tutorial overviews some methods for detecting anomalies in biosurveillance time series. The slides are incomplete: verbal commentary from the presentation has not yet been included as explanatory textboxes. Please let me (awm@cs.cmu.edu) know if you would be interested in more detail on these slides and/or access to the software that implements and graphs the various univariate methods. If I receive enough requests I will try to make both of the above available.
  • AI Class introduction. A very quick informal discussion of the different kinds of AI research motivations out there
  • Search Algorithms. What is a search algorithm? What job does it do and where can it be applied? We introduce various flavors of Breadth First Search and Depth First search and then looks at alternatives and improvements that include Iterative Deepening and Bidirectional Search. Then we look with furrowed brow at an idea called Best First Search. This will be our first view of a search algorithm that is able to exploit a heuristic function.
  • A-star Heuristic Search. The classic algorithm for finding shortests paths given an admissible heuristic. We'll deal with the notion of admissibility (summary: admissible = optimistic). We show how you can prove properties of A*. We'll also briefly discuss IDA* (iterative deepening A*).
  • Constraint Satisfaction Algorithms, with applications in Computer Vision and Scheduling. The tutorial teaches concepts from the AI literature on Constraint Satisfaction. Accompanying animations are in http://www.cs.cmu.edu/~awm/animations/constraint. This is a special case of uninformed search in which we want to find a solution configuration for some set of variables that satisfies a set of constraints. Example problems including graph coloring, 8-queens, magic squares, the Waltz algorithm for interpreting line drawings, many kinds of scheduling and most important of all, the deduction phase of minesweeper. The algorithms we'll look at include backtracking search, forward checking search and constraint propagation search. We'll also look at general-purpose heuristics for additional search accelerations.
  • Robot Motion Planning. We review some algorithms for clever path planning once we arrive in real-valued continuous space instead of the safe and warm discrete space we've been sheltering in so far. We look at configuration spaces, visibility graphs, cell-decomposition, voronoi-based planning and potential field methods. Unfortunately some of the figures are missing from the PDF version.
  • HillClimbing, Simulated Annealing and Genetic Algorithms. Some very useful algorithms, to be used only in case of emergency.

NIPS 2010

To get a look at all of the papers in the main conference, look here:
http://books.nips.cc/nips23.html

and a list of the workshops (with papers on the workshop pages):
http://nips.cc/Conferences/2010/Program/schedule.php?Session=Workshops


Bess:

- Learning individual and population level traits from clinical temporal data
https://sites.google.com/site/personalmedmodels/proceedings/Saria.pdf

- Infinite relational modeling of functional connectivity in resting state fMRI
http://books.nips.cc/papers/files/nips23/NIPS2010_1259.pdf


Jeremy:

- A theory of multiclass boosting (best paper award) (good talk)
http://books.nips.cc/papers/files/nips23/NIPS2010_1265.pdf

- Towards Holistic Scene understanding: Feedback enabled cascaded classification models
http://books.nips.cc/papers/files/nips23/NIPS2010_0117.pdf


Chris:

- Spatial and anatomical regularization of svm for brain image analysis
http://books.nips.cc/papers/files/nips23/NIPS2010_0185.pdf

- Learning Kernels with radiuses of minimum enclosing balls
http://books.nips.cc/papers/files/nips23/NIPS2010_0367.pdf


Bryan:

- Improving Human Judgments by Decontaminating Sequential Dependencies
http://books.nips.cc/papers/files/nips23/NIPS2010_0907.pdf

- An Optimization-Based Framework for Combinatorial Prediction Market Design
http://www.cs.umass.edu/~wallach/workshops/nips2010css/papers/abernethy.pdf

- Combining Human and Machine Intelligence for Making Predictions
http://www.cs.umass.edu/~wallach/workshops/nips2010css/papers/nagar.pdf

- Tree Structured Stick Breaking for Hierarchical Data
http://books.nips.cc/papers/files/nips23/NIPS2010_0146.pdf

Wednesday, December 15, 2010

Python Interview Questions and Answers 3

Ah, that makes more sense. Well, look over the socket module, and familiarize yourself with general socket programming. When I test specifically on Python knowledge, here are the general modules that I cover (along with general Python semantics - duck typing, list comprehensions, immutable versusmutable, etc):
sys, os, time, re, string, random, threading, socket, os.path, and types. These are, in descending order, the most commonly occuring modules in the Python package.

Overviewing http://www.diveintopython.org/ may be a good idea too; it tends to focus on Python specific idioms, which will most likely be the focus of the test.

# Re: How to make composited software?
Hello,

1) Study these guides (notes) here:
http://ubuntuforums.org/showthread.p...18#post3627418

Note 5) has links to OpenGL, SDL and other guides.
Install Code::Blocks IDE if you like but Anjuta, KDevelop or bare command line are equally fine.

2) Learn to program with C or C++ and Cairo graphics.
Cairo is a must to know.
http://cairographics.org/samples/

3) Download this MacSlow's Cairo-clock and study the source code.
http://macslow.thepimp.net/?page_id=23

Study also the source code of Avant Window Navigator.

You could try Bruce Eckel's free Thinking in C++ book. It's not for complete newbie programmers, but it teaches correct C++ AFAIK.

# Python Interview Questions and Answers

http://ronak15.blogspot.com/2009/05/python-interview-questions-and-answers.html

Hi Everybody,

As always interview questions but this time I was lucky to be interviewed for Python, which I had recent experience on. And the interviewer was great. He told me that he had pretty much fundamental and short questions to ask and he joked about MS interviewees will be joyed with this kind of interview process.

This was basically a python position but this made me feel why people cannot do with other programming language experts for python because a python programmer is really way too different than a C++ or Java programmer. Since I am a C++ programmer with recent experience in Python, I was considered for the position. It was fun going through the interview since it was web conference coding interview.

What I had gone through was the LinuxCBT edition of python which helped me a lot. If I had not referred that I would have done miserably.

I had tried searching for python questions over the internet but was not too lucky since I got only a few of them which made sense. Some of them were asked but restricting to just a couple of them. So I think my questions and answers will really help people to get a good idea on what can be asked for python interviews and also for people who are getting interviewed on python. I really appreciate comments and improvements on the questions and answers.

Hope the information helps.....


1. Name five modules that are included in python by default

2. Name a module that is not included in python by default

3. What is __init__.py used for?

4. When is pass used for?

5. What is a docstring?

6. What is list comprehension?

7. What is map?

8. What is the difference between a tuple and a list?

Ans. This is the most frequently asked question on python.

A tuple is a list that is immutable. A list is mutable i.e. The members can be changed and altered but a tuple is immutable i.e. the members cannot be changed.

Other significant difference is of the syntax. A list is defined as

list1 = [1,2,5,8,5,3,]
list2 = ["Sachin", "Ramesh", "Tendulkar"]

A tuple is defined in the following way

tup1 = (1,4,2,4,6,7,8)
tup2 = ("Sachin","Ramesh", "Tendulkar")

So the difference is in the type of brackets.


Coding questions

9. Using various python modules convert the list a to generate the output 'one, two, three'
a = ['one', 'two', 'three']

10. What would the following code yield?

  word = 'abcdefghij'
print word[:3] + word[3:]
Ans. This will print the word 'abcdefghij'

11. Optimize these statements as a python programmer
word = 'word'
print word.__len__()

12. Write a program to print all the contents of a file

Ans.
  try:
f1=open("filename.txt","r")
except Exception, e:
print "%s" %e

print f1.readlines()

13. What will be the output of the following code
a = 1
a,b=a+1,a+1
print a
print b

Ans.

2
2

Here in the second line a,b=a+1,a+1 means that a=a+1 and b=a+1 which is 2. But this is the python way of initialization which a python programmer should understand.

14. Given the list below remove the repetition of an element. All the elements should be unique
words = ['one', 'one', 'two', 'three', 'three', 'two']


15. Iterate over a list of words and use a dictionary to keep track of the frequency(count) of each word. for example
{'one':2,'two':2,'three':2}

16.Write the following logic in Python:
If a list of words is empty, then let the user know it's empty, otherwise let the user know it's not empty.

Ans.
a=[]
if len(a):
print"The list is empty"
else:
print"The list is not empty"


The will not work but me being a c++ programmer, I would not code it this way, I would have coded the following way

a=[]
if len(a) == 0:
print"The list is empty"
else:
print"The list is not empty"

This works but the above implementation does not. Can somebody tell me what is wrong with the above code. Because the interviewer told me that a python programmer would code it that way rather than my way. That was a good lesson. When you code in python, you tend to demonstrate your background with such mistakes. :D

17. Demonstrate the use of exception handling in python.
Ans.

a=[1,2,3,4]
try:
print a[0]
except Exception, e # This was important. Just do not say except: and print out something. It is
print e # Important to know what is the error

This could also have been better. If somebody knows a better way than the above code, I would really appreciate it.

18. Print the length of each line in the file 'file.txt' not including any whitespaces at the end of the lines.
f1=open("filename.txt","r")
leng=f1.readline()
print len(leng) -1, "is the length of the string"

Since the last character is a whitespace we deduct 1 out of the length returned by the len() function.

19. Print the sum of digits of numbers starting from 1 to 100
Ans. print sum(range(1,100))

This is way too easy but just who know python. Since I am a C++ Programmer, I started writing a for loop to add up which was way too dumb. Hope you don't make this mistake.

Python is known for it short syntax and easy to use functions.

20. Create a new list that converts the following list of number strings to a list of numbers.
num_strings = ['1','21','53','84','50','66','7','38','9']

Ans.

This one is pretty much easy but not at first. It took me a good half and hour to figure out that it was so easy.

num = [] # This is the new list which will contain all integers instead of the strings
n = len(num_strings) # This will give the length of the list
for i in range(0,n):
num.insert(i,int(a[i]))
print num

21. Create two new lists one with odd numbers and other with even numbers
num_strings = [1,21,53,84,50,66,7,38,9]

  n = len(num_strings)
ceven,codd = 0, 0
odd,even = [],[]

for i in range(0,n):
if num_strings[i]%2 == 0:
even.insert(ceven,num_strings[i])
ceven = ceven + 1
else:
odd.insert(codd,num_strings[i])
codd = codd + 1
print odd
print even


22. Write a program to sort the following intergers in list
nums = [1,5,2,10,3,45,23,1,4,7,9]

nums.sort() # This is the quickest sorting algorithm. This is the best possible way to sort.
print nums

23. Write a for loop that prints all elements of a list and their position in the list.

abc = [4,7,3,2,5,9]
n = len(abc)
for i in range(0,n):
print i+1,"-->", abc[i]

OUTPUT

1 --> 4
2 --> 7
3 --> 3
4 --> 2
5 --> 5


24. The following code is supposed to remove numbers less than 5 from list n, but there is a bug. Fix the bug.
n = [1,2,5,10,3,100,9,24]

for e in n:
if e<5:
n.remove(e)
print n

Ans. The output here will be

[2,3,5,10,100,9,24] which means the 1st and the 5th elements are removed. That is surprising to me. If anybody has an idea on what could be the explanation, I will really appreciate it.

25. What will be the output of the following
def func(x,*y,**z):
print z

func(1,2,3)
Ans.
Here the output is :
{}

If I print all the variables, namely x, y and z it yeilds me this
1 (2,3) {}
so that means that x is 1, that is normal, but I do not understand the reason why y and z yeilds surprising outputs. If anybody can point it out then I would really appreciate it


26. Write a program to swap two numbers.
a = 5
b = 9

def swap(c,d):
return d,c

swap(a,b)

This will print the swapped values of a and b

(9,5)

OR if this does not seem convincing,

a, b = 5, 10

t = a
a=b
b=t

print a,b

27. What will be the output of the following code

class C(object):
def__init__(self):
self.x =1

c=C()
print c.x
print c.x
print c.x
print c.x

Ans.

All the outputs will be 1

1
1
1
1

28. What is wrong with the code

func([1,2,3]) # explicitly passing in a list
func() # using a default empty list

def func(n = []):
#do something with n

print n

Ans. I tried running the code with my addition of printing the value of n in the function and found out the following result

func([1,2,3]) resulted in [1,2,3]
while func() resulted in []

29. What all options will work?

a.

n = 1
print n++

b.

n = 1
print ++n

c.

n = 1
print n+=1

d.

int n = 1
print n = n+1

e.

n =1
n = n+1

From the above options I believe the following will work

b. and e.

There are some problems with a, c and d.

if you try running the code in a , it does not accept n++ but it accepts ++n

n+=1 is not accepted while in d the variable is preceded by an int which is not pythonically correct.

30. In Python function parameters are passed by value or by reference?

Ans. Please refer to this


31.Remove the whitespaces from the string.

s = 'aaa bbb ccc ddd eee'

Ans.

a = string.split(s)
print a
['aaa', 'bbb', 'ccc', 'ddd', 'eee'] # This is the output of print a

print string.join(a)
aaa bbb ccc ddd eee # This is the output of print string.join(a)

32. What does the below mean?

s = a + '[' + b + ':' + c + ']'

33. Optimize the below code

def append_s(words):
new_words=[]
for word in words:
new_words.append(word + 's')
return new_words

for word in append_s(['a','b','c']):
print word

The above code adds a trailing s after each element of the list. Is there a better way one can write the above script?

34. If given the first and last names of bunch of employees how would you store it and what datatype?

Ans. Either a dictionary or just a list with first and last names included in an element.

Python Interview Questions and Answers 2

Basic Python:
=============
- do they know a tuple/list/dict when they see it?

- when to use list vs. tuple vs. dict. vs. set

- can they use list comprehensions (and know when not to abuse them? :)

- can they use tuple unpacking for assignment?

- string building...do they use "+=" or do they build a list and use .join() to recombine them efficiently

- truth-value testing questions and observations (do they write "if x == True" or do they just write "if x")

- basic file-processing (iterating over a file's lines)

- basic understanding of exception handling

Broader Basic Python:
=====================
- questions about the standard library ("do you know if  there's a standard library for doing X?", or "in which
library would you find [common functionality Y]?") Most of these are related to the more common libraries such as
os/os.path/sys/re/itertools

- questions about iterators/generators

- questions about map/reduce/sum/etc family of functions

- questions about "special" methods (__<foo>__)

More Advanced Python:
=====================
- can they manipulate functions as first-class objects (Python makes it easy, but do they know how)

- more detailed questions about the std. libraries (such as datetime/email/csv/zipfile/networking/optparse/unittest)

- questions about testing (unittests/doctests)

- questions about docstrings vs. comments, and the "Why" of them

- more detailed questions about regular expressions

- questions about mutability

- keyword/list parameters and unpacked kwd args

- questions about popular 3rd-party toolkits (BeautifulSoup, pyparsing...mostly if they know about them and when to use them, not so much about implementation details)

- questions about monkey-patching

- questions about PDB

- questions about properties vs. getters/setters

- questions about classmethods

- questions about scope/name-resolution

- use of lambda

Python History:
===============
- decorators added in which version?

- "batteries included" SQL-capible DB in which version?

- the difference between "class Foo" and "class Foo(object)"

- questions from "import this" about pythonic code

Python Resources:
=================
- what do they know about various Python web frameworks (knowing a few names is usually good enough, though  knowledge about the frameworks is a nice plus) such as
Django, TurboGears, Zope, etc.

- what do they know about various Python GUI frameworks and the pros/cons of them (tkinter, wx, pykde, etc)

- where do they go with Python related questions (c.l.p, google, google-groups, etc)

Other Process-releated things:
==============================
- do they use revision control (RCS/CVS/Subversion/Mercurial/Git...anything but VSS) and know how to use it well

- do they write automated tests for their code

Touchy-feely things:
====================
- tabs vs. spaces, and their reasoning

- reason for choosing Python

- choice of editor/IDE

Tuesday, December 14, 2010

KDD-2011

17th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD-2011)
August 21-24, 2011
Manchester Grand Hyatt
San Diego, CA

http://www.kdd.org/kdd2011/

Key Dates:
Abstracts due: February 11, 2011
Papers due: February 18, 2011
Acceptance notification: May 13, 2011

Paper submission and reviewing will be handled electronically. Authors should consult the conference Web site for full details regarding paper preparation and submission guidelines.

Papers submitted to KDD 2011 should be original work and substantively different from papers that have been previously published or are under review in a journal or another peer-reviewed conference.

RESEARCH TRACK:
We invite submission of papers describing innovative research on all aspects of knowledge discovery and data mining. Examples of topic of interest include (but are not limited to): classification and regression methods, semi-supervised learning, clustering, feature selection, social networks, mining of graph data, temporal and spatial data analysis, scalability, privacy, visualization, text analysis, Web mining, recommender systems, and so on. Papers emphasizing theoretical foundations are particularly encouraged, as are novel modeling and algorithmic approaches to specific data mining problems in scientific, business, medical, and engineering applications. We welcome submissions by authors who are new to the KDD conference, as well as visionary papers on new and emerging topics. Authors are explicitly discouraged from submitting papers that contain only incremental results and that do not provide significant advances over existing approaches.

Submitted papers will be assessed based on their novelty, technical quality, potential impact, and clarity of writing. For papers that rely heavily on empirical evaluations, the experimental methods and results should be clear, well executed, and repeatable. Authors are strongly encouraged to make data and code publicly available when possible.

INDUSTRIAL TRACK:
The Industrial/Government Applications Track solicits papers describing implementations of KDD solutions relevant to industrial or government settings. The primary emphasis is on papers that advance the understanding of practical, applied, or pragmatic issues related to the use of KDD technologies in industry and government and highlight new research challenges arising from attempts to create such real KDD applications. Applications can be in any field including, but not limited to: e-commerce, medical and pharmaceutical, defense, public policy, engineering, manufacturing, telecommunications, and government.

The Industrial/Government Applications Track will consist of competitively-selected contributed papers. Submitters must clearly identify in which of the following three sub-areas their paper should be evaluated as distinct review criteria will be used to evaluate each category of submission.

  • Deployed KDD systems that are providing real value to industry, Government, or other organizations or professions. These deployed systems could support ongoing knowledge discovery or could be applications that employ discovered knowledge, or some combination of the two.
  • Discoveries of knowledge with demonstrable value to Industry, Government, or other users (e.g., scientific or medical professions). This knowledge must be "externally validated" as interesting and useful; it can not simply be a model that has better performance on some traditional KDD metric such as accuracy or area under the curve.
  • Emerging applications and technology that provide insight relevant to the above value propositions. These emerging applications must have clear user interest and support to distinguish them from KDD research papers, or they must provide insight into issues and factors that affect the successful use of KDD technology and methods. Papers that describe infrastructure that enables the large-scale deployment of KDD techniques also are in this area.

ICDE PODS SIGKDD

  • [ICDE] International Conference on Data Engineering: Data Engineering deals with the use of engineering techniques and methodologies in the design, development and assessment of information systems for different computing platforms and application environments. The International Conference on Data Engineering provides a premier forum for sharing and exchanging research and engineering results to problems encountered in today's information society.
  • [PODS] Principles of Database Systems: PODS, the Symposium on Principles of Database Systems, is the premiere international conference on the theoretical aspects of database systems. PODS was started in 1982. It is consponsored by three ACM Special Interest Groups: SIGACT (theoretical computer science), SIGART (Artificial Intelligence), and SIGMOD. Since 1991, PODS has been held jointly with the SIGMOD conference, combining in one place the full spectrum of database research, from the most abstract and fundamental to the most pragmatic.
  • [SIGKDD] Special Interest Group of Knowledge Discovery and Data Mining: The primary focus of the SIGKDD is to provide the premier forum for advancement and adoption of the "science" of knowledge discovery and data mining.
  • [SIGMOD] Special Interest Group on Management of Data: The annual ACM SIGMOD conference is a leading international forum for database researchers, developers, and users to explore cutting-edge ideas and results, and to exchange techniques, tools, and experiences. The PODS symposium series, held in conjunction with the SIGMOD conference series, provides a premier annual forum for the communication of new advances in the theoretical foundation of database systems.
  • [VLDB] Very Large Databases: Very Large Data Base Endowment Inc. (VLDB Endowment) is non-profit organisation incorporated in the United States for the sole purpose of promoting and exchanging scholarly work in databases and related fields throughout the world.

Machine Learning Resources

From ==>> http://home.earthlink.net/~dwaha/research/machine-learning.html#software

Machine Learning Resources

Suggestions welcome
Applications | Bibliographies | Books | Commercial | Conference Announcements | Courses | Data Repositories | Home Pages | Humor | Information | Journals & Special Issues | Mailing Lists | Mirrors | ML Search Engines | Publication Search Engines | Research Groups | Software | Special Interest Groups | Tutorials

Applications (related to ML)

Bibliographies (surely this is incomplete!)

Books

Commercial

Conference Announcements

Courses on Machine Learning

Data Repositories

Home Pages

Humor

Information

Applications | Artificial Life | Belief Nets | Competitions | COLT | Constraint-Based Reasoning | Design | Ensembles and Mixture Models | Evaluation | Fraud Detection | Fuzzy Logic | Games | General ML Resources Pages | Genetic Algorithms | Human-Computer Learning | Inductive Logic Programming | Information Retrieval | Kernel Methods | Knowledge Acquisition | KDD | Knowledge Engineering | Lazy Learning | Link Analysis | Local Learning | Manufacturing | Medicine | Minimum Description & Message Length | Multi-Agent Learning | Natural Language | Neural Networks | Ontologies | Planning | Representation | Robots | Rough Sets | Skill Acquisition | Support Vector Machines | Temporal Processing | Text Processing | Unsupervised Learning WWW

Journals & Special Issues

Mailing Lists

Mirrors

ML Search Engines

Publication Search Engines

Research Groups

Software (see also Information)

Special Interest Groups

Tutorials (and short notes)