{"id":17992153,"url":"https://github.com/hfleitas/sentimentprediction","last_synced_at":"2026-03-09T11:02:57.988Z","repository":{"id":37230319,"uuid":"132657656","full_name":"hfleitas/SentimentPrediction","owner":"hfleitas","description":"Python and T-SQL solution for Sentiment analysis and Real-time predictions in SQL Server 2017+","archived":false,"fork":false,"pushed_at":"2023-07-20T13:11:19.000Z","size":88572,"stargazers_count":3,"open_issues_count":9,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-14T05:52:23.966Z","etag":null,"topics":["microsoft","prediction","python","sentiment-analysis","sql-server","tpcxbb-1gb-database"],"latest_commit_sha":null,"homepage":"https://dba2o.wordpress.com","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hfleitas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-08T19:52:19.000Z","updated_at":"2022-11-09T16:44:39.000Z","dependencies_parsed_at":"2024-10-29T20:03:39.112Z","dependency_job_id":null,"html_url":"https://github.com/hfleitas/SentimentPrediction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hfleitas/SentimentPrediction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfleitas%2FSentimentPrediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfleitas%2FSentimentPrediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfleitas%2FSentimentPrediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfleitas%2FSentimentPrediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hfleitas","download_url":"https://codeload.github.com/hfleitas/SentimentPrediction/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hfleitas%2FSentimentPrediction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30291844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["microsoft","prediction","python","sentiment-analysis","sql-server","tpcxbb-1gb-database"],"created_at":"2024-10-29T19:27:09.468Z","updated_at":"2026-03-09T11:02:57.950Z","avatar_url":"https://github.com/hfleitas.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"![cover](https://github.com/hfleitas/SentimentPrediction/blob/master/Cover.png \"cover\")\n\n## Resources 🐱‍🚀\n1. [fleitasarts.com](http://fleitasarts.com)\n2. [ailab.microsoft.com](https://ailab.microsoft.com)\n3. SQL Server R Services Samples: [Microsoft Repo](https://github.com/Microsoft/SQL-Server-R-Services-Samples)\n4. Pre-Trained ML Models: [Install in SQL Server](https://docs.microsoft.com/sql/advanced-analytics/r/install-pretrained-models-sql-server)\n5. SQL Server Machine Learning Services: [Tutorials](http://aka.ms/mlsqldev)\n6. SQL Server Components to Support Python: [Interaction of Components](https://docs.microsoft.com/sql/advanced-analytics/python/new-components-in-sql-server-to-support-python-integration?view=sql-server-2017)\n7. hreading ML: [Logistic Regression](https://docs.microsoft.com/machine-learning-server/python-reference/microsoftml/rx-logistic-regression)\n8. Resource Governor: [Alter External Resource Pool](https://docs.microsoft.com/sql/advanced-analytics/r/how-to-create-a-resource-pool-for-r?view=sql-server-2017)\n9. Interactive deep learning: [Learn alert](https://aka.ms/AA3dz6b)\n10. [aka.ms/sqlworkshops](https://aka.ms/sqlworkshops)\n11. [aka.ms/ss19](https://aka.ms/ss19)\n\n# Sentiment Prediction\n### Real-time in SQL Server\nPython and T-SQL solution for Sentiment analysis and Real-time predictions in SQL Server 2017+\n\n## Getting Started\n\nThis example should work on any machine running SQL Server 2017.\n\nIt assumes you have restored the tpcxbb_1gb sample database on a SQL Server 2017 instance. If not, just follow the instructions.\n\nGet Sentiment Example: (requirements: SQL Server 2017+, Machine Learning Services (In-Database) R \u0026 Python, tpcxbb_1gb)\n\ntpcxbb_1gb db (see latest release tpcxbb_1gb.bak [234 MB]): https://sqlchoice.blob.core.windows.net/sqlchoice/static/tpcxbb_1gb.bak\n\n### Prerequisites\n\nPowershell/Cmd, SQL Server 2017, Machine Learning Services (In-Database) R \u0026 Python, tpcxbb_1gb database.\n\n### Installing\n\nInstall SQL Server 2017+ on your local machine. I recommend choosing Developer Edition for the purpose of this example:  https://www.microsoft.com/en-us/sql-server/sql-server-downloads\n\nSelect to Add Feature Machine Learning Services (In-Database), R and Python.\n\nDownload latest release [tpcxbb_1gb.bak [234 MB]](https://sqlchoice.blob.core.windows.net/sqlchoice/static/tpcxbb_1gb.bak) and restore it. (If you already have you may skip this step)\n\nTo restore see file: [SQLServerScripts.sql](https://github.com/hfleitas/SentimentPrediction/blob/master/SQL/SQLServerScripts.sql)\n\n```\n--verify\nrestore filelistonly from disk = 'c:\\users\\hfleitas\\downloads\\tpcxbb_1gb.bak'\ngo \n--set your own paths\nrestore database [tpcxbb_1gb] from disk = 'c:\\users\\hfleitas\\downloads\\tpcxbb_1gb.bak' with replace,\nmove 'tpcxbb_1gb' to 'C:\\Program Files\\Microsoft SQL Server\\MSSQL15.MSSQLSERVER\\MSSQL\\DATA\\tpcxbb_1gb.mdf', \nmove 'tpcxbb_1gb_log' to 'C:\\Program Files\\Microsoft SQL Server\\MSSQL15.MSSQLSERVER\\MSSQL\\DATA\\tpcxbb_1gb.ldf'\ngo\n--rollup compat to 140 for 2017 or 150 for 2019\nalter database [tpcxbb_1gb] set COMPATIBILITY_LEVEL = 150 --2019\ngo\n--update stats (you may skip this step)\nuse [tpcxbb_1gb]\ngo\nEXEC sp_updatestats\n```\n\n1. Enable external scripts by running [SQLServerScripts.sql](https://github.com/hfleitas/SentimentPrediction/blob/master/SQL/SQLServerScripts.sql) on your SQL Server instance. Be aware Reconfigure with Override will immediatly apply any modified config values to the running config.\n```\nEXEC sp_configure 'external scripts enabled', 1\nRECONFIGURE WITH OVERRIDE\ngo\n```\n\n2. Walk through the steps in [SQLServerScripts.sql](https://github.com/hfleitas/SentimentPrediction/blob/master/SQL/SQLServerScripts.sql) to see how Sentiment Analysis works inside the datase.\n\n3. You may Start without Debugging [GetSentimentExample.py](https://github.com/hfleitas/SentimentPrediction/blob/master/Python/Example1.py), in Visual Studio 2017 Community Edition, get the Tools/Features for Python, then  set the Python Envirments to SQLServer2019ctp2 or SQLServer2017PythonSvcs, whichever version of SQL Server you have installed. The prefix path for the Python Enviroment will be like so [C:\\Program Files\\Microsoft SQL Server\\MSSQL15.MSSQLSERVER\\PYTHON_SERVICES], click Auto Detect, Apply and set this as the default enviroment. \n\nEnd with sp_rxPredict:\n\n```\nexec sp_rxPredict @model = @model_bin, @inputData = N'SELECT pr_review_content, cast(tag as varchar(1)) as tag FROM product_reviews_test_data' end;\n```\n\n### Purpose\n\nThis example will illustrate how to:\n* Add ML Features\n* Grant Access\n* Config\n* Install Pre-Trained \u0026 Open Source ML Models (Deep Neural Networks)\n* Code in Python and T-SQL (sp_execute_external_script)\n* Python Profiling\n* Real-time scoring\n* Azure Data Studio Notebooks\n* Cognitive API (Text Analytics)\n\nThe intention is to process large amounts of inputs and predict quality scores fast enough for real-time operations. It's advisable to monitor the system task manager cpu/ram during the train model step(s). \n\n## Deployment\n\nYou may clone this repo and open it in [Azure Data Studio](https://docs.microsoft.com/sql/azure-data-studio/download) or open the solution file [SentimentML.sln] in Visual Studio.\n\nFollow instructions in [SQLServerScripts.sql](https://github.com/hfleitas/SentimentPrediction/blob/master/SQL/SQLServerScripts.sql).\n\n## Built With\n\n* [SQL Server 2017 and up](https://aka.ms/sqlserver) - The #1 database engine in the world.\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/hfleitas/SentimentPrediction) for code of conduct, and the process for submitting pull requests.\n\n## Versioning\n\nI use [Github](http://github.com/) for versioning. For the versions available, see the [tags on this repository](https://github.com/hfleitas/SentimentPrediction/tags). \n\n## Authors\n\n* **Hiram Fleitas** - *This Repo - SentimentPrediction* - [Hiram Fleitas](https://github.com/hfleitas)\n\nSee also the list of [contributors](https://github.com/hfleitas/SentimentPrediction/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* [Nellie Gustafsson](https://github.com/NelGson) - Senior Program Manager (Microsoft)\n* [Sumit Kumar](https://github.com/sumitkmsft) - Principal Product Manager (Microsoft)\n* [Ryan Donaghy](https://github.com/gh-canon) - Senior Software Developer (Universal Property)\n* MS Research and the entire SQL Server ML team.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfleitas%2Fsentimentprediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhfleitas%2Fsentimentprediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhfleitas%2Fsentimentprediction/lists"}