Python Code Prediction

No algorithm description given

This algorithm predicts the next word or symbol for Python code. For example, given the sequence for i in the algorithm predicts  range  as the next word with the highest probability   as can be seen in the output of the algorithm: [ ["range", 0.703558325767517],
 ["xrange", 0.06841153651475905],
 ["", 0.061689313501119614],
 ["self", 0.03619486093521118],
 ["(", 0.021298892796039578],
 ["[", 0.009143630042672157],
 ["enumerate", 0.006539389025419952],
 ["sorted", 0.005506967194378374],
 ["reversed", 0.0036436754744499926],
 ["six", 0.0036100521683692936]
] The number represents the probability of each token given the input. The API can also generate suggestions with longer sequences. Calling the model with: {"code": "for i in", "num_tokens": 5, "num_results": 1} generates the following output: [["range", "(", "<NUM>", ")", ":"]] The algorithm generates the suggestion range(<NUM>): Note that  i n the case of sequence prediction, the algorithms doesn't include probabilities.  Some other examples: input predicted next word probability
def add ( 0.99701058
import numpy as np 0.99618226
else: \n (line ending) 0.96662628
for i in range 0.59164410
from __future__ import absolute_import 0.47429805
 Enter some code and try it yourself! Special symbols: <UNK> other/unknown
 <NUM> numeric Input Either: the source code as String or dictionary {code: String}. Optional, for next word prediction:  num_results: Int (min 1, max 100) . For sequence prediction: num_tokens: Int  (min 1, max 100) . The complete list of arguments: argument type description 
code string code as raw text

num_results int (optional) number of results for word or sequence prediction
 (default: 10)

num_tokens int (optional) number of tokens to use for sequence prediction (will enable sequence prediction)

diversity float [0.0 - 3.0] amount of diversity for sequence prediction: >= 1.0 means very diverse, 0.0 very
 (optional) conservative (you should probably use a value somewhere between 0.0 and 1.0)
 (default: 0.5) Output List of pairs: [[String, Foat]I (prediction and probability) for word prediction or [[ String ]] (code)   in case of sequence prediction.

(no tags)

Cost Breakdown

20 cr
royalty per call
1 cr
usage per second
avg duration

Cost Calculator

API call duration (sec)
API calls
Estimated cost
per calls
for large volume discounts
For additional details on how pricing works, see Algorithmia pricing.

No permissions required

This algorithm does not require any special permissions.

To understand more about how algorithm permissions work, see the permissions documentation.

1. Type your input

2. See the result

Running algorithm...

3. Use this algorithm

curl -X POST -d '{{input | formatInput:"curl"}}' -H 'Content-Type: application/json' -H 'Authorization: Simple YOUR_API_KEY'
View cURL Docs
algo auth
algo run algo://PetiteProgrammer/pythoncodeprediction/1.0.4 -d '{{input | formatInput:"cli"}}'
View CLI Docs
import (
  algorithmia ""

input := {{input | formatInput:"go"}}

var client = algorithmia.NewClient("YOUR_API_KEY", "")
algo, _ := client.Algo("algo://PetiteProgrammer/pythoncodeprediction/1.0.4")
resp, _ := algo.Pipe(input)
response := resp.(*algorithmia.AlgoResponse)
View Go Docs
import com.algorithmia.*;
import com.algorithmia.algo.*;

String input = "{{input | formatInput:"java"}}";
AlgorithmiaClient client = Algorithmia.client("YOUR_API_KEY");
Algorithm algo = client.algo("algo://PetiteProgrammer/pythoncodeprediction/1.0.4");
AlgoResponse result = algo.pipeJson(input);
View Java Docs
import com.algorithmia._
import com.algorithmia.algo._

val input = {{input | formatInput:"scala"}}
val client = Algorithmia.client("YOUR_API_KEY")
val algo = client.algo("algo://PetiteProgrammer/pythoncodeprediction/1.0.4")
val result = algo.pipeJson(input)
View Scala Docs
var input = {{input | formatInput:"javascript"}};
           .then(function(output) {
View Javascript Docs
using Algorithmia;

var input = "{{input | formatInput:"cs"}}";
var client = new Client("YOUR_API_KEY");
var algorithm = client.algo("algo://PetiteProgrammer/pythoncodeprediction/1.0.4");
var response = algorithm.pipe<object>(input);
View .NET/C# Docs
var input = {{input | formatInput:"javascript"}};
           .then(function(response) {
View NodeJS Docs
import Algorithmia

input = {{input | formatInput:"python"}}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('PetiteProgrammer/pythoncodeprediction/1.0.4')
print algo.pipe(input)
View Python Docs

input <- {{input | formatInput:"r"}}
client <- getAlgorithmiaClient("YOUR_API_KEY")
algo <- client$algo("PetiteProgrammer/pythoncodeprediction/1.0.4")
result <- algo$pipe(input)$result
View R Docs
require 'algorithmia'

input = {{input | formatInput:"ruby"}}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('PetiteProgrammer/pythoncodeprediction/1.0.4')
puts algo.pipe(input).result
View Ruby Docs
use algorithmia::Algorithmia;

let input = {{input | formatInput:"rust"}};
let client = Algorithmia::client("YOUR_API_KEY");
let algo = client.algo("PetiteProgrammer/pythoncodeprediction/1.0.4");
let response = algo.pipe(input);
View Rust Docs
import Algorithmia

let input = "{{input | formatInput:"swift"}}";
let client = Algorithmia.client(simpleKey: "YOUR_API_KEY")
let algo = client.algo(algoUri: "PetiteProgrammer/pythoncodeprediction/1.0.4") { resp, error in
View Swift Docs
  • {{comment.username}}