小编Dee*_*aya的帖子

TypeError:预期序列或类似数组,得到估计量

我正在开发一个对产品进行用户评论的项目.我使用TfidfVectorizer从我的数据集中提取功能,除了我手动提取的一些其他功能.

df = pd.read_csv('reviews.csv', header=0)

FEATURES = ['feature1', 'feature2']
reviews = df['review']
reviews = reviews.values.flatten()

vectorizer = TfidfVectorizer(min_df=1, decode_error='ignore', ngram_range=(1, 3), stop_words='english', max_features=45)

X = vectorizer.fit_transform(reviews)
idf = vectorizer.idf_
features = vectorizer.get_feature_names()
FEATURES += features
inverse =  vectorizer.inverse_transform(X)

for i, row in df.iterrows():
    for f in features:
        df.set_value(i, f, False)
    for inv in inverse[i]:
        df.set_value(i, inv, True)

train_df, test_df = train_test_split(df, test_size = 0.2, random_state=700)
Run Code Online (Sandbox Code Playgroud)

上面的代码工作正常.但当我将max_features45从更改为更高时,我会tran_test_split在线上出错.

错误是:

Traceback (most recent call last): File "analysis.py", line 120, …

python-2.7 pandas scikit-learn

6
推荐指数
2
解决办法
8515
查看次数

访问作业参数 Spring Batch

我一直在努力使用 Spring Batch 访问作业的作业参数。这是到目前为止我的实现。

@Configuration
@EnableBatchProcessing
@PropertySource("classpath:batch.properties")
public class CSVBatchServiceImpl extends StepExecutionListenerSupport implements CSVBatchService {
    private static final Logger LOGGER = LoggerFactory.getLogger(CSVBatchServiceImpl.class);
    @Autowired
    public JobBuilderFactory jobBuilderFactory;
    @Autowired
    public StepBuilderFactory stepBuilderFactory;

    private QuestionReader questionReader = new QuestionReader();

    @Bean(name = "importQuestionsJob")
    public Job importQuestionsJob() {
        return jobBuilderFactory.get("importQuestionsJob")
                .incrementer(new RunIdIncrementer())
                .flow(step1())
                .end()
                .build();
    }

    @Bean
    public Step step1() {
        return stepBuilderFactory.get("step1")
                .<Question, Question>chunk(2)
                .reader(questionReader.reader())
                .processor(processor())
                .build();
    }

    @Bean
    public QuestionProcessor processor() {
        return new QuestionProcessor();
    }
}

class QuestionReader extends StepExecutionListenerSupport {
    private …
Run Code Online (Sandbox Code Playgroud)

java spring spring-batch java-8 spring-boot

5
推荐指数
1
解决办法
2万
查看次数

WAL存档:FAILED(请确保WAL装运已设置)

我正在尝试将Barman配置为备份.当我这样做时,barman check replica我会继续:

Server replica:
WAL archive: FAILED (please make sure WAL shipping is setup)
PostgreSQL: OK
superuser: OK
wal_level: OK
directories: OK
retention policy settings: OK
backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
compression settings: OK
failed backups: OK (there are 0 failed backups)
minimum redundancy requirements: FAILED (have 0 backups, expected at least 2)
ssh: OK (PostgreSQL server)
not in recovery: FAILED (cannot perform exclusive backup on a standby) …
Run Code Online (Sandbox Code Playgroud)

postgresql postgresql-9.6 barman

1
推荐指数
1
解决办法
3573
查看次数