Why are most machine learning models (not frameworks) written in Python? Even through almost any programming language can be used for machine learning?

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    33 minutes ago

    My impression from what code I’ve looked at is that little computation is done by the Python code itself, so there’s little by way of gains to be had by trying to use something higher-performance, which eliminates a lot of the reason one would use some other languages.

    Python’s cross-platform, albeit with a Unix heritage, so it doesn’t create barriers there. It’s already widely-used, a mature language that isn’t going anywhere and with a lot of people who know it.

    It’s got an ecosystem for distributing libraries over the network, and there’s a lot of new code going out and being distributed rapidly.

    Python isn’t statically-typed. Static typing can help write more-robust code. If you’re writing, say, the next big webserver, I’d want to have that checking. But for code that may often be running internally in a research project — and this is an area with a lot of people doing research — a failure just isn’t that big a deal. So, again, some of the reasons that one might use another language aren’t there.

    And I imagine that there’s also inertia. Easier to default to use what others would use.

    If you have another language in mind, you might mention that, see if there might be more-specific things. I could come up with more meaty plausible guesses if what you were wondering is something like “why isn’t everyone using SmallTalk?” or something.

    • Overspark@piefed.social
      link
      fedilink
      English
      arrow-up
      8
      ·
      2 hours ago

      Yeah this. Python was already popular with the early adopters, and it’s a fairly easy language to learn and use. After that it became a network effect thing: all the best tools were already written in Python so people continued to do so.

      • TehPers@beehaw.org
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 hour ago

        Also a lot of data scientists aren’t really programmers. They just learned Python to do data science. Learning a new language for this purpose would be both very difficult and, in their eyes, often unnecessary.

        • tal@lemmy.today
          link
          fedilink
          English
          arrow-up
          3
          ·
          26 minutes ago

          I once had dinner with a Stanford professor, years back, who was talking about the fact that he liked teaching in Python because he spent way less time teaching the language and more the higher level stuff that he was actually trying to get across than when he was using C++. Lower barrier to entry for new users. I’d guess that probably in the intervening years, a lot of classes have decided to use it for similar reasons. If you want to teach, I dunno, signal processing and your students maybe don’t have a great handle on the language yet, you want to be spending time on the signal processing stuff, not on language concepts.