September 2018
Beginner to intermediate
178 pages
4h 57m
English
Let's now try to code up the preceding algorithm:
def weather_fit(data): """ Learn the transition and emission probabilities from the given data for the weather model. Parameters ---------- data: 2-D list (array-like) Each data point should be a tuple of size 2 with the first element representing the state of Weather and the second element representing whether it rained or not. Sunny = 0, Cloudy = 1, Windy = 2 Rain = 0, No Rain = 1 Returns ------- transition probability: 2-D array The conditional distribution representing the transition probability of the model. emission probability: 2-D array The conditional distribution representing the emission probability of the model. """ data = np.array(data) transition_counts = np.zeros((3, ...
Read now
Unlock full access