New answers tagged

0

You can also do this with the dplyr package. The dplyr package has the functions group_by to group your data by one or more variables and summarise to do some aggregation function. The dplyr package also supports the 'pipe' notation %>%. This notation means the output of the previous function is the first argument of the next function. Here is what it ...


0

I like to use the plyr library but there are other ways: library(plyr) ddply(mydata, c('Replicate','Node','Day'), nrow) the dd in ddply means that the input is a dataframe and the output is also a dataframe the rows are grouped by the values of columns given as second argument the last argument is the function to apply on every group, in this case nrow to ...


1

Your model is clearly overfitting. You should use higher dropout value like 0.5 .For better generalization use deep models. And you can also use early stopping so that your model stops training before significantly overfitting.


0

A correlation matrix is symmetric because it represents correlations among variables and correlation is a symmetric relation. What is a correlation matrix? A bit more formally, for a set of $n$ random variables $X_{1},\ldots ,X_{n}$ the correlation matrix contains at place $(i,j)$ the value of the correlation between $X_{i}$ and $X_{j}$. Denote by $corr(X_{i}...


0

Please try duplicating the specific company's data ten times or more, and include more samples in cross/test data from that company-specific data (3:1). I hope this will have some positive implications.


0

I don't think that's a very good idea: the goal is not to make the model predict a more extreme polarity when the tweet relates to the company. Instead you might want to consider oversampling the few instances of this specific company. For instance if you have 100 company-specific tweets and 1000 general tweets in your training set, you could duplicate the ...


2

Well assuming df is your Pandas dataframe you could sort it by Artist and then do something like this: df = df.drop_duplicates(subset='Artist', keep='first')


0

Maybe they found out that they wrong identified 209 patient as positive and when they found out that they just subtracted those wrong result to make the total case correct.


1

Looks like that number is calculated from the total_cases column. Value = "total_cases from day before" - "total_cases of that day". In this case: -209 is 130 - 339. Not sure why that number would decrease, but could be they changed the way they count, or just an error in the data.


0

col = [] for c in df.columns: if df[c].dtypes=='object': col.append(c) df_dummies = pd.get_dummies(df , columns=col, drop_first=True) ## get dummies part It is a good practice to use the drop_first parameter as it would avoid the model getting overfitted.


1

Not sure what you are after, but Kaggle has many datasets you can use. You can use this search to get started: https://www.kaggle.com/search?q=ordinal+datasetSize%3Asmall+datasetSize%3Amedium another source: https://www.gagolewski.com/resources/data/ordinal-regression/


0

As the error says: there is no categorical_values parameter for OneHotEncoder. It was removed at the same time that OneHotEncoder was extended to deal with strings directly, and you may want to use ColumnTransformer for selecting out the categorical column(s). For example, https://datascience.stackexchange.com/a/57383/55122


0

Its easier to perform this by method get_dummies: X_enc = pd.get_dummies(X) Reference: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.get_dummies.html


1

Here is a quick solution that does not do it in-place but takes up extra space: def transform_series(x, chunk_size): df = pd.DataFrame() for i in range(chunk_size): df[f'column_{i+1}'] = x[i::chunk_size].reset_index(drop=True) return df input_series = pd.Series([10,11,12,13,14,15]) transformed_df = transform_series(input_series, ...


0

Here are a few ideas to start with: A simple model would be to use multiple linear regression (MLR), or a Random Forest If you want to evaluate only based on if an ingredient is used, your input dataset could look like this: Butter Flour Eggs ... Test Smell Look Texture 1 0 1 1 5 2 4 If you want to ...


2

Use pandas.DataFrame.reindex() df = pd.concat((df1, df2), axis=1) #reorder columns column_names=["A","C","B","D"] df = df.reindex(columns=column_names)


0

I'd do pandas.concat and then reorder my columns. Something like this: # Concatenate along axis 1 df_new = pd.concat((df1, df2), axis=1) # New order of columns, interleaved in this case new_cols_order = np.array(list(zip(df1.columns, df2.columns))).flatten() # Reorder columns df_new = df_new[new_cols_order] Edit: I noticed the answer from Dee, which came ...


3

You can have a look at the kaggle stock dataset. https://www.kaggle.com/borismarjanovic/price-volume-data-for-all-us-stocks-etfs This questions are normally done in OpenData stack exchange. https://opendata.stackexchange.com/


0

Vasim's code gives me negative results Values_2009 Values_2014 CAGR <dbl> <dbl> <dbl> 1 10000 19500 -15.4 2 10500 15000 -8.53 3 25000 35500 -8.39 You need to swap the parameters in the function and also there are 5 years growth in the data. Full example: example_data <- tribble(...


1

You can check the class of the class(df$dependent). You are expecting it to be numeric. To convert multiple columns to factors, you can do something like this factor_cols <- c("col_1","col_7"), df[factor_cols] <- lapply(df[factor_cols], as.factor) If you keep the customer id, then you will have a problem when applying your model to a new customer.


0

First off, I would point out that both concepts can very well coexist. Let's take the following example: Image classification including 2 classes and samples covering 2 domains. The classes are imbalanced and one domain is "harder" than the other. You could use weighted sampling to sample more examples from the "harder" domain while simultaneously use a ...


Top 50 recent answers are included