Better HN
topnewbestaskshowjobs
Log inSign up

pprogrammer

31 karma · joined Jul 18, 2016 (10y ago) · 13 submissions

Submissions

1.

Python Code Suggestions Using a Long Short-Term Memory RNN(blog.algorithmia.com ↗)

7 points · by pprogrammer · 10y ago · discuss

2.

Show HN: Python next word prediction(algorithmia.com ↗)

4 points · by pprogrammer · 10y ago · discuss

comment 10y ago · link · parent

The model does generalize to data it hasn't seen before (and that's validated using a validation set) but not to data that isn't similar to the data set. For example, it would probably not detect the programming language well when only using comments.

comment 10y ago · link · parent

puts is probably much more informative than <<

comment 10y ago · link · parent

It probably does not contain a lot of es6 syntax, and the let keyword probably occurs a lot more in other languages (Swift, Haskell, Lua). You could try to add more code to disambiguate it, for example adding a semicolon already displays it as second.

comment 10y ago · link · parent

This is a great idea! I did think of something like this, because similar languages often end up in the top-3 of the classifier.

comment 10y ago · link · parent

That would probably work OK, I guess, but some languages have the same keywords, so I don't think you'll get very high accuracy. I also tried a word level n-grams with linear classifiers, I couldn't get very high accuracy out of it. Also n-grams with higher values for n improve accuracy a lot if you train it with a lot of data, both for word-level models as for character level.

comment 10y ago · link · parent

Interesting example. It is not a valid Python/C example, you wouldn't find such an example in the code (edit: dataset). The model also isn't trained on small code snippets (only on running code), this is currently probably a weak spot.

I agree a lot would be possible using formal grammar indeed but it would be probably a lot of work to maintain all the parsers. Also some languages share a lot of the same syntax, so in some cases this may lead to ambiguity. Maybe you could use a combination of both approaches in that case.

comment 10y ago · link · parent

Great idea! Will think about this when I am going to add languages.

comment 10y ago · link · parent

Probably almost all of the samples are syntactically valid, but it probably works OK for invalid code. Adding or removing symbols can have an impact on the results though, as those may occur more frequently in other languages.

comment 10y ago · link · parent

I tried a linear classifier, yes. It works decent too, but has lower accuracy when using a big dataset (+/- 98% top-1 accuracy vs. 99.4%).

12.

Show HN: Detecting the Programming Language of Code Using ML and Neural Networks(danielheres.space ↗)

53 points · by pprogrammer · 10y ago · 28 comments