Skip to content

Instantly share code, notes, and snippets.

View shashwatwork's full-sized avatar
💭
Happy Learning!

SHASHWAT TIWARI shashwatwork

💭
Happy Learning!
View GitHub Profile
apiInterface=ApiClient.getApiClient().create(ApiInterface.class);
Call<Pojo> call = apiInterface.getAPIResponse(vizdata);
call.enqueue(new Callback<Pojo>() {
@Override
public void onResponse(@NonNull Call<Pojo> call, @NonNull Response<Pojo> response) {
Pojo pojo=response.body();
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Heart Prediction");
alertDialog.setMessage("Predicted Result is "+pojo.getIsHeart());
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
package com.infinitemakerz.heartdiseaseprediction;
import com.google.gson.annotations.SerializedName;
public class Pojo {
@SerializedName("isHeart")
private String isHeart;
@SerializedName("CHECK")
private String CHECK;
package com.infinitemakerz.heartdiseaseprediction;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface ApiInterface
{
package com.infinitemakerz.heartdiseaseprediction;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ApiClient
{
private static final String BASE_URL="https://heart-prediction.herokuapp.com";
private static Retrofit retrofit;
public static Retrofit getApiClient()
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(“https://api.github.com/")
.build();
Demo service = retrofit.create(Demo.class);
Call<List<Movie>> movie = service.listMovie(“Gino Osahon”);
public interface Demo {
@GET("users/{user}/repos")
Call<List<Movie>> listMovie(@Path("user") String user);
@GET("group/{id}/users")
Call<List<User>> groupList(@Path("id") int groupId);
}
// Query parameters can also be added to a method.
@GET(“group/{id}/users”)
Call<List<User>> groupList(@Path(“id”) int groupId, @Query(“sort”) String sort);
recomendations = model.transform(single_user)
recomendations.orderBy('prediction',ascending=False).show()
single_user = test.filter(test['userId']==11).select(['movieId','userId'])
# User had 10 ratings in the test data set
# Realistically this should be some sort of hold out set!
single_user.show()
from pyspark.ml.evaluation import RegressionEvaluator
evaluator = RegressionEvaluator(metricName="rmse", labelCol="rating",predictionCol="prediction")
rmse = evaluator.evaluate(predictions)
print("Root-mean-square error = " + str(rmse))
predictions = model.transform(test)
predictions.show()