Categories
Mastering Development

How to use a cut in prolog to find the number of daughters?

Exercise: Observe the family structure below where each person has a gender specification as their third parameter (m = male, f = female). Use a cut to write the predicate numDaughters(L, Count) in such a way that family(Husband, Wife, Kids), numDaughters([Husband, Wife|Kids],X) lists each family in the database and the number of daughters in each […]

Categories
Mastering Development

Sort data by bins using groupby

I want to show the most frequent genre (df.listed_in) of program in each decade (df.release_year) I can show the most frequent by year using the following formula df.groupby(‘release_year’)[‘listed_in’].apply(lambda x: x.mode().iloc[0]) that shows the following result: To show the most frequent genre by decade I tried the following formula: bins = [1925,1950,1960,1970,1990,2000,2010,2020] groups = df.groupby([‘listed_in’, pd.cut(df.release_year, […]

Categories
Mastering Development

avoid overwrite values using time series and forecast future value in loop R

I am running loop in R for time series (5y point) data. I want to get a result for new data (rata) using a formula (include initial and prior values). But, I get something weird. Gere is my code: n=7 set.seed(1) #data ta=c(1950,1955,1960,1965,1970,1975,1980) ra=c(1.7,1.3,-2.7,-2.4,3.3,5.7,1.7) rata=matrix(c(ta,ra),nrow=7) #rata ## initials a=runif(n,1,10) b=runif(n,0,10) c=runif(n,-100,100) d=runif(n,0,100) #priors p=runif(n,0,1) q=rnorm(n,c,d) […]

Categories
Mastering Development

ignore all commas, dots, single quotes and double quotes between double quotes java

This is one example of my csv file where I have for example 2 commas inbetween quotes and also a single quote. "16788","Michel Georges Bury","M",44,179,74,"France","FRA","1996 Summer",1996,"Summer","Atlanta","Shooting","Shooting Men’s Small-Bore Rifle, Prone, 50 metres",NA or this one: "6036","Carl Auteried, Sr.","M",45,172,74,"Evita VI","AUT","1960 Summer",1960,"Summer","Roma","Sailing","Sailing Mixed Two Person Heavyweight Dinghy",NA I am using String[] fields = line.replaceAll("\"", "").split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*)"); to split […]

Categories
Mastering Development

What is the problem with the axis of my factorplot?

I have this dataset: kaggle: House Prices: Advanced Regression Techniques. I loaded it as follows: import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns import scipy.stats as st train = pd.read_csv(“train.csv”) I then attempted to plot SalePrice by YearBuilt using OverallQual as the hue: plt.figure(figsize = […]

Categories
Mastering Development

Why does my getter return [LSubmarineClass;@27c170f0 when it should return the array of objects

Im trying to create a class called ShipStorage which stores objects of submarine class in an array of type submarince class. When I use the getters and setters for the array submarine, it prints [LSubmarineClass;@27c170f0. Can someone please explain what is happening here and what im doing wrong. class ShipStorage { private Submarine[] submarine; public […]

Categories
Development

mapply giving non-numeric argument to binary operator error in R

I am trying to generate a variable flagging implausible age differences between respondents and their parents in a household roster. I have two issues i) my function does not replace the flag variable with TRUE when it should, ii) mapply gives an error on ” non-numeric argument to binary operator error” while I don’t get […]

Categories
Development

If else statement with 4 years variable including knowing which year it is

So the question stated is: There is year 1950-2050 and we have the olympic games and football/soccer world championship. The program should be able to tell which one it is based from these two variables and how the program should know is from the year between 1950-2050. The program should also be able to tell […]

Categories
Development

If else statement with 4 years variable including knowing which year it is

So the question stated is: There is year 1950-2050 and we have the olympic games and football/soccer world championship. The program should be able to tell which one it is based from these two variables and how the program should know is from the year between 1950-2050. The program should also be able to tell […]