-1

I'm new in programming Blockchain. I want to make a smart contract with machine learning, a simple case. I know how to create a solidity contract, but I do not know how to add learning to the contract. Does anyone have any ideas?

1

Machine Learning usually takes a lot of processing power and memory. Blockchain costs a lot for any processing power or memory. I would create smart contracts that do minimal processing and data collection from the blockchain and offload everything CPU and memory intensive via web3, web3j or some other off-chain API to a traditional server.

1

I'll throw the question back at you. Why would you implement "machine learning" in a smart contract?

The majority of the machine learning models right now have a pipeline that looks like the following:

  1. Preprocess the data. This operation is unsuitable to do in a smart contract due to the high transaction costs and speed. One could consider adding the final dataset to the blockchain, but there is no benefit from that. Let alone the transaction costs for uploading the data to the blockchain. It would be much more suitable to store it on IPFS if you want free distribution of data that are immutable.
  2. Train the model: Again it would be crazy to train using a smart contract given the lack of support for linear algebra. Imagine that our local computers run high performant linear algebra libraries in Fortran or C that have been developed and maintained for decades. You could consider storing the model on the blockchain and save other people the effort and the time to train it again.
  3. Run the model: This depending on the model could be viable, but again the lack of Linear-Algebra libraries would probably make it prohibitively costly to develop.

Take my answer with a grain of salt as the area is developing at a fast pace. Personally, I dont see the reason to use blockchain in machine learning right now. Hopefully, someone smarter than me will come to prove me wrong.

P.S. Check Open Minded that do privacy enhancing decentralized machine learning using differential privacy and secure MPC. However, this is a different beast

  • Thanks for answering! My idea is to use Artificial Intelligence in Ethereum, and I had opted for machine learning. Possibly, if the contract is only responsible for making requests to a server would be more feasible and would leave all the logical process to the server. – Elvis Suarez Jul 12 '18 at 14:22
  • 1
    @ElvisSuarez again you need to elaborate on that. Since a server exists which is a point of centralization (centralization is not an inherently bad thing ), why not let the users contact the server directly. What you say is technically possible with Oraclize. Deep down my point is similar to this. – davinci26 Jul 12 '18 at 17:17
  • Thanks again, it would be more convenient to centralize everything in a server and ready, but for a subject of the faculty I must mix both concepts, although I understand that I must delve into the subject, greetings – Elvis Suarez Jul 13 '18 at 2:10
1

You would have to define the smart contracts yourself. While Solidity or Smart Contracts were not meant to used for Machine Learning, here is an interesting incentive for using smart contracts- they let you easily assess the efficiency of a process. But given the fact that we have Python for Machine learning, a language which boast of such a powerful library like Scikit-Learn, one would be hard-pressed to do it.

That being said, Using Solidity and Smart Contracts to test out Machine Learning Concepts isn't a bad idea.

Not the answer you're looking for? Browse other questions tagged or ask your own question.