Пример #1
0
def main(input_filepath, output_filepath):
    # make_data_set(input_filepath, output_filepath)
    # visualize(output_filepath)
    # create_trained_model(output_filepath)
    print(
        predict(
            "my cat doest like the milk that I bought from the store yesterday"
        ))
def main():
    train, test, words, users = make_dataset.main()
    X, y, final_test = build_features.main(train, test, words, users)

    pipeline = train_model.fit(X, y)

    submissions = predict_model.predict(pipeline, final_test)

    save_submission.save(submissions)
Пример #3
0
def full_workflow(historical=True):
    # Create dataset
    df_canonical = build_features.make()
    build_features.persist(df_canonical)

    # Normalize dataset
    df_normalized = normalize_features.make()
    normalize_features.persist(df_normalized)

    if historical is True:
        (train_dataset, train_labels), (
            test_dataset, test_labels
        ) = split_dataset.split_training_data_randomly_with_seed(df_normalized)

        # Train model
        model = train_model.make("dev")
        train_model.persist(model)

        # Create predictions
        predictions = predict_model.predict()
        # Evaluate predictions
        predict_model.evaluate_predictions(predictions, test_labels)

    else:
        train_dataset, train_labels = split_dataset.pop_label(df_normalized)

        test_dataset = build_features.make(build_test_game_data.make())

        normalized_test_dataset = normalize_features.make(test_dataset)
        normalized_test_dataset = add_dummies(normalized_test_dataset,
                                              train_dataset)

        # Train model
        model = train_model.make("test", train_dataset, train_labels)
        train_model.persist(model)

        # Create predictions
        predictions = predict_model.predict(normalized_test_dataset)
        df_predictions = build_test_output(test_dataset, predictions)
        fr = ProcessedFilePersistence('2019Predictions.csv')
        fr.write_to_csv(df_predictions)
        build_bracket_output()
    build_data()
    create_freq_chart()
    create_wordclouds()
    transform_data()

    train_model(algorithm="svm", method="bag_of_words")
    test_model(algorithm="svm", method="bag_of_words")
    train_model(algorithm="knn", method="bag_of_words")
    test_model(algorithm="knn", method="bag_of_words")
    train_model(algorithm="naive_bayes", method="bag_of_words")
    test_model(algorithm="naive_bayes", method="bag_of_words")
    train_model(algorithm="linear_regression", method="bag_of_words")
    test_model(algorithm="linear_regression", method="bag_of_words")
    train_model(algorithm="random_forest", method="bag_of_words")
    test_model(algorithm="random_forest", method="bag_of_words")
    train_model(algorithm="svm", method="tf_idf")
    test_model(algorithm="svm", method="tf_idf")
    train_model(algorithm="knn", method="tf_idf")
    test_model(algorithm="knn", method="tf_idf")
    train_model(algorithm="naive_bayes", method="tf_idf")
    test_model(algorithm="naive_bayes", method="tf_idf")
    train_model(algorithm="linear_regression", method="tf_idf")
    test_model(algorithm="linear_regression", method="tf_idf")
    train_model(algorithm="random_forest", method="tf_idf")
    test_model(algorithm="random_forest", method="tf_idf")

    create_results_chart()
    txt = "Fahrettin Koca yeni tedbirlere yönelik açıklamalarda bulundu."
    result = predict(txt, algorithm="svm", method="bag_of_words")
    print(f"Tahmin sonucu: {result}")
Пример #5
0
def predict(customer_id: int, month: int):
    predict_model.predict(customer_id, month)