I've seen the AI be smart and be stupid about it. In one game, almost everyone on the biggest continent picked the same ideology as the person with the highest culture (Freedom). In the same game, my biggest trading partner picked the same ideology as me because we were such good friends.
And in the same game? Babylon picked Autocracy.
And in the same game? Babylon picked Autocracy.