Sklearn Model to JS - javascript

I am working on a sentiment analysis project, where the backbone is ofc a model. This was developed using sklearn's off the shelf solutions (MLP) trained with my data. I would like to "save" this model and use it again in JavaScript.
Adam
I have looked at pickle for python but I'm not sure how i could use this for JS. This is a chrome extension I am developing so I would rather not set up and server. I should add this is course work, so spending money is a no!

After some research I pretty much determined its not possible using sklearn in JS. My solution was to use keras and use tensorflow JS.
Alternatively, I have learnt the maths behind the network and "raw" code it using no libraries. This took a lot longer than just converting everything to keras although.

Related

Load trained Machine Learning model in javascript

I am using sklearn in python to build/train some models (Random Forest Regressor, Kmeans, SVM, ...), and I would like to use those trained models in a webapp Javascript/html. Is there a way to do so?
I've seen that tensorflow.js allows to do such things with keras model. But it seems to me that TF/keras in python are limited to neural network.
I've also seen sklearn-porter, but it seems to be limited to some specific models (classification mostly). If someone managed to use it, can he tells me more?
Thanks in advance for any help
As an option you can simply build RESTfull API in Python (for instance using Flask). After it would be easy just request a prediction from Javascript.
There are few benefits for such approach:
except the model, you still maybe need data preparation functions;
you have to separated projects;
with REST API you can easy add new version of the model;

Writing a file manager in QML

I just started learning QML, with no previous experience in Qt or GUI development in general. My first task is to write a file manager. So far what I like about QML is that I can do design in plain text, but it's been quite challenging finding the way around to achieve even simple things. Currently I use Qt.labs.FolderListModel 2.1 as the work horse for directory listing, and I haven't even touched C++ or PyQt yet, it's purely QML now.
So I have a few questions regarding the future path of my little file manager:
Is FolderListModel powerful enough to do all the things a
versatile file manager can do? As far as I see,
QFileSystemModel looks more feature complete? And the fact
that the former is in Qt.labs worries me a bit. If indeed
FolderListModel is meant to be used as a "quick-and-dirty" thing,
does that mean that it's better to switch to QFileSystemModel
sooner? Since I approached the Qt world from QML rather than the
traditional C++ angle, what is it like to replace my current
FolderListModel code in QML to something backed by Qt/C++ or PyQt?
Related: I heard that it's actually possible to write complete applications in pure QML (with JavaScript). If the application is driven by some back-end, e.g. a database, I can see that QML alone is probably not expressive enough. However, in my case of writing a file manager, despite the "performance" argument, is it a good idea to try to stick to pure QML, using JavaScript for all the business logic?
I have been working recently on a simple file manager in QML. The problems you will face if you stick only to QML are:
not being able to know how many drives are currently plugged in.
not being able to easily sort files by name. Using provided sorting flags will result in having B.txt before a.txt because of the case.
Fortunately it is easy to connect C++ classes with QML so you will always be able to expand default QML features.
How to connect C++ and QML: http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html

Storing user input data in HTML5

A (possible) client has a multipart questionnaire that they want coded in HTML5 (for responsiveness). I was thinking Bootstrap 3, combined with HTML and a bit o' javascript. However, I don't know what their options are regarding tracking the answers.
I'm new to HTML5, coming from the Flash world. What are my options? It seems a job for a backend DB, and I know enough Django to get into trouble, so perhaps that would be the best bet? I have done basic Django sites, but when something goes wrong, oh, it's a bit of a pain! (I haven't found Django as user friendly as I might like)
Is there anything new and funky in HTML5 (I'm not sure how they'd get the data out of local storage)? I'm good at HTML, but don't know all the tricky tricks in HTML5.
Thanks
Use ViewModel with Knockout.js for responsiveness. Its pretty fast.
You can see this sample Knockout.js project here.
Have you taken a look at the Django HTML5 Boilerplate (DH5BP) project1 on GitHub?
From the Readme.md
The Django HTML5 Boilerplate...incorporat[es] the HTML5 Boilerplate (H5BP) project into an easy to consume Django-friendly Python package.
Find out...about HTML5 Boilerplate at https://github.com/h5bp/html5-boilerplate
This project differentiates itself from other H5BP to Django ports, by
including Fabric scripts that automatically convert new versions of
H5BP into a Django-friendly Python module. Ideally, this will make
keeping up-to-date with the latest version of H5BP trivial.
Your best bet is probably to work with a CMS. It would greatly reduce your development time and it would help you avoid common pit-falls.
I would recommend using WordPress with some sort of plugin as in my experience it has been the easiest to work with for small projects.
HTML5 has some new elements and a simplified syntax. Some elements have had their definitions changed (what the tags intended usage is).
Update:
Four years later, WordPress now has a REST API. A good way to store user input could be to check if they are logged in and then post information via AJAX to the API.

How can I handle user data using QT Quick?

I am trying to develop an app for Ubuntu Touch. I am using QML integrated with JavaScript.
I know that it is a huge mess to read or write to files in JavaScript when it is embedded in a webpage, but this is not embedded in a webpage so it should be easier right? The Ubuntu documentation is pretty bad right now.
Does anyone know how I can get this done? I want to get it done without using c++ because using QML, JavaScript and c++ seems like just a big mess. If the only way to do it is using c++ then I guess thats what I will have to do, but I would like to find another way.
You will have to write a wrapper for QFile class that will be exposed to QML code. Here is an example how to do that. I'm not sure if it's outdated but it looks like it should work just fine.
The simplest way to handle data in your Ubuntu Touch app is to actually use SQLite (No surprise there). You can find a really good tutorial on using SQLite with Ubuntu Touch here:
https://askubuntu.com/questions/352157/how-to-use-a-sqlite-database-from-qml
It seems like this is the most efficient way to handle app data in Ubuntu Touch. If you want to be able to write to an actual file, you need to handle it using c++. Check out Kamil's answer for that.

UI technologies for Java EE applications

I need some guidance from the experts.
Till now I have worked on Java and Java EE stuff along with Unix scripting etc. But everything was on the backend side. So I never actually touched the UI code much other than occasional cosmetic changes.
But now I have got one project where we need to work on the frontend part as well.
As I learnt from my colleagues, we need to know CSS, Html, Javascript, XSLT/XPath etc to make a good user friendly UI.
So could you kindly guide as to where to start. I feel that there are lot of things put together.
I tried to read up these things separately e.g. CSS thru W3C , Javascript thru W3C and I understood them but when it comes putting all of these together I am faltering. Require your suggestions to overcome this
I guess you are mostly interested in web applications development. In any case, it's good to know CSS (mainly CSS3) and HTML (preferably HTML 5) as well as a javascript library such as jQuery. Regarding the web frameworks to start with. Here are some choices. You may look around to see their pros and cons. So, here they are some of these:
JSF 2.0 is a brilliant framework following the Model View Controller pattern, that can be combined with an off the shelf javascript component library for JSF such as richfaces, primefaces, icefaces to give you a Rich Internet Application experience.
Groovy on Grails is also an excellent framework enabling you to write also in Groovy, starting usually from the domain layer and creating automatically a scaffold to work with - Similarly, Ruby on Rails offers the possibility to work with Ruby.
Spring MVC is also a great and popular framework to work with.
Django Python is a popular framework for writing in python, "Play!" framework to work with scala and many more.
So, choose the flavor you prefer and try delving into its details. Hope I have helped you.
If you are using Java EE, there's already a good UI framework available in that stack called JSF.
A good text to get started with it is JSF 2.0 tutorial with Eclipse and Glassfish

Categories

Resources