Choose a random starting word for building markov chain

0 votes
I have a python code that uses the markov chain to generate sentences. I have defined two starting words but I want the first one to be chosen randomly. Is this possible? If yes, how do I achieve it?
Aug 2, 2019 in Machine Learning by Greg
625 views

1 answer to this question.

0 votes

Hey @Greg, this is possible. You can use the random function. It will choose random numbers/words from the list or in this case, dictionary.

import random
previous[0] = random.choice(Map.keys())
answered Aug 2, 2019 by Bhavya

Related Questions In Machine Learning

0 votes
1 answer

How to simulate first passage time probability in python for a random walk?

To begin with, you're now computing fp ...READ MORE

answered Apr 5, 2022 in Machine Learning by Dev
• 6,000 points
1,551 views
0 votes
1 answer

Markov chain using processing - Python

Try something like this @Gujjar HashMap<String, int> wordCount; int ...READ MORE

answered Aug 2, 2019 in Machine Learning by Ashish
849 views
0 votes
0 answers
0 votes
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,362 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP