Billionaire investor Mark Cuban told CNBC on Tuesday he started buying Twitter after the company got its act together on artificial intelligence. Twitter shares closed up nearly 4 percent Tuesday after Cuban's comment. (Source: FactSet.) In an interview on "Squawk Alley," the "Shark Tank" judge said he's been buying into companies that work in AI, deep learning and machine learning. "I started buying Twitter recently because I think they finally got their act together with artificial intelligence," he said at BTIG's 15th annual charity day in New York.

The remarks by Cuban came six days after Twitter reported better-than-expected first-quarter earnings. The social media company has used algorithms to combat user harassment, vowing to prevent abusive behavior and block repeat offenders from the site. They've also used machine learning to tailor ads and tweets to users. Twitter said in its first-quarter earnings release, it "continued to use other machine learning techniques to improve the relevance of notifications, which increased engagement and brought people back to Twitter." In March, Chief Executive Jack Dorsey said the impact of AI on society would be "positive," but he appeared unsure if the U.S. government is ready to deal with the impact. "I don't know. I think so, I hope so. But if they (government) are not we are certainly going to help because it is a technology that is important, it is a trend that we need to see more of and it does help people," Dorsey told CNBC.

Twitter machine learning for ads