Recent

Author Topic: artificial intelligence, machine learning libraries for Delphi/FreePascal?  (Read 24575 times)

tatamata

  • Hero Member
  • *****
  • Posts: 787
    • ZMSQL - SQL enhanced in-memory database
Are there any libraries or code collections with various AI/machine learning algorithms available for Pascal (Delphi, FPC; Lazarus...)?


tatamata

  • Hero Member
  • *****
  • Posts: 787
    • ZMSQL - SQL enhanced in-memory database
Hi, Avra and thank you for the links.
However, it seems to be very sparse?
Is there anything near complete and extensive as e.g. sci-kit learn (sklearn) for python: http://scikit-learn.org/stable/ ?

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
You might also want to consider the Conscious Artificial Intelligence project.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Is there anything near complete and extensive as e.g. sci-kit learn (sklearn) for python
Not that I know. Converting it to Pascal is possible but one needs to be really motivated to start such big job. Depending on the problem, if I were you I would probably choose some fusion of neural networks combined with fuzzy logic. Or use Matlab and it's IEC 61311-3 ST code generator (ST is Structured Text, primitive Pascal variant used with programmable logic controllers). Output must be adapted for FPC but it is usable enough to think about it. Matlab C codegen is another option. Writing some glue code to talk to your FPC application shouldn't be to complex.
« Last Edit: May 18, 2016, 09:59:39 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

schuler

  • Full Member
  • ***
  • Posts: 223
So cool to find my own project commented here by jwdietrich: Conscious Artificial Intelligence . Thank you.

In the case that you would like to use my neural network API, I've added plenty of comments and some examples:

https://github.com/joaopauloschuler/neural-api

This API has been mainly developed for Lazarus/FPC but plenty of its units also compile with Delphi.

 :) Have fun  :)
« Last Edit: September 27, 2019, 12:42:06 am by schuler »

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
@schuler: Hi I've downloaded the repo and made some patchches so that it's compatible to my system
If you like you could move the bin and data-folder up one level ...
Tha patch was too big (~500K) so I had to compress it ...
Have fun.
 
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

schuler

  • Full Member
  • ***
  • Posts: 223
:) Hello jc99 :)

I can see on your patch that you've changed some weights (loved to find that you've tried):
-SOM.FatorDeCorrecao:=1;
+SOM.FatorDeCorrecao:=3.5;

Does the above improve the example in your opinion?

Some of the code is older than 20 years. We might have bits and pieces that are 30 years old... Anyway, I have been translating variable names, methods and comments to English for the past few years.

What code reformatting tool have you used? I might end using the same tool.

When you said that you had to change folder structure.... Huuummm... I'm able to compile in 3 environments out of the box: 2 environments are windows and 1 environment is linux. I'm also able to crosscompile the libs folder to Android with lamw (watched NN running on Android few days ago and loved). I'll add Android specific work soon.

I wonder if the folder problem is related to the SVN url I check in:
svn+ssh://<user>@svn.code.sf.net/p/cai/svncode/trunk

I noticed also that you've made some user interface changes (UI isn't my strong):
-      Orientation = pbVertical
+      Orientation = pbTopDown

Is there any other change that isn't reformatting in the code?

 :)  Happy Coding  :),
JPSS

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
:) Hello jc99 :)

I can see on your patch that you've changed some weights (loved to find that you've tried):
-SOM.FatorDeCorrecao:=1;
+SOM.FatorDeCorrecao:=3.5;

Does the above improve the example in your opinion?
I have doubled the Neurons in each direction (20x20)
and Ended up mostly with a result when one edge is rotatet to the rest.
by updateting the factor it happens less.

BTW: with (40x40) I almost never get a good result.
Though the results are somehow interesting from an artists point of view.

Some of the code is older than 20 years. We might have bits and pieces that are 30 years old... Anyway, I have been translating variable names, methods and comments to English for the past few years.

What code reformatting tool have you used? I might end using the same tool.
The internal JVC-Lazarus formater (Ctrl-D) though I am not happy with it, the formatter included to Delphi is much more tolerant to errors and new features. (but they left it out in the XE10.1 XE10.2 personal edition ...)

When you said that you had to change folder structure.... Huuummm... I'm able to compile in 3 environments out of the box: 2 environments are windows and 1 environment is linux. I'm also able to crosscompile the libs folder to Android with lamw (watched NN running on Android few days ago and loved). I'll add Android specific work soon.

I wonder if the folder problem is related to the SVN url I check in:
svn+ssh://<user>@svn.code.sf.net/p/cai/svncode/trunk
I drive a very strict security-system (using SRP with heise restric'tor)
only files placed in a specific folder or with a specific hash are allowed to run.
Also i don't like to search through many subfolder to clean the compiler-mess.
so i make a strict separation of Project(information)-Files, Source-code, datafiles (incl. FPDoc & PO), compiler-generated-files and executables
So my filestructure looks like:
Code: Text  [Select][+][-]
  1. + Projects-Root
  2. ++-bin
  3. | +-x86_64-win64 (here are the executables)
  4. | +-i386-win32
  5. |  '- ... more  $(TargetCPU)-$(TargetOS)
  6. +-lib
  7. |  +-<Projectname or PackeageName>
  8. |      +-$(TargetCPU)-$(TargetOS) (here are the compiled units *.ppu *.o *.compiled ...
  9. |
  10. +-FPC (Here are the project-files for lazarus/FPC
  11. +-D... (Here are the project-files for delphi (a directory for each version)
  12. +-Source (Here and in subdirectories are the source-files)
  13. +-Language (*.po *.mo - files for i18n)
  14. +-FODoc ( *.xml for FPDoc-Documentation)
  15. +-Data (Test-Datafiles, when released the Datafiles are in %programData%\<Vendorname>\<AppName> for global data or in %APPDATA%\<Vendorname>\<AppName> for userdata on WinXX
  16. the nearly only file(s) in root are the <Projectname>.lpg (Lazarus-Group-files) <Projectname>_<DVer>.groupproj (Delphi-Group-files) <Projectname>_<DVer>.bdsgrp (Delphi-Group-files <=D2006)
  17.  
I noticed also that you've made some user interface changes (UI isn't my strong):
-      Orientation = pbVertical
+      Orientation = pbTopDown
That was just a test ...

Is there any other change that isn't reformatting in the code?
I think I changed some functionresults from
Code: Pascal  [Select][+][-]
  1. <FunctionName> := <Value>  
to
Code: Pascal  [Select][+][-]
  1.  Result := <Value>
I don't know if it's here or in another project I Changed some
Code: Pascal  [Select][+][-]
  1. <NumerticVal> := integer(Pointer(<something>))  
to
Code: Pascal  [Select][+][-]
  1.  <NumerticVal> := PtrInt(Pointer(<something>))

 :)  Happy Coding  :) ,
JPSS
Thanks.
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

schuler

  • Full Member
  • ***
  • Posts: 223
 :) Hi jc99,  :)

I did plenty of changes inspired on your patch. I haven't applied it directly but I did plenty of code reformatting and some other data structure changes.

Folders have been changed to:

Unit output dir:
..\bin\$(TargetCPU)-$(TargetOS)\units\

Target file name:
..\bin\$(TargetCPU)-$(TargetOS)\bin\

I have already tried some neural networks in 3 android devices and it works well. I'll eventually commit examples.

There are plenty more to come.

 :) I wish everyone happy Object Pascal coding  :),
JP

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
:) Hi jc99,  :)

Target file name:
..\bin\$(TargetCPU)-$(TargetOS)\bin\ [???]


 :) I wish everyone happy Object Pascal coding  :) ,
JP
I use ..\bin\$(TargetCPU)-$(TargetOS)\$Nameonly($Project(InfoFile))
That means the .lpi file gives the name for the binary not the .lpr .
It leaves the posibility to create several .lpi file all with the same .lpr but with different settings. Example: see the fpc-PPC-Compiler *.lpi-files

According to my experience all binaries in your case will be renamed to bin.exe
« Last Edit: June 23, 2017, 12:17:33 am by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

tatamata

  • Hero Member
  • *****
  • Posts: 787
    • ZMSQL - SQL enhanced in-memory database
Re: artificial intelligence, machine learning libraries for Delphi/FreePascal?
« Reply #11 on: January 06, 2021, 12:27:38 pm »
Coming back to this topic...Is there any library covering unsupervised machine learning techniques, i.e. clustering?

 

TinyPortal © 2005-2018